C++/CLI and native code

C++/CLI and native code

Bernd_L
Participant Participant
1,147 Views
4 Replies
Message 1 of 5

C++/CLI and native code

Bernd_L
Participant
Participant
Hi there,

I wonder how to use unmanaged functions (ObjectARX) from a managed project written in C++/CLI. I had hoped it was no more than just adding #include "nativeArxFileName.h" and have the corresponding include paths defined, but obviously it's not that easy. I'm asking here, because I find it very clumsy to go the other way round and call .NET classes from a good oldfashioned ObjectARX project, but maybe I just haven't found any good explanations on how to do that, yet.

Any help would be greatly appreciated, Bernd
0 Likes
1,148 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
I use native ObjectARX with managed C++/CLI all the time, and it's fairly easy to do.

You can use the ARX wizard to build a mixed-mode DLL that can contain both managed and unmanaged code (which must be loaded via NETLOAD, or have the MANAGED=1 value in its registry entry for demand loading).

The one thing you need to do is to turn off embedded manifest generation.

Another way to do it, is without using the ObjectARX wizard, and instead using a standard C++/CLI project:

1. Create a new managed C++/CLI ClassLibrary project.

2. In the project settings, add the include and library paths to the ObjectARX include and lib folders.

3. Replace your stdafx.h with one generated by the ObjectARX wizard for a standard ObjectARX project. If you want to use MFC, then you also need to make your DLL an MFC Extension Dll (add _AFXEXT to your preprocessor definitions).


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

wrote in message news:[email protected]...
Hi there,

I wonder how to use unmanaged functions (ObjectARX) from a managed project written in C++/CLI. I had hoped it was no more than just adding #include "nativeArxFileName.h" and have the corresponding include paths defined, but obviously it's not that easy. I'm asking here, because I find it very clumsy to go the other way round and call .NET classes from a good oldfashioned ObjectARX project, but maybe I just haven't found any good explanations on how to do that, yet.

Any help would be greatly appreciated, Bernd
0 Likes
Message 3 of 5

Bernd_L
Participant
Participant
Hi Tony,

thank you so much. I chose the second way and now I can use the 'old' classes as well as the managed ones.
One thing that was a bit strange is, that even though I added the paths to the inc and lib folders of ObjectArx in my global VC++ directories, I still had to expand the filenames acdbmgd.h and acmgd.h to their full paths. But that shouldn't bother me as long as everything else is running so smoothly.
0 Likes
Message 4 of 5

Anonymous
Not applicable
Sorry, I missed a few details.

There's no acdbmdg.h and acmgd.h that I'm aware of, so I
assume you mean the DLL's instead.

You just reference them with the #using directive in
StdAfx.h, like this:

#using
#using

For visual studio to find those files, you have to tell it where they
are. In your project properties dialog, select the C/C++ node, and
set "Resolve #using References" to the path to acad.exe.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

wrote in message news:[email protected]...
Hi Tony,

thank you so much. I chose the second way and now I can use the 'old' classes as well as the managed ones.
One thing that was a bit strange is, that even though I added the paths to the inc and lib folders of ObjectArx in my global VC++ directories, I still had to expand the filenames acdbmgd.h and acmgd.h to their full paths. But that shouldn't bother me as long as everything else is running so smoothly.
0 Likes
Message 5 of 5

Bernd_L
Participant
Participant
oops, of course I meant the dll's. But I found that the using directives are not necessary when they are already defined in the global vc++ directories' settings.
0 Likes