T
Tolga
Hello friends,
I need to load an unmanaged dll(which i wrote for license control)
from system32 folder and then my asp. net project will read the values
from there.(I'll write the full code to the bottom)
I get an "Object reference is not set an instance of an object
error"...This code works in my local machine , but in our remote
machine there was a problem that i told above. I can only fix the
problem by iisreset , but problem repeats again and again for a while
later... The problem is in DLL Import section... full code is here
where it broke...
i am sure u can help me to solve this problem thanx everybody...
private int CheckLicenceApply()
{
PortalSettings portalSettings =
(PortalSettings) HttpContext.Current.Items
["PortalSettings"];
int i= 0;
// error is in here when trying to load dll
i = Mydll.LicenceApply
(portalSettings.PortalTitle,GetLicense().ToString() ,
ProductGroupKey, ProductMagic,
Request.Url.Host.ToLower());
return i;
}
public string GetLicense()
{
string XMLPath = Server.MapPath(PortalSettings.ApplicationPath) ;
string XMLLicenseCode="0";
string ConfigFile = XMLPath + "\\web.config";
XmlDocument xDoc = new XmlDocument();
xDoc.Load(ConfigFile);
XmlNodeList ndLst;
ndLst = xDoc.SelectNodes("//appSettings/add");
foreach (XmlNode node in ndLst)
{
if (node.Attributes[0].Value == "LicenseNumber")
{
XMLLicenseCode = node.Attributes[1].Value ;
break;
}
}
return XMLLicenseCode;
}
public class Mydll
{
[DllImport("Licencontrol.dll" )]
public static extern ushort LicenceApply(string LicenceName,
string LicenceCode,string ProductGroupKey,
uint ProductMagic,string AModifier);
[DllImport("Licencontrol.dll")]
public static extern ushort ReturnWSCount(string LicenceName,
string LicenceCode, string ProductGroupKey,
uint ProductMagic,string AModifier);
[DllImport("Licencontrol.dll")]
public static extern ushort InfoDemo(string LicenceName,
string LicenceCode, string ProductGroupKey,
uint ProductMagic,string AModifier);
[DllImport("Licencontrol.dll")]
public static extern string ExpireControl(string LicenceName,
string LicenceCode, string ProductGroupKey,
uint ProductMagic,string AModifier);
}
I need to load an unmanaged dll(which i wrote for license control)
from system32 folder and then my asp. net project will read the values
from there.(I'll write the full code to the bottom)
I get an "Object reference is not set an instance of an object
error"...This code works in my local machine , but in our remote
machine there was a problem that i told above. I can only fix the
problem by iisreset , but problem repeats again and again for a while
later... The problem is in DLL Import section... full code is here
where it broke...
i am sure u can help me to solve this problem thanx everybody...
private int CheckLicenceApply()
{
PortalSettings portalSettings =
(PortalSettings) HttpContext.Current.Items
["PortalSettings"];
int i= 0;
// error is in here when trying to load dll
i = Mydll.LicenceApply
(portalSettings.PortalTitle,GetLicense().ToString() ,
ProductGroupKey, ProductMagic,
Request.Url.Host.ToLower());
return i;
}
public string GetLicense()
{
string XMLPath = Server.MapPath(PortalSettings.ApplicationPath) ;
string XMLLicenseCode="0";
string ConfigFile = XMLPath + "\\web.config";
XmlDocument xDoc = new XmlDocument();
xDoc.Load(ConfigFile);
XmlNodeList ndLst;
ndLst = xDoc.SelectNodes("//appSettings/add");
foreach (XmlNode node in ndLst)
{
if (node.Attributes[0].Value == "LicenseNumber")
{
XMLLicenseCode = node.Attributes[1].Value ;
break;
}
}
return XMLLicenseCode;
}
public class Mydll
{
[DllImport("Licencontrol.dll" )]
public static extern ushort LicenceApply(string LicenceName,
string LicenceCode,string ProductGroupKey,
uint ProductMagic,string AModifier);
[DllImport("Licencontrol.dll")]
public static extern ushort ReturnWSCount(string LicenceName,
string LicenceCode, string ProductGroupKey,
uint ProductMagic,string AModifier);
[DllImport("Licencontrol.dll")]
public static extern ushort InfoDemo(string LicenceName,
string LicenceCode, string ProductGroupKey,
uint ProductMagic,string AModifier);
[DllImport("Licencontrol.dll")]
public static extern string ExpireControl(string LicenceName,
string LicenceCode, string ProductGroupKey,
uint ProductMagic,string AModifier);
}