Domanda

I have a VS2010 solution with a "hello world" WPF Application and a Class Library project. In my class library, I have defined a class in a namespace called ReportImageMerge.Core. I have that project referenced by my WPF app project, but when I run the build, I get several errors. The parent error of the rest which are references to objects within my custom namespace is this:

Error   3   The type or namespace name 'Core' does not exist
in the namespace 'ReportImageMerge' (are you missing an assembly reference?)

Strangely, if I remove the project reference and add it back, my errors disappear along with all red squigglies. Only when I rebuild do I see the errors anew. The namespace and class are defined as below:

namespace ReportImageMerge.Core.Business
{
    public class ReportHelper
    {
        ...
    }
}

The class and name are referenced as below:

using ReportImageMerge.Core.Business;

namespace ReportImageMerge.Reporter
{
    public partial class MainWindow : Window
    {
        public ReportHelper ReportHelper { get; set; }
        ...
    }
}

The only information I have found related to my issue seem to be centered around target framework. The WPF Application is set to ".NET Framework 4 Client Profile" by default, and the class library is set to ".NET Framework 4". Most advice for people with Silverlight projects referencing class libraries was to use a Silverlight-specific class library. There doesn't appear to be the same for WPF app projects.

I have seen advice given to change the target framework of the referencing project to the same as the referenced app, but I get an unspecified runtime error if I do that.

How can I get my class library namespace to be recognized after building my solution?

È stato utile?

Soluzione

You cannot reference the full framework from the client framework.

Change either of the projects so that they both target the same framework.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top