DllImport Error

Posted: 08-31-2004, 01:14 PM
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);

}
Reply With Quote

Responses to "DllImport Error"

Tolga
Guest
Posts: n/a
 
Re: DllImport Error
Posted: 09-08-2004, 06:42 AM
Hi folks!
if u couldnt solve the problem or maybe i couldnt explain it :)...But
it is not a shame to reply anything about it...

tetci@pyazilim.com (Tolga) wrote in message news:<bbcc45b3.0408310514.77f9470d@posting.google. com>...
> 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);
>
> }
Reply With Quote
 
LinkBack Thread Tools Search this Thread Display Modes
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Message "A drawing error ocurrred which is probably due to an out-of-memory condition. Try qu wendy_matarazzo@adobeforums.com Adobe Acrobat Macintosh 2 05-11-2005 06:12 PM
Error 403 Failed to read heders Error for long-runningCFMAIL and CFINDEX command Funke Macromedia ColdFusion 0 03-29-2005 08:49 PM
Error Creating Control: Parser Error DocHeader does not have a property named 'cc3:MyItems' ~~~ .NET Ed ~~~ ASP.NET Building Controls 0 11-10-2004 04:24 PM
dllimport call in aspnet application makes the application hangs sonyram ASP.NET Security 0 08-09-2004 11:33 AM
DllImport and WebMethod and STAThread Alfred B. Thordarson ASP.NET Web Services 1 12-02-2003 05:01 PM