I ran into this weird compile time error the other day, and as it turned out, this is due to the limitation of Visual Studio 2005 deployment capabilities. 

 A Google search on that error would turn out many hits. The official explanation can be found in this Microsoft knowledge base article. In my case, I have a solution file that contains multiple projects. Among them, one is a web project and one is a console application project. And the web project has a reference to the console application since it shares some functionality with the console app.

This setting has been working well until I added a web deployment project. After adding the web deployment project, I would get

Could not Find File ‘Microsoft.Windows.CommonLanguageRuntime, Version=2.0.50727.0

error at compile time. The easiest way to get around this limitation is to change the console application into a class library and create another project (in this case a console application) that simply instantiate the class and cal the original console app’s corresponding function. Using this technique, the web application no longer references to the console application but to a class library and thus the above compile time error would not occur.

After you fix this error, you might get a "could not find certificate error" when you try to compile. This is because when the deployment project was built the very first time (when the web project had a reference to the console application), the deployment was trying to build the console application portion as a ClickOnce application. If you look at the project settings (Project->Properties) for the console app (or class library if you had changed it to a class library project), you will see that the "Sign the ClickOnce manifests" option is checked. Uncheck this option will eliminate the certificate error. The check box might be checked but grayed out (at least this was what I saw), and if this is the case, you will need to manually remove the configuration from the .proj file (search for ClickOnce).

Be Sociable, Share!

Leave a Reply

Your email address will not be published. Required fields are marked *