Problem with assembly references in Visual Studio

26,512

Solution 1

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

Solution 2

Yeah, it sounds like there is a problem with the Framework version your project is targeting. Try setting proj2 to have the same target framework as proj1.

You can do this by right-clicking the project in the Solution Explorer in Visual Studio, selecting Properties, and viewing the Target Framework dropdown in the Application tab.

Alternatively, you can open up the .csproj files and ensure that they have matching TargetFrameworkVersion tags. This tag is typically located within a ProperyGroup near the top of the file.

Solution 3

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

Solution 4

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.

Share:
26,512
Jeffrey Greenham
Author by

Jeffrey Greenham

Pythonic pedant.

Updated on October 17, 2020

Comments

  • Jeffrey Greenham
    Jeffrey Greenham over 3 years

    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?