Assembly.CreateInstance returns null

I work with assembly.CreateInstance, and it returns null, while it was perfect, using it with another project with the same assembly file DLL. Can you suggest reasons when and why it returns null? this is urgent?

Edit

The type I'm looking for has a default constructor, but it implements a different interface, for example. Project1 has an interface A and makes a DLL that contains a new type, let it be typeB that implements A. Project2 has the same interface A and uses the "CreateInstance" method to search for typeB, but here does CreateInstance return null, any suggestions?

+3
source share
7 answers

, , 1 CreateInstance null ( Nullable<T>) (ProxyAttribute, ), null.

:

  • ( , )
  • as, (, , , )

; , , , ( ) .

+5

null, . . MSDN.

, .

+2

, Assembly.CreateInstance null, , , . , .NET , , .

Assembly.CreateInstance , , , .

.

+1

, ( ). , , , ..

0

You can try to fix the problem using the Assembly Binding Log Viewer (fuslogvw) to try and find out if there are any failures.

0
source

A more reliable way to do this could be to use Activator.CreateInstanceand pass this type directly.

0
source

Source: https://habr.com/ru/post/1751990/


All Articles