InvalidCastException of a Activator.CreateInstance object during an installation procedure

前端 未结 1 1429
萌比男神i
萌比男神i 2021-01-24 00:46

I have the following procedure

private static IMyInterface OpenInstance( 
string assemblyPath, 
string classType, 
string assemblyName, 
out AppDomain domainInst         


        
相关标签:
1条回答
  • 2021-01-24 01:04

    I solved the problem following the link proposed at this post

    stack overflow: appdomain-createinstancefromandunwrap-unable-to-cast-transparent-proxy

    The link that gives us the solution code is

    west-wind.com: Assembly Loading across appdomain

    It is really a basic thing, i was falled in the case where an assembly is loaded by an external application (in my specific case: the wow64 installer application).

    The application does not know where to find the assemblies that depend from the main assembly you are loading, so you have to write a custom assembly resolver for the current application domain (in my specific case: the wow64 installer application) in order to give the necessary loading information inside it.

    Head to the west-winf link to get the code, it works perfectly

    0 讨论(0)
提交回复
热议问题