9

VS2010: In my newly created project, any time I try to add a reference to any of my other projects or, in this case, MySql.Data...I get an error that says "Incompatible Reference" - "In order to add it you should to change the project's target to a compatible framework first"

My project's target is set to .NET 4 and whether or not the reference I'm trying to add is or isn't set to .NET 4 I still get the error. Anyone got any suggestions? Thanks

J Benjamin
  • 4,722
  • 6
  • 29
  • 39

5 Answers5

11

well I'm not sure what the problem was but if I browse to the physical file to add the reference instead of using the "Recent" or other dialogues in the the Add References window, it works just fine. Never figured out why the other way stopped working for me.

J Benjamin
  • 4,722
  • 6
  • 29
  • 39
2

I had the same problem. The problem was resolved by adding the reference to the compiled dll file. It would work for me, but I got curious why this worked and the reference of the project doesn't.

I checked the project that I wanted to reference. In this project two more projects are referenced. I resolved the error by doing the following:

  1. Added the project (x) to my solution that I liked to reference
  2. Added the projects (ref1 and ref2) that are referenced in the reference project (x).
  3. Added the reference (x) to the consumer project
  4. No error occurred.

I hope this helps you in the future.

Regards,

Stefan

Stefan
  • 21
  • 1
1

You eliminated the obvious reason to get this error. What's left is adding an assembly that was built to run on another target platform. Like Silverlight or Windows Phone. You can't mix these platforms, they run with a different version of the CLR and mscorlib. No shortcut for that, you'll have to rebuild the assembly.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
0

I was having the same issue with my .Net assembly compiled at .Net Framework 4.0 After search a lot, I find the problem...to my case was the reference that I created in windows registry to see my assembly in Visual Studio References Screen: HKEY_CURRENT_USER\Software\Microsoft.NETFramework\v2.0.50727\AssemblyFoldersEx\BNB.Seguranca.V2.0

the value was with a empty space in the begin of the registry value, that was causing a problem do find the assembly in correct folder.

olavooneto
  • 65
  • 2
0

J Benjamin,

We've created a tool that will help you to achieve your goal. Muse VSReferences will allow you to add a Global Assembly Cache reference to the project from Add GAC Reference menu item.

enter image description here

Regards

BALKANGraph
  • 2,031
  • 1
  • 15
  • 16
  • thanks i'll check it out...the reason that problem happened in the first place is because I was references other projects in my solution that had originally had references in them to dll's...well when we moved over to a new source control, the migration team changed them so that they referenced projects instead of build dll's...so when I referenced the project, and it didn't have ITS referenced project in my solution, was causing strangeness...and it was hard to see too, the only way I found it was just happen to see that some had a path and some didn't...inside the referenced projects – J Benjamin Jun 21 '11 at 19:26