Visual Studio 2010 error: Type universe cannot resolve assembly - visual-studio-2010

I've loaded a WPF project initially created in Visual Studio 2008 into Visual Studio 2010. The conversion process goes smoothly, but on certain XAML files the VS2010 designer throws several errors related to project references, including this one:
System.Reflection.Adds.UnresolvedAssemblyException
Type universe cannot resolve assembly: GalaSoft.MvvmLight, Version=3.0.0.31869, Culture=neutral, PublicKeyToken=3e875cdb3903c512.
This assembly reference works just fine in the Expression Blend 4 designer, but not in VS2010.
I can build and run the solution successfully.
My solution targets the .Net Framework 3.5 SP1.

I can't quite tell if you're having the same problem I had or not, but I was getting that type universe error all the time with the Ninject .dll. I solved it by "Unblocking" the zip file before extracting it. I think this only affects Vista and Win 7 dev machines but it's worth a try. I posted a blog entry last week with details on the error and the solution. Scroll down to the "Foiled by a Blockhead" section.

Check which version of the MVVM Light assemblies you are referencing.
When you install the MVVM Light Toolkit binaries, you get separate WPF 3.5 and WPF 4 versions. You can find the WPF 4 assemblies (assuming default install location) in
c:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\WPF4

I found a workaround, but I'm not happy with it. If I change the target framework setting for the project from ".NET Framework 3.5" to ".NET Framework 4 Client Profile" the designer works just fine. But I'd rather not change my target framework just to get designer support!

Related

How do I fix missing NuGet references?

I'm using Visual Studio Professional 2017, version 15.6.6. A co-worker gave me a solution which he says I should be able to open and rebuild without any problems. There seems to be something wrong with either the NuGet packages and/or Framework. Co-worker will only say it must be something wrong with my computer, so I'm hoping someone here can help.
I tried right clicking on the solution and picking "Restore NuGet Packages". The references still have the yellow triangle by them. I tried to rebuild anyway and got the message "The reference assembilies for framework ".NETFramework, Version=v6.0" were not found. I looked at the project properties and saw the target framework was blank. I tried choosing .NET Framework 4.6, but that gave me multiple errors of the type "Package [name of NuGet package] is not compatible with net46(.NETFramework, Version=v4.6)." The co-worker had mentioned trying .NET Core before, so I tried downloading .NET Core 3.1 from this site: https://dotnet.microsoft.com/en-us/download/visual-studio-sdks?cid=getdotnetsdk. I installed it (including restarting my computer), but don't see .NET Core in the Target framework. Can anyone help guide me getting this solution running?
Here's an image showing the missing references (yellow triangle) on the right and the reference error message when I tried to rebuild.
Here's an image after I set the framework to 4.6 and showing the target framework choices I have available:
We can see that:
.NET 6 is supported by Visual Studio 2022 and Visual Studio 2022 for Mac (and later versions).
You can update to VS2022 and try again.

Entity Framework Build Issue in VS 2012 .NET 4.5

Is there any trick/workaround/known "gotcha" regarding Entity Framework 4 and Visual Studio 2012?
I have a project that works and compiles perfectly on my Windows 7, VS 2010, .NET 4 box. Over the weekend I setup a new machine, with Windows 8 Enterprise RTM, and VS 2012 Ultimate RTM. EF design is out of the box, using ObjectContext approach (pre EF 4.1).
I retrieved the working solution from source control, went through conversion process, and get it to build successfully in VS2012 targeting the .NET 4 Framework.
However, when I run the app or debug it, I get "unable to load metadata resource" from the first EF call. Soo ..
Step 1: Work the EF error
Ok, so I use dotPeek to see the assembly, and sure enough when built in VS2012, the EDMX metadata files are not in the assembly.
Step 2: work the missing resources problem
I set metadata processing to "copy to output" and then back to "embed" to force. Nope.
I looked around the MSBUILD files for 4.5 to see if the EntityDeploy targets looked corrupt. Nope.
I did a full repair on VS 2012 to see if something got messed up. Nope.
Set MSBUILD VS version to "11.0" to avoid the 2010 compatibility checks in the csproj. Nope.
Step 3: Delete model, try again using VS 2012 defaults
Ok, I figured I just couldnt make this work. So I deleted the model, and readded as new in VS 2012, which uses EF 5.0 from NuGet, and recontructs using the DbContext approach. Got all this lined up, fixed a few syntax things b/t EF 4.0 and 5.0 and we are building.
Still get same error, still no resources in .DLL
A collegue of mine can build this successful in VS 2012 but on Windows 7 w/o .NET 4.5 installed.
Is there a bug or known issue in .NET 4.5 or MSBUILD 4.5? gotta be missing someting simple.
Figured it out. I don't have a .resources file in this project and it appears CoreCompile in .NET 4.5 is not embedding any of the EF resources files without that being present.
Trying to research is this is expected or new behavior.

