Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to add Rhino Mocks 3.5 to a .NET 2.0 project in Visual Studio 2010

We're upgrading from Dev Studio 2005 to Dev Studio 2010. I opened my 2005 solution in Visual Studio 2010 and went through the conversion process keeping all projects targeted at .NET 2.0. When I try to build the project, my references to Rhino.Mocks.dll are failing to be used. I see errors like this:

DalDiscoveryTest.cs(7,7): error CS0246: The type or namespace name 'Rhino' could not be found (are you missing a using directive or an assembly reference?)

I went into my project and removed the reference to Rhino.Mocks.dll and attempted to re-add it. Then I get a dialog that reads:

'Rhino.Mocks.dll', or one of its dependencies, requires a later version of the .NET Framework than the one specified in the project. You can change the .NET Framework target by clicking Properties on the Project menu and then selecting a new target in the '.NET Framework' dropdown box. ...

I'm using "Rhino Mocks 3.5 for .NET 2.0" available at http://www.ayende.com/projects/rhino-mocks/downloads.aspx. This project builds fine in Dev Studio 2005 using .NET 2.0. The only was around the issue that I've found is to change the target of the test projects to .NET 3.5, but I'm wanting to minimize changes initially.

Is there any way around this problem besides changing the target to a newer version of .NET?

like image 547
Eli Avatar asked Dec 12 '22 22:12

Eli


1 Answers

I contacted MSDN support directly to try to get a hotfix for this issue. They were able to reproduce this problem in Visual Studio 2008 and 2010. There isn't a hotfix, but there is a relatively simple fix you can do by modifying your project's settings.

  1. Add the reference to the third-party DLL (Rhino.Mocks.dll) into the project and ignore the warning by clicking "Yes".
  2. Click on the project reference and in the property window modify the "Specific Version" of Rhino.Mocks to "True".
  3. Right click on the project node in the solution explorer in Visual Studio 2010 and select "Unload Project".
  4. Right click on the project node and select "Edit Your Project Name Here".
  5. After the line starting with <Reference Include="Rhino.Mocks, ...">, add the following line: <SpecificVersion>True</SpecificVersion>.
  6. Reload the project by right clicking the project node and select "Reload".
  7. Rebuild your project.

This worked for me.

like image 185
Eli Avatar answered Dec 21 '22 23:12

Eli