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?
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.
- Add the reference to the third-party DLL (Rhino.Mocks.dll) into the project and ignore the warning by clicking "Yes".
- Click on the project reference and in the property window modify the "Specific Version" of Rhino.Mocks to "True".
- Right click on the project node in the solution explorer in Visual Studio 2010 and select "Unload Project".
- Right click on the project node and select "Edit Your Project Name Here".
- After the line starting with
<Reference Include="Rhino.Mocks, ...">
, add the following line:<SpecificVersion>True</SpecificVersion>
. - Reload the project by right clicking the project node and select "Reload".
- Rebuild your project.
This worked for me.
I just ran into this issue as well. After a bit of searching I found this post from Chris May (Thanks Chris!)
I guess there's a conflict between the static method and the extension method both named "Expect".
As per the post, I fully qualified the expects method and it fixed problem #1. Then changing the <SpecificVersion />
issue, fixed the other build issues I was having.
来源:https://stackoverflow.com/questions/2775538/unable-to-add-rhino-mocks-3-5-to-a-net-2-0-project-in-visual-studio-2010