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
How to Turn a Datatable to a CSV
How to Intercept a Method Call in C#
How to Shut Down the Computer from C#
Serialize Class Containing Dictionary Member
How to Deserialize Xml to Object
Get a Screenshot of a Specific Application
How to Find All Combinations of Items in an Array
Remove Characters from C# String
How to Create a .Net Datetime from Iso 8601 Format
Are Arrays or Lists Passed by Default by Reference in C#
Remove Items from One List in Another
Change a Web.Config Programmatically with C# (.Net)
Javascriptserializer.Deserialize - How to Change Field Names