PDA

View Full Version : System.AccessViolationException on Windows 7



cummins
01-14-2010, 03:27 PM
After I checked out the license for the feature/version, then processed both code1 and code2 on Windows XP. Both of them worked fine on Windows XP. But The code1 threw an AccessViolationException on Windows 7.
(Attempted to read or write protected memory. This is often an indication that other memory is corrupt) Do you have any ideas on this?


code1
CONFIG *conf = NULL;
conf = lc_auth_data(lm_job, FeatureName);
char *vendorString = conf->lc_vendor_def;

code2
CONFIG *conf = NULL;
conf = lc_auth_data(lm_job, FeatureName);
long days = lc_expire_days(lm_job, conf);


Thanks,

cummins
01-18-2010, 11:05 AM
My demo application is a C# windows appliation, and it calls c++ functions to
get the data. Both demo1 and demo2 works fine on Windows xp, but the demo2 crashes on Windows 7 by throwing an error (System.AccessViolationException).

As you can see the function "demo1",
using conf->lc_vendor_def do not crash on Windows 7, but it just crashes when
I return the "conf->lc_vendor_def". Any suggestions to make it work on Windows 7?


C#
[DllImport("demo.dll", CharSet = CharSet.Ansi)]
public static extern string demo1();

[DllImport("demo.dll", CharSet = CharSet.Ansi)]
public static extern string demo2();

C++
char* demo1()
{
initialize the job...
Checkout the license...
...
...

CONFIG *conf = NULL;
conf = lc_auth_data(lm_job, FeatureName);
char* vendorString = conf->lc_vendor_def;
char* test = "LM_CHAR_PTR";
return test;
}

char* demo2()
{
initialize the job...
Checkout the license...
...
...

CONFIG *conf = NULL;
conf = lc_auth_data(lm_job, FeatureName);
char* vendorString = conf->lc_vendor_def;
return vendorString;
}