Click here to Skip to main content
11,802,442 members (69,840 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C++ VB VB.NET
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
Rate this: bad
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.
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
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.
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 KrunalRohit 366
1 OriginalGriff 365
2 F-ES Sitecore 295
3 Afzaal Ahmad Zeeshan 230
4 CPallini 230
0 OriginalGriff 2,950
1 Maciej Los 1,910
2 KrunalRohit 1,862
3 CPallini 1,645
4 Richard MacCutchan 1,157

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 31 May 2012
Copyright © CodeProject, 1999-2015
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