Ho un'applicazione Web che sta importando DLL dalla cartella bin.Leggere una chiave di registro
const string dllpath = "Utility.dll";
[DllImport(dllpath)]
Ora quello che voglio fare è prima di importazione le DLL da una cartella non nel progetto corrente ma ad un certo posizione diversa.
Il percorso di tale cartella è memorizzato in una chiave di registro.
Come devo fare?
Edit:
Perché non è possibile lavorare questo fuori ???
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");
non funziona qui, ma sta lavorando in caso pageload ...
Ma se faccio questa DLL importazione non funzionerà ... Come posso risolvere questo problema?