Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ VB.NET argument types
I have written in C++ a .NET class library which serves as a wrapper over an existing C++ API.
 
Some of the arguments are pointers (byte*) that allow the user to pass his own raw buffers as arguments.
 
All works fine as long as the library is referenced under C++ and C#. On the opposite, VB does not recognize the functions that use such arguments. They don't even appear in the Object Browser.
 
I am not really looking for a safe solution, just a workaround.
 
Any suggestion?
Posted 30-May-12 23:22pm
Edited 31-May-12 4:35am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Not really familiar with VB, but the IntPtr[^] class should allow you to interact with pointers. You might want to overload the C++ functions to accept those as well (if I understand correctly, and the C++ is C++/CLI).
 
And worse case, if you can get it to work in C#, write a C# wrapper for the C++ functions that are giving you trouble.
  Permalink  
Comments
YvesDaoust at 31-May-12 11:38am
   
Interesting proposal.
 
I am trying that, it works on a property and a method argument ! Thanks !
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

VB.Net does not have pointer types, but it does support pointers as method parameters. You didn't post your VB code, but at a guesss, your declarations are using the ByVal keyword for all parameters; try using ByRef for the pointers. That tells the Framework to treat the parameters as reference pointers, which should do what you need.
  Permalink  
Comments
YvesDaoust at 31-May-12 10:30am
   
The class library is written in C++. The buffer arguments are typed as unsigned char* (unmanaged). I am not writing the VB declarations myself, the Object Browser does.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 380
1 _Amy 255
2 Richard Deeming 250
3 Nirav Prabtani 223
4 CHill60 175
0 _Amy 110
1 Maciej Los 90
2 OriginalGriff 85
3 Mehdi Gholam 80
4 Sergey Alexandrovich Kryukov 75


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 31 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100