0

This question is an extension of a another SO question here: How to use a Class from one C# project with another C# project

The most popular answer describes the process to add a reference to another project in the same solution. On following the steps I am able to get Microsoft's Intellisense suggestions for the changes in the other project, however on compiling I face the following error:

Error 112 'OtherNamespace.ClassObject' does not contain a definition for 'NewProperty' and no extension method 'NewProperty' accepting a first argument of type 'OtherNamespace.ClassObject' could be found (are you missing a using directive or an assembly reference?)

Any idea what is causing the conflict?

EDIT: Sample code:

public class ClassObject
{
    public virtual int ExistingProperty
    {
        get;
        set;
    }

    public virtual int NewProperty
    {
        get;
        set;
    }

    public ClassObject()
    {
    }
}

I think it might be due to a different reference being used during compile than at the time of code editing. Because there are some weird issues like, if I change an existing property name all the references to it show errors at compile but the new property just doesn't work.

EDIT2: Adding pictures -

Before Compile:

enter image description here

After compile:

enter image description here

tbl_Scaling_Line is ObjectClass, SuratJalanCheck is NewProperty

Community
  • 1
  • 1
Birla
  • 1,170
  • 11
  • 30

1 Answers1

0

The problem, as apparent, was due to incorrect references to an older version of the DLL (result of the second project) even though the inter-project references had been set up correctly.

Previously, due to another compile time issue, I had set the build output directory of all projects to the same (as the main project which was using all the DLLs). As it turns out, this was the culprit and was fixed easily by returning each project to it's own build directory and letting the inter-project references do their job.

PS. This question and answer may not be relevant to everyone but I feel it still does provide value to the SO community.

Birla
  • 1,170
  • 11
  • 30