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

We are upgrading from Dev Studio 2005 to Dev Studio 2010. I opened my 2005 solution in Visual Studio 2010 and went through the conversion process, supporting all projects oriented to .NET 2.0. When I try to build a project, my links to Rhino.Mocks.dll are not 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 the using directive or assembly references?)

I entered my project and deleted the link to Rhino.Mocks.dll and tried 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 version specified in the project. You can change the target of the .NET Framework by clicking Properties on the Project menu, and then selecting a new target from the .NET Framework drop-down list ....

I am using "Rhino Mocks 3.5 for .NET 2.0", available at http://www.ayende.com/projects/rhino-mocks/downloads.aspx . This project works great in Dev Studio 2005 using .NET 2.0. The only thing I found was to change the goal of test projects on .NET 3.5, but I want to minimize the changes first.

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

+4
source share
2 answers

I contacted MSDN support directly to try to get a fix for this problem. They were able to reproduce this problem in Visual Studio 2008 and 2010. There are no fixes, but there is a relatively simple fix that you can make by changing your project settings.

  • Add a link to a third-party DLL (Rhino.Mocks.dll) in the project and ignore the warning by clicking Yes.
  • Click on the project link and in the properties window change the "Specific Version" of Rhino.Mocks to "True".
  • Right-click on the node project in Solution Explorer in Visual Studio 2010 and select "Unload Project."
  • Right-click on the project node and select "Change project name here."
  • After the line starting with <Reference Include="Rhino.Mocks, ..."> , add the following line: <SpecificVersion>True</SpecificVersion> .
  • Restart the project by right-clicking the node project and select Refresh.
  • Restore your project.

It worked for me.

+13
source

I just ran into this problem. After a little search, I found this post from Chris May (thanks to Chris!)

I assume that there is a conflict between the static method and the extension method called "Expect".

According to the report, I fully qualified the expects method and fixed problem # 1. Then, by changing the <SpecificVersion /> problem, I fixed other creation problems that I had.

0
source

Source: https://habr.com/ru/post/1308924/


All Articles