我有一个正在从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导入将无法正常工作...... 我怎样才能解决这个问题?