HighTechTalks DotNet Forums  

Problem calling unmanaged C dll in vb.net

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss Problem calling unmanaged C dll in vb.net in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
JimmyD
 
Posts: n/a

Default Problem calling unmanaged C dll in vb.net - 12-29-2005 , 10:05 AM






Hello,
I'm having problems calling a function in an unmanaged C dll using
VB.net. The program runs, then tries to execute the following function,
and just dies, no error message, even when I use a try/catch. I've used
the following two methods:

<DllImport("myDLL.DLL")> _
Public Shared Function GetSiteKeyAddV2(ByVal easyLicense As Integer,
ByVal addOn As Integer, ByVal userpassword As String, ByVal site_code
As String, ByVal level As Integer, ByVal options As Integer, ByVal
restriction_type As Object, ByVal num_days_or_runs As Object, ByVal
license_type As Object, ByVal copies As Integer, ByVal site_key as
string) As Integer
End Function

And

Private Declare Function GetSiteKeyAddV2 Lib "myDLL.DLL" ByVal
easyLicense As Integer, ByVal addOn As Integer, ByVal userpassword As
String, ByVal site_code As String, ByVal level As Integer, ByVal
options As Integer, ByVal restriction_type As Object, ByVal
num_days_or_runs As Object, ByVal license_type As Object, ByVal copies
As Integer, ByVal site_key as string) As Integer

Here's the C function definition:
int FUNCTYPE GetSiteKeyAddV2(int easyLicense, int addOn, char
*userpassword, char *site_code,
unsigned long level, unsigned long options,
unsigned restriction_type, unsigned num_days_or_runs,
unsigned license_type, int copies,
char *site_key);

Some things I'm concerned about are the unsigned c data types (which
I've mapped to vb.net object data types, though I don't know if this is
correct), and the fact that site_key returns a string.

Any help would be much appreciated, I'm very new to the interop stuff.

Thanks -
J


Reply With Quote
  #2  
Old   
Kyle Burmark
 
Posts: n/a

Default RE: Problem calling unmanaged C dll in vb.net - 01-03-2006 , 04:32 PM






I don't think there is a UIntegerin vb.net is there? If so try that for the
unsigned c++ params. And also try using a StringBuilder for the strings. And
allocate there space to 260. Do a combo of those things and see what happens.

"JimmyD" wrote:

Quote:
Hello,
I'm having problems calling a function in an unmanaged C dll using
VB.net. The program runs, then tries to execute the following function,
and just dies, no error message, even when I use a try/catch. I've used
the following two methods:

DllImport("myDLL.DLL")> _
Public Shared Function GetSiteKeyAddV2(ByVal easyLicense As Integer,
ByVal addOn As Integer, ByVal userpassword As String, ByVal site_code
As String, ByVal level As Integer, ByVal options As Integer, ByVal
restriction_type As Object, ByVal num_days_or_runs As Object, ByVal
license_type As Object, ByVal copies As Integer, ByVal site_key as
string) As Integer
End Function

And

Private Declare Function GetSiteKeyAddV2 Lib "myDLL.DLL" ByVal
easyLicense As Integer, ByVal addOn As Integer, ByVal userpassword As
String, ByVal site_code As String, ByVal level As Integer, ByVal
options As Integer, ByVal restriction_type As Object, ByVal
num_days_or_runs As Object, ByVal license_type As Object, ByVal copies
As Integer, ByVal site_key as string) As Integer

Here's the C function definition:
int FUNCTYPE GetSiteKeyAddV2(int easyLicense, int addOn, char
*userpassword, char *site_code,
unsigned long level, unsigned long options,
unsigned restriction_type, unsigned num_days_or_runs,
unsigned license_type, int copies,
char *site_key);

Some things I'm concerned about are the unsigned c data types (which
I've mapped to vb.net object data types, though I don't know if this is
correct), and the fact that site_key returns a string.

Any help would be much appreciated, I'm very new to the interop stuff.

Thanks -
J



Reply With Quote
  #3  
Old   
JimmyD
 
Posts: n/a

Default Re: Problem calling unmanaged C dll in vb.net - 01-04-2006 , 10:53 AM



Thanks, Kyle.

There is UInt16-64 in VB.net, but I never got that far. I ended up just
creating an ActiveX DLL and interfaced with the unmanaged C DLL that
way, which worked great. But thanks for your input.

Jim

Kyle Burmark wrote:
Quote:
I don't think there is a UIntegerin vb.net is there? If so try that for the
unsigned c++ params. And also try using a StringBuilder for the strings. And
allocate there space to 260. Do a combo of those things and see what happens.

"JimmyD" wrote:

Hello,
I'm having problems calling a function in an unmanaged C dll using
VB.net. The program runs, then tries to execute the following function,
and just dies, no error message, even when I use a try/catch. I've used
the following two methods:

DllImport("myDLL.DLL")> _
Public Shared Function GetSiteKeyAddV2(ByVal easyLicense As Integer,
ByVal addOn As Integer, ByVal userpassword As String, ByVal site_code
As String, ByVal level As Integer, ByVal options As Integer, ByVal
restriction_type As Object, ByVal num_days_or_runs As Object, ByVal
license_type As Object, ByVal copies As Integer, ByVal site_key as
string) As Integer
End Function

And

Private Declare Function GetSiteKeyAddV2 Lib "myDLL.DLL" ByVal
easyLicense As Integer, ByVal addOn As Integer, ByVal userpassword As
String, ByVal site_code As String, ByVal level As Integer, ByVal
options As Integer, ByVal restriction_type As Object, ByVal
num_days_or_runs As Object, ByVal license_type As Object, ByVal copies
As Integer, ByVal site_key as string) As Integer

Here's the C function definition:
int FUNCTYPE GetSiteKeyAddV2(int easyLicense, int addOn, char
*userpassword, char *site_code,
unsigned long level, unsigned long options,
unsigned restriction_type, unsigned num_days_or_runs,
unsigned license_type, int copies,
char *site_key);

Some things I'm concerned about are the unsigned c data types (which
I've mapped to vb.net object data types, though I don't know if this is
correct), and the fact that site_key returns a string.

Any help would be much appreciated, I'm very new to the interop stuff.

Thanks -
J




Reply With Quote
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.