473,326 Members | 2,111 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,326 software developers and data experts.

C Library in a managed DLL

I have a .LIB file, built an compiled in C that I need to use in
my .NET application.

If I build a C++.Net Console application and activate the exposed
functions directly the library works perfectly.

If I try to compile the .LIB file into a managed DLL for use in either
my VB.Net GUI or my managed C++.Net Console application I get a Null
Reference Exception when the LIB makes a MALLOC call.

Is there some command or option that I need to set to allow my managed
DLL to be able to run MALLOC?

Thanks!

Mar 30 '07 #1
1 1089
Hi Kidan,

Have you tried to access the library via platform invoke instead of
importing it ?

something like this:

Declaration:
-------------

<DllImport("filename.(lib or dll)", EntryPoint:="YourREALFunctionName")_
Private Shared Function YourAliasForyourfunction(parameter1 as
parametertype, etc.) As ReturnValueType
End Function--

Using it:
---------

VariableWithReturnType=YourAliasForyourfunction(pa rameters) ...
I hope this helps,

Roger
..NET 2005 and DB developer
"Kidan" wrote:
I have a .LIB file, built an compiled in C that I need to use in
my .NET application.

If I build a C++.Net Console application and activate the exposed
functions directly the library works perfectly.

If I try to compile the .LIB file into a managed DLL for use in either
my VB.Net GUI or my managed C++.Net Console application I get a Null
Reference Exception when the LIB makes a MALLOC call.

Is there some command or option that I need to set to allow my managed
DLL to be able to run MALLOC?

Thanks!

Mar 30 '07 #2

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

Similar topics

1
by: mccoyn | last post by:
I'm porting an old project to use .NET. When I try to link in a static library (.lib) that has a single managed class in it. I get the following errors: LINK : error LNK2020: unresolved token...
0
by: Alex Sedow | last post by:
I have 3 projects: 1. C++ static library (.lib) with fast code. (Core level) 2. Managed C++ assembly (.dll) that include C++ library (1) and contain managed wrappers around classes from C++...
4
by: Aaron Queenan | last post by:
When I build a C++ library to .NET using the managed C++ compiler, I get the following error message: Linking... LINK : error LNK2020: unresolved token (0A000005) _CrtDbgReport LINK : error...
3
by: mirek | last post by:
Hi, I've got problem building managed class library to wrap unmanaged code. I created managed class library using standard patten: #include "../Unmanaged/Class1.h" //Class1 unmanaged ...
1
by: Adam Clauss | last post by:
I have an unmanaged C++ library that I need to use through C#. I created a Managed C++ class library and through it wrote a wrapper class to call what I need. However, one of the methods (an...
5
by: Gerhard Menzl | last post by:
When creating a Managed C++ DLL using the Visual Studio 7.1 Solution Explorer (by selecting Add New Project and then either choosing Class Library (.NET) or Windows Control Library (.NET)), the IDE...
2
by: Michael Braitmaier | last post by:
I have a quite severe problem. I am trying to compile a C++ library initially written for VC++ 6. To make the library available for .NET languages I want to compile the library as managed C++...
7
by: rCs | last post by:
The SEI has published CMU/SEI-2006-TR-006 "Specifications for Managed Strings" and released a "proof-of-concept" implementation of the managed string library. The specification, source code for...
87
by: Robert Seacord | last post by:
The SEI has published CMU/SEI-2006-TR-006 "Specifications for Managed Strings" and released a "proof-of-concept" implementation of the managed string library. The specification, source code for...
5
by: Jesper Schmidt | last post by:
When does CLR performs initialization of static variables in a class library? (1) when the class library is loaded (2) when a static variable is first referenced (3) when... It seems that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.