I’ve been working in service land for the last few weeks and have been noticing occasionally when I didn’t boot Visual Studio up in admin mode my WCF Service projects wouldn’t load. This only seemed to happen occasionally so I did a little digging and found out that it only occurs when you’ve set the project to run using IIS as the host.
The quick fix here is to run Visual Studio in elevated mode using the right click ‘Run as Administrator’ command, however that didn’t seem to solve the issue when running on my new Fujitsu tablet. If you’re loading up Visual Studio as an administrator and still getting the COM exception on your WCF project, try the following steps as a workaround…
1. Close the solution in Visual Studio
2. Ensure your .csproj (or VB equivalent) file is writable by opening the file properties and ensuring the read-only checkbox is unchecked.
3. Open the csproj file in your favourite text editor (I use Notepad++) and scroll right down to the bottom
4. Change the use IIS setting to false
5. Save the file and re-open the solution in Visual Studio (recommended to run as admin).
6. If you want to continue to publish to IIS go back to the project properties in Visual Studio and set it back to run under IIS. Otherwise it will run as normal with the WcfServiceHost.
That’s pretty much it. It’s a quick workaround to get your troublesome IIS hosted service open in visual studio again, ready for some development love.