Re: DLLInport from a ASP.NET web app using C#
- From: "Ravneet" <Ravneet@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 5 Jun 2005 07:11:02 -0700
Hi Scott,
A sample follows:
<Managed code snippet begins>
public string getSerial()
{
string serial = "";
try{
serial = getSerialEx(); //this line throws NullPointerException
}
catch(Exception npe){
string s = npe.StackTrace;
}
return serial;
}
</managed code snippet ends>
The serial is returned correctly in first run. Keeping the first session on,
I open another browser and browse to the app. This time the call fails,
giving an exception at the line marked above.
On the umanaged code side, the function just returns a LPSTR (tried with
LPTSTR too). Initially the function was taking a LPTSTR out parameter, and I
was using StringBuilder argument in the managed code, but this kept on
returning garbage to me. Played with Charset.XXXX too to fix that but didnt
help much, so changed the unmanaged function to accept no parameters but
return a LPSTR now.
Let me know if you need some more info.
Thanks !
"Scott Allen" wrote:
> Ok, perhaps you could post some of your code. Do you know exactly what
> line throws the null reference exception? You should be able to get
> that information from a stack trace.
>
> --
> Scott
> http://www.OdeToCode.com/blogs/scott/
>
> On Sat, 4 Jun 2005 19:47:01 -0700, "Ravneet"
> <Ravneet@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> >Scott,
> >that **can** be a very faint case. The unmanaged code works fine as far as i
> >have tested. But still to rule out this case I can do a repeated call to the
> >unmanaged code to see if it works (from unmanaged code itself).
> >As for the case from managed code, the call returns correct string value on
> >the first attempt, and fails with an exception in successive calls.
> >
> >"Scott Allen" wrote:
> >
> >> Is it possible the unmanged code is returning a NULL pointer?
> >>
> >> --
> >> Scott
> >> http://www.OdeToCode.com/blogs/scott/
> >>
> >> On Fri, 3 Jun 2005 15:31:03 -0700, "Ravneet"
> >> <Ravneet@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> >>
> >> >I am trying to do some calls to unmanaged DLL that I have written. I am doing
> >> >it in the Session_Start of my Global.asax.cs.
> >> >The first time I call a function in my DLL it returns correct string value.
> >> >The return type in unmanaged DLL is LPSTR (tried LPTSTR too). There are no
> >> >in/out params in the functions, just a return value.
> >> >The second time (and onwards) when I try to make a call to the same
> >> >function, I get an exception "Object reference not set to an object....)." I
> >> >am trying this by loading multiple page requests to the web app.
> >> >Any ideas where I should look into to resolve this one.
> >> >
> >> >Thanks
> >> >Ravneet
> >>
> >>
>
>
.
- Follow-Ups:
- Re: DLLInport from a ASP.NET web app using C#
- From: Scott Allen
- Re: DLLInport from a ASP.NET web app using C#
- References:
- DLLInport from a ASP.NET web app using C#
- From: Ravneet
- Re: DLLInport from a ASP.NET web app using C#
- From: Scott Allen
- Re: DLLInport from a ASP.NET web app using C#
- From: Ravneet
- Re: DLLInport from a ASP.NET web app using C#
- From: Scott Allen
- DLLInport from a ASP.NET web app using C#
- Prev by Date: Enabling SessionState...
- Next by Date: Re: DLLInport from a ASP.NET web app using C#
- Previous by thread: Re: DLLInport from a ASP.NET web app using C#
- Next by thread: Re: DLLInport from a ASP.NET web app using C#
- Index(es):
Relevant Pages
|