"op.exe"
的绝对路径。此代码来自StackOverFlow上的另一个问题
我的代码:
static void Main(string[] args)
{
AppDomain app = AppDomain.CreateDomain("seco");
//my dll that i want to add to my app domain
string path = @"D:\vs projects\ConsoleApplication17\ConsoleApplication17\bin\Debug\lom.dll";
Type type = typeof(Proxy);
var asmLoaderProxy = (Proxy)app.CreateInstanceAndUnwrap(
type.Assembly.FullName,
type.FullName);
asmLoaderProxy.GetAssembly(path); //load succed here
// the exe that needs to the dll
app.ExecuteAssembly("op.exe"); // -> throw exception FileNotFoundException here
AppDomain.Unload(app);
Console.WriteLine("finished");
Console.ReadKey();
}
[Serializable]
public class Proxy
{
public Assembly GetAssembly(string assemblyPath)
{
try
{
return Assembly.LoadFrom(assemblyPath);
}
catch (Exception)
{
return null;
// throw new InvalidOperationException(ex);
}
}
}
}
我的错误是什么?注意-> dll是一类,只有一个方法可以打印“在dll中打个招呼”
和exe从类中获取实例并调用方法
感谢:)
<< ["op.exe"
的绝对路径。赞:@"D:\sample\TestDll\ConsoleApp1\bin\Debug\op.exe"
希望这可以帮助您。
"op.exe"
的绝对路径。