What do the red exclamation mark icons in front of references mean in VS2010?

In Visual Studio 2010 project property pages, if I select Common Properties and Framework and References for a C++ project, I can see all the references from a project.
They usually have this icon:
Sometimes, though, some references appear as this:
I tried to google it or find any documentation about it in the msdn documentation about references, but cannot find anything related to this. Does someone know about this? Thank you very much in advance!
This happens also if you had VS2010 SP1 and then install .net 4.5. They changed the handling of this in a way that causes problem in VS2010. (.net 4.5 is installed with VS2012)
I believe it is because the referenced assembly is a different version than your target application. I receive the same thing if I reference a .net 4.0 assembly from a .net 3.5 project.

Using VS 2010, can I reference a project created in VS 2005?

Here's a puzzler - something that doesn't work that I assumed would (no surprise there).
We have a library project that is referenced in a few other desktop app projects. The library project is written in VS 2005 (.NET 2.0).
My problem is that some of our apps still live in VS 2005 for the time being (for various reason). I can't seem to reference this library project in VS 2010 without it demanding that I upgrade it to .NET 4, which if I do, then breaks my ability to include it as a reference in my VS 2005 projects.
This type of thing fries my brain. Is there any way I can make this work?
Hmm, that doesn't make a lot of sense. You don't reference a 'library project', you reference the DLL that it produces. Project + Add Reference, Browse tab. There's no known problem with that, within a 95% accuracy guess, mixed mode assemblies have a few hairs.
If you actually try to load a vs2005 project into a vs2010 solution, then yes, it's going to try to convert the project file. And that turns vs2005 catatonic, it doesn't have the time machine to guess what a vs2010 project looks like. Just making a copy of the project directory solves that problem.
Can you change the .NET version back to 3.5 or 2.0 in VS.NET 2010 after it revises the project version to .NET 4.0?
Use a file reference to the built dll, rather than a project reference.
You may also find you need to add an extra bit of compatible-framework info to your manifest file to tell .net to allow your .exe to use .net 4 and .net 2 assemblies alongside each other - if it's not there you'll just get an error on startup. (Sorry, I can't remember the exact details and I'm not at my work machine right now to be able to find them - but if you have problems at runtime, the error message should lead you to the exact solution you need)
Correction: I was thinking of this 'useLegacy' startup setting, which you may need to add to your app.config if you want to use a mixture of .net 2.0 and .net 4.0 assemblies in your application:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
On option, that is a complete PITA, but should work is:
Create a new project file in 2010 that includes everything the 2005 project file has. Just call it MyProject2010.csproj or whatever.
Then, add this project to your 2010 solution.

Target Framework does not change in Visual Studio 2010

When I change the target framework of any project in Visual Studio 2010 it does not actually change the System assembly references. For example if I target v2.0 and check the properties of System and System.Data I can see that they are still both v4.0. If i change the target to v3.5, System stays at v4.0 but System.Core changes to v3.5.
Because of this I am truly not targeting anything except v4.0.
There may be something strange in your install. I just created a WPF project, keeping the default settings, thus targeting .NET 4. Then, I switched to 3.5. VS asked to reload the project and then the targeted runtime of the references was v2 (correct) and their version was 3.5 (with an error that Microsoft.CSharp and System.Xaml were missing, which is understandable).
Then, I did the same for .NET 3 and 2 and got the same results: after reloading the project, the version of the referenced DLLs had changed were it made sense (System.Data is always v2.0).
When using the CLR v2, the vshost debug helper had its name changed to something like vshost-clrv2.
I've reinstalled Visual Studio several times and it hasn't solved anything. After uninstalling there is 10.0 stuff laying all over the place leading me to believe the uninstaller is also leaving what ever is causing this issue. I'm going to have to reinstall the OS to get the issue to go away.
I also wanted to link to my earlier post because this post has more information about how I originally discovered this issue, contains a link to the Microsoft Connect bug report I opened and links to several other users experiencing the same problem: Visual Studio 2010 Can no longer build .NET v3.5

Resources