C# 如何在运行时将程序集加载到AppDomain?

C# 如何在运行时将程序集加载到AppDomain?,c#,asp.net,visual-studio-2008,C#,Asp.net,Visual Studio 2008,我有一个ASP.NET(C#)web应用程序,它在运行时加载我的dll程序集。它在windows server 2003上一直运行良好,但现在我们转到windows server 2012,我得到了一个错误: could not load file or assembly 'C:\\Inetpub\\wwwroot\\FrontOffice\\bin\\overlay\\FrontOffice.Edi.Overlay.FORD.dll' or one of its dependencies.

我有一个ASP.NET(C#)web应用程序,它在运行时加载我的dll程序集。它在windows server 2003上一直运行良好,但现在我们转到windows server 2012,我得到了一个错误:

could not load file or assembly 'C:\\Inetpub\\wwwroot\\FrontOffice\\bin\\overlay\\FrontOffice.Edi.Overlay.FORD.dll' or one of its dependencies.
这是我的代码:

AppDomain.CurrentDomain.AppendPrivatePath(AppDomain.CurrentDomain.BaseDirectory + "bin\\overlay");

Assembly.Load("FrontOffice.Edi.Overlay");
Assembly assembly = Assembly.Load("FrontOffice.Edi.Overlay." + tp);
AppDomain.CurrentDomain.ClearPrivatePath();

Type type = assembly.GetType("FrontOffice.Edi.Overlay." + tp + ".Overlay" + tp);

Object[] args = new object[] { hdrRow, ts };

Overlay = Activator.CreateInstance(type, args);
OverlayInfo = type.GetMethod("ProcessSegment");
错误发生在
Assembly.Load(..)
上的第二行


任何帮助都将不胜感激。

如果您直接在项目中添加引用,您的代码是否有效?这样可以消除动态加载的问题。我不确定我是否从未尝试过。你是说要添加对我的dll的引用吗?我该怎么做,我该怎么称呼它?