473,473 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Calling Managed code in a mixed C++ dll

Ray
I am trying to add calls to managed C++ class from unmanaged C in the same
DLL (I saw somewhere while trying to solve something else, that if you have
them both in the same DLL that you could freely call between managed and
unmanaged code with no stress, but i'm living proof that that was wrong, I'm
full of stress :)

at any rate, I've been laboring under the assumption that if I have file 1
over here with

#pragma unmanaged
BOOL myNiceUnmanagedMeth(void)
{

long x = MyNS::MyClass::MyMeanOlManagedMeth( 30);
}

and on the managed side

namespace MyNS
{
__gc class MyClass
{
public:
int MyMeanOlManagedMeth(int y){

return y * 2;
}
}
}

anybody got hints on how to make myNiceUnmanagedMeth call
MyMeanOlManagedMeth????

Ray


Nov 16 '05 #1
3 3600
That managed method is an instance method, so you need to create an object,

MyClass *o = new MyClass();
long x = o->MyMeanOlManagedMeth( 30);

Or declare the method to be static.

Huihong
The most secure .NET source code protection @ Remotesoft
"Ray" <Ra*@noSpamPlease.com> wrote in message
news:t4*******************@twister.socal.rr.com...
I am trying to add calls to managed C++ class from unmanaged C in the same
DLL (I saw somewhere while trying to solve something else, that if you have them both in the same DLL that you could freely call between managed and
unmanaged code with no stress, but i'm living proof that that was wrong, I'm full of stress :)

at any rate, I've been laboring under the assumption that if I have file 1
over here with

#pragma unmanaged
BOOL myNiceUnmanagedMeth(void)
{

long x = MyNS::MyClass::MyMeanOlManagedMeth( 30);
}

and on the managed side

namespace MyNS
{
__gc class MyClass
{
public:
int MyMeanOlManagedMeth(int y){

return y * 2;
}
}
}

anybody got hints on how to make myNiceUnmanagedMeth call
MyMeanOlManagedMeth????

Ray

Nov 16 '05 #2
Ray
I get compile errors...
MyClass : is not a class or a namespace name
MyMeanOlManagedMeth: identifier not found, even with argument-dependent
lookup.

"Huihong Luo" <hu******@stanfordalumni.org> wrote in message
news:uR**************@TK2MSFTNGP09.phx.gbl...
That managed method is an instance method, so you need to create an object,
MyClass *o = new MyClass();
long x = o->MyMeanOlManagedMeth( 30);

Or declare the method to be static.

Huihong
The most secure .NET source code protection @ Remotesoft
"Ray" <Ra*@noSpamPlease.com> wrote in message
news:t4*******************@twister.socal.rr.com...
I am trying to add calls to managed C++ class from unmanaged C in the same DLL (I saw somewhere while trying to solve something else, that if you

have
them both in the same DLL that you could freely call between managed and
unmanaged code with no stress, but i'm living proof that that was wrong,

I'm
full of stress :)

at any rate, I've been laboring under the assumption that if I have file 1 over here with

#pragma unmanaged
BOOL myNiceUnmanagedMeth(void)
{

long x = MyNS::MyClass::MyMeanOlManagedMeth( 30);
}

and on the managed side

namespace MyNS
{
__gc class MyClass
{
public:
int MyMeanOlManagedMeth(int y){

return y * 2;
}
}
}

anybody got hints on how to make myNiceUnmanagedMeth call
MyMeanOlManagedMeth????

Ray


Nov 16 '05 #3
try to use full class name

MyNS::MyClass *o = new MyNS::MyClass();
long x = o->MyMeanOlManagedMeth( 30);

Huihong
-----Original Message-----
I get compile errors...
MyClass : is not a class or a namespace name
MyMeanOlManagedMeth: identifier not found, even with argument-dependentlookup.

"Huihong Luo" <hu******@stanfordalumni.org> wrote in messagenews:uR**************@TK2MSFTNGP09.phx.gbl...
That managed method is an instance method, so you need to create an
object,

MyClass *o = new MyClass();
long x = o->MyMeanOlManagedMeth( 30);

Or declare the method to be static.

Huihong
The most secure .NET source code protection @ Remotesoft

"Ray" <Ra*@noSpamPlease.com> wrote in message
news:t4*******************@twister.socal.rr.com...
> I am trying to add calls to managed C++ class from unmanaged C in the
same > DLL (I saw somewhere while trying to solve something
else, that if you
have
> them both in the same DLL that you could freely call
between managed and > unmanaged code with no stress, but i'm living proof that that was wrong, I'm
> full of stress :)
>
> at any rate, I've been laboring under the assumption
that if I have file1 > over here with
>
> #pragma unmanaged
> BOOL myNiceUnmanagedMeth(void)
> {
>
> long x = MyNS::MyClass::MyMeanOlManagedMeth( 30);
> }
>
> and on the managed side
>
> namespace MyNS
> {
> __gc class MyClass
> {
> public:
> int MyMeanOlManagedMeth(int y){
>
> return y * 2;
> }
> }
> }
>
> anybody got hints on how to make myNiceUnmanagedMeth

call > MyMeanOlManagedMeth????
>
> Ray
>
>
>
>


.

Nov 16 '05 #4

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

Similar topics

5
by: Adam McKee | last post by:
We are using Visual Studio.NET 2003 in our project with .NET framework 1.1. One of our libraries is a mixed-mode dll assembly consisting of one managed C++ library, and several unmanaged C++...
1
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code...
4
by: | last post by:
I am stuck in a situation and I do believe that this should work, but it doesn't. I have a unmanaged dll, that uses MFC. This works great. Now I recompile the unmanaged dll so it contains...
1
by: Kluch | last post by:
I have a mixed mode dll with a garbage collected interface. The interface is garbage collected because my derrived class has managed member variables. I am trying to return a pointer to my...
1
by: slugster | last post by:
Hi, i originally posted this via another portal, but after giving it time to propagate it still hasn't shown up. My apologies for the multiposting. This might be a very simple question, but i...
13
by: bonk | last post by:
Hello, I am trying to create a dll that internally uses managed types but exposes a plain unmanaged interface. All the managed stuff shall be "wrapped out of sight". So that I would be able to...
9
by: Herby | last post by:
Is possible to have a managed method within a Native(un-managed) class within a \clr project? E.g. class myClass { public: #pragma managed void myMethod(void);
9
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for...
1
by: Arne Adams | last post by:
Hi, I try to use a C# Dialog in a legacy MFC application. The problem seems to boil down to the following: from an unmanaged console application I can call any function of the managed bridge - if...
7
by: Andreas Reiff | last post by:
Hey! I have a managed c++ app (actually, the app is mixed managed/unmanaged, but this happens in the managed part) that dynamically generates some program in c# (with CSharpCodeProvider). The...
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
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...
1
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...
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,...
1
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: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
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.