_AppDomain::CreateInstance returns COR_E_TARGETINVOCATION

Hello,

My unmanaged C++ CLR host returns COR_E_TARGETINVOCATION when it attempts to create an instance of an assembly which refers to an external assembly located in a different folder. If I copy the external assembly locally then the error goes away. The external assembly has been created with TLBIMP.EXE.

Any idea what could be the problem

Thanks for yor help.

-mab



Answer this question

_AppDomain::CreateInstance returns COR_E_TARGETINVOCATION

  • ShaaaM

    From MSDN:

    Referenced assemblies outside the application's root directory must have strong names and must either be installed in the global assembly cache or specified using the <codeBase> element.

    You could try to use LoadFrom, but this can get tricky. See http://www.gotdotnet.com/team/clr/LoadFromIsolation.aspx


  • ejamashu

    Ok thanks for your help.

    -mab


  • Bosse G

    Use fuslogvw.exe to see what happens. If that assembly is not in the app path, how should the CLR find it
  • NickNotYet

    So I' using a config file for the app domain:

    <configuration>
    <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
    <assemblyIdentity name="xsiom"
    publicKeyToken=""
    culture="neutral" />
    <codeBase version="1.0.0.0"
    href="C:\Application\bin\xsiom.dll"/>
    </dependentAssembly>
    </assemblyBinding>
    </runtime>
    </configuration>

    ...but the problem remains:

    ERR: The private assembly was located outside of appbase. Source Url = file:///C:/Application/bin/xsiom.dll.


    Is it possible to specify the location of an non-strong-named assembly outside the app base

    -mab


  • Lakshman

    I've added the path to the assembly in the domain app setup with the PrivateBinPath prop but now I get this error instead.

    WRN: Not probing location file:///s:/Rayflex/Debug/bin/xsiom.DLL, because the location falls outside of the appbase.

    Is there a way to fix that

    thanks

    -mab


  • JayaC

    That's the HRESULT that generates TargetInvocationException. That exception is poorly documented, to put it mildly. This KB article might be helpful...


  • _AppDomain::CreateInstance returns COR_E_TARGETINVOCATION