Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with assembly references in Visual Studio

I created a new project in visual studio proj2 and I want it to have the same assembly references as proj1, so I opened proj1.csproj and copied:

<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="system" />
<Reference Include="System.Windows" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Reference Include="System.Net" />
<Reference Include="System.Windows.Browser" />
</ItemGroup>

and pasted it into proj1.csproj. The problem is that my System.Windows assembly reference has an exclamation mark beside it, and when I try to click it, it says:

This project cannot be viewed in the object browser because it is unavailable or not yet built. Please ensure that the project is available and built.

And of course in my .cs file, it says that

The type or namespace 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?)

How do I get my assembly references to work?

like image 518
Jeffrey Greenham Avatar asked Feb 23 '11 19:02

Jeffrey Greenham


People also ask

How do I resolve a reference problem in Visual Studio?

To fix a broken project reference by correcting the reference path. In Solution Explorer, right-click your project node, and then select Properties. The Project Designer appears. If you're using Visual Basic, select the References page, and then click the Reference Paths button.


3 Answers

Go to project properties and ensure you're targeting at least Framework 3.0.

like image 176
Dan Abramov Avatar answered Sep 22 '22 16:09

Dan Abramov


System.Windows is WPF and it requires at least .NET 3.0 to be targeted by the project.

like image 39
Darin Dimitrov Avatar answered Sep 19 '22 16:09

Darin Dimitrov


Given your update comment, here is the list of assemblies in the Client Profile. You will likely need to reference the full .NET 4 Framework to use System.Windows...

Also note that System.Windows.dll does not encapsulate the System.Windows namespace; much of that namespace is spread across the Presentation*.dll assemblies. Double-check that the actual references being used by your first project appear in the second, for starters.

Also please consider posting the code from your .cs file that results in this error; it's possible a type you're using therein is actually held in a different assembly that you aren't referencing.

like image 37
Dan J Avatar answered Sep 19 '22 16:09

Dan J