The Type Is Defined in an Assembly That Is Not Referenced, How to Find the Cause

The type is defined in an assembly that is not referenced, how to find the cause?

When you get this error it isn't always obvious what is going on, but as the error says - you are missing a reference. Take the following line of code as an example:

MyObjectType a = new MyObjectType("parameter");

It looks simple enough and you probably have referenced "MyObjectType" correctly. But lets say one of the overloads for the "MyObjectType" constructor takes a type that you don't have referenced. For example there is an overload defined as:

public MyObjectType(TypeFromOtherAssembly parameter) {
// ... normal constructor code ...
}

That is at least one case where you will get this error. So, look for this type of pattern where you have referenced the type but not all the types of the properties or method parameters that are possible for functions being called on that type.

Hopefully this at least gets you going in the right direction!

The type 'xxx' is defined in an assembly that is not referenced

So after putting in a few more hours with my Architect, we found the issue. Our developers had multiple copies of the same dll buried in various folders in our Source Control. One of the projects was referencing the incorrect .dll.

After fixing the references and removing the extra uneeded .dlls, the error is gone and our builds are finally working! :)

Compile ERROR: The type is defined in an assembly that is not referenced

The most simple solution is add reference to dal from the UI project.

The type 'Nullable ' is defined in an assembly that is not referenced

I'm not sure why, by I had to manually add a reference to the netstandard library in the web.config file of the MVC application:

      <compilation debug="true" targetFramework="4.7.2">
<assemblies>
<add assembly="netstandard, Version=2.0.3.0, Culture=neutral,
PublicKeyToken=cc7b13ffcd2ddd51"/>
</assemblies>
</compilation>


Related Topics



Leave a reply



Submit