Type is not loaded. Please make sure you call LoadAssembly First Errors

This is a common error that occurs when a .NET type signature cannot be matched to an already loaded type. This error can often be misleading, because of the LoadAssembly reference in the message which seems to suggest a missing assembly.

Common Causes

Mismatched Type Signatures

If you are using CreateInstance() or InvokeMethod() or Get/SetProperty() and you are specifying an invalid or misspelled type name in the signature you will get this error. For example if you do:

loBridge.InvokeStaticMethod("System.XML.XmlReader", "Create", loReader)

Where the correct signature is:

loBridge.InvokeStaticMethod("System.Xml.XmlReader", "Create", loReader)

(note the .Xml vs the incorrect .XML in the typename) this error is thrown. In that case fixing the typo is all you need.

Invalid Parameter Type

If you're calling methods using InvokeMethod or creating objects with CreateInstance that are using parameters and the parameter types don't match an existing signature you often get this error. This depends on the signature - if it can be matched but the parameter values are invalid the calls will throw. But if the signature cannot not be matched to any overload of the method or constructor call, you can get the above error.

Actually missing Assembly References

In rare occasions the error actually correctly reflects the situation where you are missing a dependent assembly.

If you have are calling a component that has dependencies that live in other assemblies that may not have been loaded yet, you can also get this error. Because Reflection does not automatically load all dependencies or if a dependency is not available in the same folder as the host assembly you may also see this error.


Because of these various ways this error can manifest, it's sometimes difficult to track down the exact cause of the problem. But hopefully, these notes can help narrow down the problem to a few scenarios.

© West Wind Technologies, 2020 • Updated: 08/14/19
Comment or report problem with topic