ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Calling a manged DLL from unmanaged C++ ARX

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
alex_b
1263 Views, 2 Replies

Calling a manged DLL from unmanaged C++ ARX

Hello

I need to use in my (unmanaged C++) program some functionality which is easy to get in C#.

To test for feasibility, I decided to try a very basic example available at Microsoft:

- build a C# DLL containing an interface and a simple public method which adds two numbers.

- register it

- in the ARX project import the type library and acces the DLL like so:

	HRESULT hr = CoInitialize(NULL);
	IGetDocText* pGetDocText (__uuidof(CGetDocText));
	// use the ADD API
	long result = 0;
	hr = pGetDocText>Add(10, 20, &result);
	// Release the COM interface
	CoUninitialize();

 If I I use the clr oldSyntax switch as per MS recommendation, I get a zillion errors, all like: 

c:\!dev\objectarx 2008\inc\mgdinterop.h(166) : error C2039: 'Vector3d' : is not a member of 'Autodesk::AutoCAD'

If I use the No clr support switch, it errors on:

.error C2440: 'initializing' : cannot convert from 'const _GUID' to 'GetDocText::IGetDocText *'

No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

 which seems logical to me.

As this is my 1st time at managed code usage in ARX, I could use a few hints, please.

 

Thanks

 

2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: alex_b

Why not use create a mixed mode module?

Just a thought

Message 3 of 3
alex_b
in reply to: Anonymous

Hi Daniel.

 

For one, I am not that fluent in interop and .net to dare do what you suggest.

 

Anyway, I solved the problem.

I was led awry by a Microsoft document stating that the unmanaged code should be compiled with /clr:oldSyntax switch.

As soon I got rid of it, it compiled OK.

 

Thanks

 

alex

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost