我有一个从 bin 文件夹中导入 DLL 的 Web 应用程序。
const string dllpath = "Utility.dll";
[DllImport(dllpath)]
现在我要做的是首先从不在当前项目中而是在某个不同位置的文件夹中导入 DLL。
该文件夹的路径存储在注册表项中。
我该怎么做?
编辑:
为什么我不能解决这个问题???
public partial class Reports1 : System.Web.UI.Page
{
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software\xyz");
string pathName = (string)registryKey.GetValue("BinDir");
const string dllpath = pathName;
[DllImport(dllpath)]
public static extern bool GetErrorString(uint lookupCode, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder buf, uint bufSize);
protected void Page_Load(object sender, EventArgs e)
{
string pathName = (string)registryKey.GetValue("BinDir");
在这里不工作,但在页面加载事件中工作......
但是,如果我这样做 DLL 导入将无法正常工作......我该如何解决这个问题?