473,789 Members | 2,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# using C++ dlls and lib

I have a program in C# that needs to access a couple of C++ dlls and libs.

Can this be done?

Thanks,

Tom
Oct 20 '06 #1
3 4067

"tshad" <ts**********@f tsolutions.comw rote in message
news:O2******** ******@TK2MSFTN GP04.phx.gbl...
|I have a program in C# that needs to access a couple of C++ dlls and libs.
|
| Can this be done?
|
| Thanks,
|
| Tom
|
|

You can only call functions exported by DLL's, C# (and all other .NET
languages) cannot bind to libs.
Note also that with "exports" I mean C style exported functions. Search the
docs for PInvoke interop for more details.

Willy.

Oct 21 '06 #2
tshad wrote:
I have a program in C# that needs to access a couple of C++ dlls and libs.

Can this be done?
COM DLL's or Win32 DLL's.

COM stuff can be used directly.

Win32 DLL's can be used via dllimport.

A very simple example:

using System;
using System.Runtime. InteropServices ;

class MainClass
{
[DllImport("msvc rt.dll")]
public static extern int system(string cmd);
public static void Main(string[] args)
{
Console.WriteLi ne("Hello world");
system("CLS");
}
}

Arne
Oct 21 '06 #3
Willy Denoyette [MVP] wrote:
Note also that with "exports" I mean C style exported functions. Search the
docs for PInvoke interop for more details.
Good point.

C++ mangled names is a problem.

Arne
Oct 21 '06 #4

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

Similar topics

7
4451
by: Ritu | last post by:
Hi All, Can any body please tell me how i can write a device driver using CSharp. Thanks, Ritu
0
2753
by: Shiraz | last post by:
Hi I have a question regarding the functionality of merge modules. Since this relates to my previous queries, I'll just give you a brief background on the topic. I had to make an installer for an application which was to share dlls with another application and these dlls were not self-registering. Someone on the forum suggested a few methods for the Visual studio installer, but since I had been using another software, a certain...
11
2297
by: Devender Khari | last post by:
Hi Friends, I'm facing a situation as follows, need help on identifying possible issues. There is an MFC application developed in VC6.0, say ABCVC6.exe and another developed in VC.NET, say DEFVCNET.exe. There are a few DLLs that are to be used by these applications. All these DLLs are originally developed in VC6.0 but some of them are now migrated to VC.NET. So, let's say we have PQRVC6.dll and XYZVCNET.dll.
2
1349
by: | last post by:
I try to build dll in VC .NET, In that project I use dlls that were built in VC6, and I get a lot of errors. (for example <iostream.h> instead of <iostream> etc.) I am not aloud to change anything inthe code of projects that were built in vc6. I need to make it works together(dlls that were built in vc6 and the one that was built in .NET). The main problem is that the vc6 header files that were included in .net source code raise such errors...
7
3110
by: Oenone | last post by:
I'm sure there's an obvious way to do this, but I'm missing it so far. I have an ASP.NET application that relies on several DLLs to work. Currently in order to get my site working I have to put them all in the bin/ folder within my web site's directory. As I have numerous web sites, I want to be able to place all of these DLLs just once into a single location elsewhere on the disk (e.g., "D:\DLLs"). I don't want to put them into the...
6
2206
by: Brian Bischof | last post by:
I'm having troubles getting the debugging process to work consistenly for external classes. I got it to work once and then I turned it off. But now I can't get re-enabled. Here is what I'm doing. If someone could tell me what I'm missing that would be great. 1. Create an external class and call it Test.dll. 2. Create a test Asp.net app called App.sln. 3. For App.sln I set a reference to Test.dll. 4. Compile App.sln and run it. The web...
0
1518
by: Reini | last post by:
We are developing an Asp.Net 2.0 application (Web Administration) for the IIS 5.0 to 6.0 and the W2K to W2K3 operating system. The application consists of several layers. One layer is a .Net 2.0 Classlibrary (DxuCoreClr.dll) written in managed C++, that is encapsulating several native Api's in form of native Win32 dlls (i.e. dxldaputils.dll). The Classlibrary and the native dlls are installed to the bin directory of the Asp.Net 2.0...
7
6511
by: Olegus | last post by:
Hello, in order to perform backup/restore MSSQL database using SMO, one needs to reference several namespaces in a backup class : using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Smo; Unfortunately, MSSQL 2005 and MSSQL Express keep them in different place. For MSSQL2005 they are located in C:\Program Files\Microsoft SQL Server \90\SDK\Assemblies and for MSSQL Express you can find them in C:
6
4598
by: =?Utf-8?B?RmFiaWFu?= | last post by:
Hello, I have a class hierarchy distributed over 3 native C++ dlls. The base class has a .NET Windows.Form for status output via a gcroot<>. The gcroot is declared private - the sub classes only have access via a protected "print"-method. I need the different dlls as the sub classes implement the base class's pure virtual methods using different technologies. To use the native classes from outside their dlls I use the...
0
928
by: =?Utf-8?B?YmVuIG1pdGNo?= | last post by:
hi i have a question about how to arrange linkage between a "framework" executable and an extensible set of "applet"s in DLLs that plug into the executable. the main exe is an application for managing interactions between "applets" which live in the dlls. the main exe offers communications between the applets, and also certain services that the applets can make use of. the question is, how to offer these services to the dlls. they can...
0
9666
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...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10410
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10139
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
9984
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...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
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
5418
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...
2
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.