473,770 Members | 7,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling VC++ From (C# | VB) .NET

Yesterday I posted the message below to microsoft.publi c.dotnet.langua ges.vb
and microsoft.publi c.vc.language. The two replies are also posted.

I need to write some ISO C++ functions, more information below. Is C# a
better language to use than VB.NET for calling these C++ functions? If so I
would appreciate some links on calling C++ from C#.

Thanks!

-- Mark
============= Calling VC++ From VB.NET ============

I have been searching google, google groups and MSDN but haven't found any
simple examples yet. Suggestions and/or URLs would be appreciated!

I need to write some ISO C++ functions to verify data streams. (It is
expected these will also eventually be run in Linux.) The application also
needs a management GUI. For Windows I plan to write the GUI in VB .NET
2003.

How do I call C++ from VB.NET? I'm trying to start small:

bool AlwaysReturnsTr ue(void)

and work up to:

bool StreamIsValid(I N ByteArray, IN Length, OUT ErrorMessage, OUT ErrorByte)
I'm uncertain about memory issues: Who allocates, etc. I'm also unclear
about internalization of the error messages.

Thanks.

-- Mark

============== bonj reply =============
I have been searching google, google groups and MSDN but haven't found any
simple examples yet. Suggestions and/or URLs would be appreciated!

I need to write some ISO C++ functions to verify data streams. (It is
expected these will also eventually be run in Linux.) The application
also
needs a management GUI. For Windows I plan to write the GUI in VB .NET
2003.
Why don't you write it in java, then you won't even have to write a
different one for linux.

How do I call C++ from VB.NET? I'm trying to start small:
Use Declare.

bool AlwaysReturnsTr ue(void)

and work up to:

bool StreamIsValid(I N ByteArray, IN Length, OUT ErrorMessage, OUT
ErrorByte)
Read up on System.InteropS ervices.Marshal et al.


I'm uncertain about memory issues: Who allocates, etc. I'm also unclear
about internalization of the error messages.


Caller allocates. .NET also has some 'magic' classes such as
StringBuilder that can be 'passed to be filled' without having a maximum
size pre-specified - this is done by the GC.

=============== Crouchie1998 reply =============== =

I wrote a simple C++ DLL & called it from VB.NET. Here's the sample:

http://www.gotdotnet.com/Community/U...2-ca46ef086c12

I hope this will help
Nov 16 '05 #1
1 1788
I found a PInvoke example which looks to be what I need. Where can I find
information on parameter types, allocating memory, etc?

Thanks.

-- Mark

Mark Jerde wrote:
Yesterday I posted the message below to
microsoft.publi c.dotnet.langua ges.vb and
microsoft.publi c.vc.language. The two replies are also posted.
I need to write some ISO C++ functions, more information below. Is
C# a better language to use than VB.NET for calling these C++
functions? If so I would appreciate some links on calling C++ from
C#.
Thanks!

-- Mark
============= Calling VC++ From VB.NET ============

I have been searching google, google groups and MSDN but haven't
found any simple examples yet. Suggestions and/or URLs would be
appreciated!
I need to write some ISO C++ functions to verify data streams. (It is
expected these will also eventually be run in Linux.) The
application also needs a management GUI. For Windows I plan to write
the GUI in VB .NET 2003.

How do I call C++ from VB.NET? I'm trying to start small:

bool AlwaysReturnsTr ue(void)

and work up to:

bool StreamIsValid(I N ByteArray, IN Length, OUT ErrorMessage, OUT
ErrorByte)

I'm uncertain about memory issues: Who allocates, etc. I'm also
unclear about internalization of the error messages.

Thanks.

-- Mark

============== bonj reply =============
I have been searching google, google groups and MSDN but haven't
found any simple examples yet. Suggestions and/or URLs would be
appreciated! I need to write some ISO C++ functions to verify data
streams. (It
is expected these will also eventually be run in Linux.) The
application also
needs a management GUI. For Windows I plan to write the GUI in VB
.NET 2003.


Why don't you write it in java, then you won't even have to write a
different one for linux.

How do I call C++ from VB.NET? I'm trying to start small:


Use Declare.

bool AlwaysReturnsTr ue(void)

and work up to:

bool StreamIsValid(I N ByteArray, IN Length, OUT ErrorMessage, OUT
ErrorByte)


Read up on System.InteropS ervices.Marshal et al.


I'm uncertain about memory issues: Who allocates, etc. I'm also
unclear about internalization of the error messages.


Caller allocates. .NET also has some 'magic' classes such as
StringBuilder that can be 'passed to be filled' without having a
maximum size pre-specified - this is done by the GC.

=============== Crouchie1998 reply =============== =

I wrote a simple C++ DLL & called it from VB.NET. Here's the sample:

http://www.gotdotnet.com/Community/U...2-ca46ef086c12

I hope this will help

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
4114
by: RainBow | last post by:
Hi everyone, (Very Sorry, if this is the wrong group in which I am posting this query). Code snippet: //C library typedef int (*PFunc)(int* aArg); void call_c_foo(PFunc aPtrtoFunc) {
1
2430
by: dwp | last post by:
hResult = pDefaultDomain->CreateInstanceFrom( pAppDomain- >m_bstrLoadAssemblyName, pAppDomain->m_bstrManagedClass, &pObjectHandle ) This call gives the E_ACCESSDENIED return value. I have checked that nothing is using the loaded assembly and that the access rigts are OK. Does anyone know of another reason for this return value ?
1
2914
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code written in C#. When the app calls my unmanaged functions, they work fine. But as soon as my unmanaged functions call managed functions (in the same source file!), the app reports an "unknown exception" error.
17
2204
by: Bill Grigg | last post by:
I have been successfully calling DLL's using VC++ 6.0 and also using VC++7.1 (.NET). I only mention this because I have never felt comfortable with the process, but nonetheless it did work. Recently I started calling an unmanaged DLL from a .NET app. It worked fine. Now I have the situation where I am trying to call a function in one DLL from another DLL. Both are unmanaged and are built with VC++7.1. In the calling DLL I set the property...
1
1602
by: Bern McCarty | last post by:
What do you make of this? I cannot tell for sure but it almost seems as the the transition thunk to get back from the native bool method to the managed caller is looking at eax and, if any bit is set, normalizing it to 0x00000001. If it wants to normalize the value then it should only operate on the al register since that's all that the native bool method uses to hold the return value. Is this a known VC 7.1 bug? Is there a hotfix...
16
517
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both and my c++ code should call c code.but when i tried to call a function in c code externing that function in my c++ code, i am getting unresolved external symbol error. Whatever i try its giving more and more errrors...so is it possible to merge 2...
16
3785
by: Jaco Naude | last post by:
Hi there, This is my first post over here and I hope someone can give me some guidance. I'm trying to embed Python into a Visual C++ 2008 application and I'm getting linker problems. I've compiled a DLL of the Python source code using the pythoncode VC++ project in the PCbuild folder of the source download and this works 100% without any warnings etc. I've done this in Debug and Release mode without any problems.
6
11581
by: Ole Nielsby | last post by:
VC has a __cdecl specifier which allows functions and methods to be called with varying parameter count. (I understand this is the default for functions in general but in VC, instances use another convention unless they have an ellipsis argument.) I can force GCC and other compilers to use such a convention by declaring all methods with an ellipsis, but I'd rather not clutter my method definitions with these.
1
2190
by: Clint Jensen | last post by:
Hello, I had a working project creating in Visual Studio 2003 where a VC++ program was calling a DLL produced by VB built using VS 2003. We recently upgraded to VS 2005 and calling the VB DLL from the VC++ program no longer works I am getting an error on the #import saying "Cannot open type library file: <name of file>: Error loading type library / DLL
0
9592
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10004
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9870
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.