473,473 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Link C++ static lib in C# project - confirm not possible?

I just need to confirm now (after I've spent several days chasing mystery
metadata warnings/errors) that this is *NOT* possible:

Link a managed C++ static library into a (managed) C# application.

NOT POSSIBLE?

Please respond *only* if you *know* the answer, I'm not interested in
conjecture.

For those that care: my project is *not* trivial, and is a migration from C++.
The library in question is composed of 100's of files, and isn't trivial to
convert to either a DLL or C# (at least w/o seriously affecting my timeline).

Finally, presuming that the above is not possible, why wouldn't the C#
compiler/linker emit a simple error such as "Cannot link C/C++ static library
with C# project"?


--
Bret Pehrson
mailto:br**@infowest.com
NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl>>
Nov 15 '05 #1
2 8263
NO, its not possible, the compiler doesn't emit a simple error because there
is no link step involved when compiling a C# source file.

Willy.

"Bret Pehrson" <br**@infowest.com> wrote in message
news:40***************@infowest.com...
I just need to confirm now (after I've spent several days chasing mystery
metadata warnings/errors) that this is *NOT* possible:

Link a managed C++ static library into a (managed) C# application.

NOT POSSIBLE?

Please respond *only* if you *know* the answer, I'm not interested in
conjecture.

For those that care: my project is *not* trivial, and is a migration from C++. The library in question is composed of 100's of files, and isn't trivial to convert to either a DLL or C# (at least w/o seriously affecting my timeline).
Finally, presuming that the above is not possible, why wouldn't the C#
compiler/linker emit a simple error such as "Cannot link C/C++ static library with C# project"?


--
Bret Pehrson
mailto:br**@infowest.com
NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl>>

Nov 15 '05 #2
Hello Bret,

Thanks for your post. As I understand, you have a .NET Managed Class
Library created by C++ and want to link it directly to C# project. Please
correct me if there is any misunderstanding. I now share the following
information with you:

Willy is correct that it's not possible. If it's a .NET Managed Class
Library, you can add reference to it and use it in your C# project.

If it's a Win32 Static Library, you can create C++ DLL which simply links
to the Static Library and put the names of the functions that need to be
exported to the .DEF file of the DLL. Then, your C# application can call
the functions via P/Invoke.

Consuming Unmanaged DLL Functions
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconconsumingunmanageddllfunctions.asp

Please feel free to let me know if you have any problems or concerns.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #3

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

Similar topics

3
by: Craig | last post by:
Hi, I'm working on a PHP FTP client, but my testers have complained the delete file link is too easy to hit by mistake. Would it be possible/plausible to write a bit of javascript that pops up a...
0
by: TGF | last post by:
Hello, I am creating a console app. I try to link a static library by including it in the Linker-Input-Additional Dependencies field under the Project properties. Then I specify the path to...
0
by: david | last post by:
Hello! I've a link error problem problem with VS .NET 2003. I give you the complete description of a simple test (to simplify) : First, I make a WIN32 static library supporting MFC and using...
5
by: Baget | last post by:
Hello this code does not compile on VC6, it compile fine on other compilers on two OS (gcc, bcc, VC7 on windows, gcc on Linux). I am getting error C2057 on VC6 what to do? ==========...
2
by: free2cric | last post by:
Hi, I have two c++ static libraries say A.lib and B.lib. I am creating third static library C I create project in microsoft visual studio as win32 static library. I go to project-> settings ->...
9
by: Laban | last post by:
Hi, I find myself using static methods more than I probably should, so I am looking for some advice on a better approach. For example, I am writing an app that involves quite a bit of database...
5
by: lsolesen | last post by:
I used the following javascript to add confirm-boxes to links. The confirm-boxes are added at runtime for links with the class "delete". The script adds the function to the links. When I click...
18
by: Zytan | last post by:
I just got a TypeInitializationException exception. Why it is a common cause for this? The InnerException is System.FormatException, although I don't see anything requesting something to be...
8
by: Bern McCarty | last post by:
We have a large mixed dll that I can never seem to get to link incrementally. Below is the console output. For simplicity I've eliminated some stuff that we normally do when we really link this...
0
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,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.