PC Review


Reply
Thread Tools Rate Thread

Another P Invoke Question

 
 
ba.hons
Guest
Posts: n/a
 
      26th Apr 2007
Hello,

I have another method in a DLL which i am trying to use and i keep
getting null reference exception can anyone shed any light on this.

int GetConnectedControllers(char * controllers , int controllersSize)

which should return buffer of chars which indicates readers connected.
which i imagine looks like

"reader1,reader2 etc"

my decleration for this method in c# is

[DllImport("MyDll.dll", SetLastError = true, CharSet = CharSet.Ansi)]
static extern int GetConnectedControllers(out
System.Text.StringBuilder test5,
int ControllersSize);

then i call in my application

int x=Form1.GetConnectedControllers(out test5, 1000);

then test5 seems to go out of scope.

I am completely lost on this.

any help appreciated!

Adam

 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      26th Apr 2007
>[DllImport("MyDll.dll", SetLastError = true, CharSet = CharSet.Ansi)]
> static extern int GetConnectedControllers(out System.Text.StringBuilder test5,

^^^

Remove the out modifier.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
P Invoke Question ba.hons Microsoft C# .NET 8 27th Apr 2007 01:32 PM
P Invoke Question ba.hons Microsoft C# .NET 0 26th Apr 2007 02:46 PM
P Invoke Question ba.hons Microsoft C# .NET 0 26th Apr 2007 02:46 PM
P Invoke Question ba.hons Microsoft C# .NET 0 26th Apr 2007 02:29 PM
Question for invoke Microsoft C# .NET 1 14th Sep 2006 02:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:24 AM.