Nathan
Nathan

Reputation: 10784

Adding private member variable causes namespace to go missing in C# assembly?

This may be the most bizarre error I've ever encountered using .NET/C# - adding a private member variable of a type from an external assembly apparently causes my own namespace to go missing.

I have two projects in a solution:

UI contains a project reference to Core.

Core contains a reference to the TwainDotNet.dll version TwainDotNet-1.0-12-03-2011 from http://code.google.com/p/twaindotnet/

Inside of my Core project, adding the below code (and this is all of it!) is sufficient to cause the problem:

using TwainDotNet;

namespace Core
{
    public class TwainMonitor 
    {
        private Twain _twain; //comment this field out, and
                              //everything builds fine.
    }
}

The symptoms are that Core builds fine. But UI complains that:

The type or namespace name 'Core' could not be found (are you missing 
a using directive or an assembly reference?)    

Why on earth would adding a private member variable of a type from an external assembly cause my own namespace to go missing in action?

Upvotes: 0

Views: 222

Answers (1)

caesay
caesay

Reputation: 17233

I can not be certain that this is infact your issue, but I have experienced these symptoms before when referencing things targetting the Full framework profile from project targetting a Client framework profile.

What I would try, is making sure that you are targetting the .Net 4 Full profile and NOT the client profile in your project properties for both of your projects.

Upvotes: 3

Related Questions