Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 3rd, 2007, 06:35 AM
Authorized User
 
Join Date: Jan 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default How can we call VC++ dll in C# windows application



I have a VC++ dll and i want to call it in my C# Windows Application.
How can I do it?

 
Old March 4th, 2007, 01:35 AM
Registered User
 
Join Date: Mar 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Load it explicitly and make calls to the exported methods , before doing that you need to declare the exported functions in C# , look at PInvoke examples. or much rather look at www.pinvoke.net to get an idea of what i mean.

 
Old March 4th, 2007, 01:45 AM
Registered User
 
Join Date: Mar 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Forgot to mention that in many cases using the DllImport attribute is not sufficent, the whole thing is not really that straight forward for example.
For unions that need to be passed you need to declare a struct with Layout type set to explicit,.
For pointers that have to be passed from managed to unmanaged it is essential that you pin it before you pass it (especially when the pointer is involved in a async callback into the managed code).



Quote:
quote:Originally posted by ssawe
 Load it explicitly and make calls to the exported methods , before doing that you need to declare the exported functions in C# , look at PInvoke examples. or much rather look at www.pinvoke.net to get an idea of what i mean.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with windows application and DLL naikpalak722 General .NET 0 October 2nd, 2007 03:08 PM
How to call a COM DLL from VC++, subhash_w Visual C++ 0 July 15th, 2005 11:33 PM
How to call VC++ DLL from ASP/ASP.net? leesoon Classic ASP Professional 0 December 9th, 2004 10:06 PM
DLL in VC#.NET sachin-csharp .NET Framework 2.0 1 August 23rd, 2004 11:57 PM
Call VB6 or VC++ classes from C# - Reflection? lpinho C# 0 September 22nd, 2003 09:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.