473,411 Members | 1,995 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,411 software developers and data experts.

HOWTO call static managed function from unmanaged code.

A little more info.

I have a unmanaged C++ DLL, compiled without /CLR.
Inside a Managed C++ DLL, I have the following class:

MarshalWrapper.h
----
#ifdef _MANAGED
__nogc
#endif
class MarshalWrapper
{
public:
MarshalWrapper();
~MarshalWrapper();

static bool IsExceptionActive();
};

MarshalWrapper.cpp
----
MarshalWrapper::MarshalWrapper()
{
}

MarshalWrapper::~MarshalWrapper()
{
}

bool MarshalWrapper::IsExceptionActive()
{
const unsigned long cnNoExceptionActive = 0xCCCCCCCC;
return Marshal::GetExceptionCode() != cnNoExceptionActive;
}

Inside my Unmanaged C++ project, I add a reference to the Managed C++
project, and call MarshalWrapper::IsExceptionActive().

I get the following error:
File1.obj : error LNK2019: unresolved external symbol "public: static
bool __cdecl MarshalWrapper::IsExceptionActive(void)"
(?IsExceptionActive@MarshalWrapper@@SA_NXZ) referenced in function
"public: __thiscall File1::~File1(void)" (??1File1@@QAE@XZ)

I tried changing the function declaration to be __cdecl, but this
caused other confusing problems.

All the examples I have are from calling managed code inside a managed
C++ project inside a #pragma unmanaged block, is it not possible to
make calls from a project not compiled with /CLR? If not, what are the
downsides to changing my unmanaged C++ project to /CLR? In particular,
are there any performance implications?

Thanks,
-ken
ra*************@gmail.com (Ken Durden) wrote in message news:<f3*************************@posting.google.c om>...
I'm trying to call

Marshall::GetExceptionCode() from Unmanaged C++.

Can I use gcroot to do this, or is there a simpler way?

-ken

Nov 17 '05 #1
0 1433

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

Similar topics

1
by: sunil s via DotNetMonster.com | last post by:
Hi, I've got a native C++ app which calls a 3rd parth .NET DLL using the LoadLibrary/GetProcAddress functions. This works fine when the DLL is located in the app directory, but if I move it out...
24
by: Jazper | last post by:
hi i have this problem. i made a class deverted by CRootItem with implementation of IDisposable-Interface. i made a test-funktion to test my Dispose-Method.... but when set a breakpoint in my...
2
by: hykim | last post by:
I want to call a unmanaged dll's function returning some STRUCT's pointer. the next is definition of a STRUCT. ----------------------------------------------------------------------- typedef...
3
by: Tony Liu | last post by:
Dear All: I create a very simple DLL by using EVC to test the problem. (The platform I am working for those program is WinCE.NET) ******************************************************* The...
2
by: joye | last post by:
Hello, My question is how to use C# to call the existing libraries containing unmanaged C++ classes directly, but not use C# or managed C++ wrappers unmanaged C++ classes? Does anyone know how...
8
by: ATS | last post by:
HOWTO Implement LoadLibrary\GetProcAdrress\FreeLibrary in C# Please help, I want to fully implement LoadLibrary\GetProcAdrress\FreeLibrary in C#, and be able to call functions that I use...
3
by: ATS | last post by:
HOWTO Implement LoadLibrary, GetProcAdress, and FreeLibrary. Below is code that I want to be able to use simple LoadLibrary\GetProcAddress\FreeLibrary technqiues on. I've used the code that was...
13
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
3
by: Sam Carleton | last post by:
I am writing Managed C++ code to call in to an Unmanaged C API. The reason for using Managed C++ over C# is that the Unmanaged C module is loaded via LoadLibrary(). DllImport cannot be used;...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...
0
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...

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.