Thursday, January 20, 2011

Reference Removed Build Visual Studio 2010

Having trouble with a reference you imported when you try to build or debug an application with Visual Studio 2010?

I noticed an issue with VS2010 when I was creating a simple VB.NET console application using Google's GData Client API. I began by adding the reference to a .dll file and then adding a "Imports Google.GData.Client" to the top of my code. All pretty standard right?

I was then able to write out the code for my application using this API; everything seemed to be working fine. Intellisense picked up the classes and all. Then I tried to debug and everything fell apart.

Suddenly it was if I had never added the reference to my class. I was getting Type not defined errors and namespace issues with my imports statement. I checked my references and found my expected .dlls, but went ahead and re-added them anyways. All my errors cleared out and everything again looked fine. I tried to build and debug again and kept hitting the same issue.

After a long time, I finally found a solution!
Go to your application's properties, click on the Compile tab and set the "Target framework (all configurations):" dropdown from ".NET Framework 4 Client Profile" to ".NET Framework 4"


Click OK and save. Your applications will probably shut down all windows, but now you should be able to debug and build your application successfully (assuming you have no other errors). At least the reference issue will be solved.

1 comments:

Rob Fine said...

I received an email from Farzad with some additional links on this subject.

http://msdn.microsoft.com/en-us/library/cc668079.aspx

And for those targeting the .NET Framework 4 Client Profile, you cannot reference an assembly that is not in the .NET Framework 4 Client Profile. Instead you must target the .NET Framework 4:
http://msdn.microsoft.com/en-us/library/cc656912.aspx

Thanks for your contribution, Farzad.

Post a Comment