【发布时间】:2010-12-13 11:34:08
【问题描述】:
好的...现在这对我来说是新事物..
我的 bin 文件夹中有一个 utility.dll 文件,我正在当前的应用程序中访问它。这部分工作正常......
public partial class Reports1 : System.Web.UI.Page
{
[DllImport("Utility.dll")]
public static extern bool GetErrorString(uint lookupCode, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder buf, uint bufSize);
}
但现在我必须使用不在 bin 中的文件夹中的 .dll,而是在 C:/ 中的某个其他文件夹中使用 .dll
我尝试使用注册表键,其中我将文件夹的路径存储在注册表键中并获取该路径并将其放置在 Utility.dll 的位置,但这不起作用....我收到一条错误消息属性必须是属性参数类型的常量表达式......
public partial class Reports1 : System.Web.UI.Page
{
private static string PathName
{
get
{
using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software/Copium"))
{
return (string)registryKey.GetValue("BinDir");
}
}
}
[DllImport(PathName)]
public static extern bool GetErrorString(uint lookupCode, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder buf, uint bufSize);
大家有什么建议... 谢谢。
【问题讨论】:
标签: c# asp.net visual-studio dll