Leia uma chave do registro
Eu tenho um aplicativo da web que está importando DLLs da pasta bin.
const string dllpath = "Utility.dll";
[DllImport(dllpath)]
Agora o que eu quero fazer é primeiro importar as DLLs de uma pasta que não esteja no projeto atual, mas em algum local diferente.
O caminho dessa pasta é armazenado em uma chave do Registro.
Como devo fazer isso?
Editar:
Por que não posso resolver isso?
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");
não está funcionando aqui, mas está trabalhando no evento pageload ...
Mas se eu fizer isso, a importação da DLL não funcionará ... Como posso consertar isso?