Search code examples
c#appdomain

AppDomain Assembly Not Found When Executable File Name Changes


I was try to load a byte array into a different domain. I tried using the solution provided by caesay in AppDomain Assembly not found when loaded from byte array and the loading works.

However, when I change the file name to a different name from the one I build, I encounter "Could not load file or assembly". The error was caught at the CreateInstanceAndUnwrap.

Anyone knows how to resolve this issue where my executable name is different from the assembly name?

Details:
Code base: Using caesay's reply
Program Assembly and executable name: CreateDomainTest
New executable name: test.exe
Error: Could not load file or assembly 'CreateDomainTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or of its dependencies. The system cannot find the specific file.

Thanks in advance.


Solution

  • I have manage to resolve the issue.

    Instead of using CreateInstanceAndUnwrap, I use CreateInstanceFrom and pass in the assembly path. After which, I unwraps it.