473,385 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 4051

"tshad" <ts**********@ftsolutions.comwrote in message
news:O2**************@TK2MSFTNGP04.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("msvcrt.dll")]
public static extern int system(string cmd);
public static void Main(string[] args)
{
Console.WriteLine("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
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
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...
11
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...
2
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...
7
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...
6
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....
0
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...
7
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...
6
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...
0
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.