Namespace issue upgrading to Visual Studio 2012 - visual-studio-2012

I am upgrading a solution to Visual Studio 2012 (and 2013, but that's a side issue)
I am encountering the following error (many times) when compiling the test projects:
Error 345 The type 'System.Action'
exists in both 'c:\Users\neil\Documents\Visual Studio 2013\Referenced
Assemblies\Third Party Dlls\Moq\Moq.dll' and 'c:\Program Files
(x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Core.dll' .....
We are using Moq 4.0000, and the solution is using .Net 3.5 in all projects. It looks like the .Net framework now has a System.Func<....> implementation (previously only defined in Moq?) Oddly we haven't had this problem with VS2008, also using .Net 3.5.
Does anyone know how to resolve this?

Action and Func with many parameters were added only with .NET 4.0. Was it initially a .NET 2.0 project? In that case, you can try to remove the System.Core.dll from the references and try to see if the project compiles. Despite the name, it is unessential and was added only with .NET 3.5. The cleanest solution would be to upadate your library, Moq, with an updated one that fixes the clash in .NET 4.0. If that is not an option, follow Pratick advice to use assembly extern aliases.

Related

The type or namespace XXX could not be found(are you missing a using directive or an assembly reference?

I'm working on a project that targeting .NET 4.0 Framework. I added a reference to a third party dll file and call its methods in my code and have no error. But when I build the project it gave me The type or namespace error with blue underline on the methods of the dll. Using .NET Reflector I checked dll .NET Version of mscorlib.dll it is 4.0.0.0. My application Target .NET Version is 4.0 then Why I'm getting this error.
What I have done.
Remove all references to the library. Clean the project. Restart the project. again add the references. Not good in English please guide me. Stuck in it last 4 days.
Check if you have privileges to access the dll file. Then try running Visual Studio as administrator. If it does not help try to build the solution as 64x/86x not Any CPU.

Visual Studio C++ 2010 Error

I have a problem, I've installed Visual Studio C++ 2010 Express and whenever I make a new project then run the debug to test it it gives me the following error:
Error 2 error C1107: could not find assembly 'mscorlib.dll': please specify the assembly search path using /AI or by setting the LIBPATH environment variable c:\Users\Cretu\documents\visual studio 2010\Projects\test2\test2\stdafx.cpp 1
Leaving this aside, when I close Visual C++ and open it and then try to open my project it gives me this error:
The Visual C++ project "test2" is targeting ".NETFramework, Version=v4.0", which is not installed on this machine. You must download this framework in order to open...
But I already have installed the following .NETFrameworks on my machine (Control Panel -> Installed Programs, that's where i got their name):
Microsoft .NET Framework 1.1,
Microsoft .NET Framework 4 Client Profile,
Microsoft .NET Framework 4 Extended.
Can somebody please explain why this is happening? I've already re-installed .NET Framework 4.0 and rebooted my PC but I still get this error. Please help. Thanks in advance for taking the time to read my question.
You are missing quite a few packages. Im guessing you tried to install .NET manually - well that never works, you need to use an official installer, heres my list of working .NET 4 and 4.5, im guessing the "Chart Controls" are actually unnecessary :

The type or namespace could not be found

I'm currently trying to convert a WiX 3.5 custom actions project in Visual Studio 2008 to WiX 3.7 and Visual Studio 2012 and I'm getting the following exception:
The type or namespace name 'MyNamespace' could not be found (are you
missing a using directive or an assembly reference?)
The dll is definitely referenced and Visual Studio 2012 has no problem seeing the namespace. Everything under the namespace even pops up in Intellisense, but when I build it I'm getting this exception.
Anyone have an idea of what's going on here?
Additional Info:
The namespace I'm referencing is a .Net 2.0 library and the custom actions project is a .Net 2.0 project.
EDIT:
After further investigation, I'm getting this warning, which I'm guessing is the root of the problem:
The primary reference "MyNamespace, Version=8.5.1.20, Culture=neutral,
PublicKeyToken=f593502af6ee46ae, processorArchitecture=MSIL" could not
be resolved because it has an indirect dependency on the .NET
Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0"
than the version "2.0.0.0" in the current target framework.
Why is it trying to use mscorelib 4.0 when this is a 2.0 project?
So it turned out that the dll being reference, while compiled to target the .Net 2.0 framework, was being compiled with the 4.0 compiler. Switching the project to compile with the 3.5 compiler solved the problem.
This may be completely unrelated but I had a similar issue yesterday. I had accidentally copied a class file (.cs) from one solution into another solution. Clearly, I hadn't added the references to the other solutions.
In our case, while the referenced dll was targeting .Net 4.0, it had its own reference to a .Net 4.5.2 dll. The referenced 4.0 framework target led us to believe that 4.5 or 4.5.1 were sufficient to handle things, but they weren't—the referencing project had to be 4.5.2 to handle the dll and all its references.
This was clearly an error on the part of the dll maker.

Enable-Migrations fails for EF5

I am using .NET 4.0 and Visual Studio 2010 (which I will eventually upgrade, but not quite yet). I ungraded from EF 4.1 to EF 5 via NuGet and ran Enable-Migrations (via the Package Manager Console) but got this error
No context type was found in the assembly 'UI'.
I Googled around and found this SO post.
The scenario described by the poster is slightly different as he is using VS 2012 and .NET 4.5. Either way I'm not sure if this will solve my issues. Do I need to be using VS 2012 and .NET 4.5 to use Migrations? How do I solve my issue?
In order to NuGet commands work correctly, you should specify the default project:
So you should change the dropdown value from UI to Model (I presume). Actions should not depend on VS version.

Can't open NerdDinner project in vs2008

NerdDinner.csproj won't load in vs2008 sp1 with .net 3.5 sp1. Am I not up-to-date on these tools or something? It complains this project type not supported on this installation.
Do you have the ASP.NET MVC Framework installed? If not, you need it. NerdDinner is an example of an MVC Framework project, and you won't be able to open it or run it without the ASP.NET MVC Framework installed.
You can find the appropriate installation information at http://www.asp.net or more specifically http://www.asp.net/mvc
In my I had to change the value of the "ProjectTypeGuids" in the project file. I copied them from another MVC project that I had created with my version of VS 2008.
This is the post that gave me the answer:
http://www.stuffthatjustworks.com/How+To+Fix+Xcsproj+Cannot+Be+Opened+The+Project+Type+Is+Not+Supported+By+This+Installation.aspx
In my case...it was the wrong version of the framework.
I just copied the from another asp.net mvc project I had made. (then you probably have to fix up the references, which is trivial with resharper :-) )

Resources