Posted By: Verdant | Feb 12th, 2008 @ 11:23 AM
page 1 of 1
Comments: 6 | Views: 1268
I am working on a software research project that is entirely in C#, however now we want to have a maya plugin that utilizes some of the functionality from the C# code.

Maya expects an unmanaged dll, which is fine i don't mind writting that.

However, i need to make hooks to the C# code and vice versa, i have no problems accessing my unmanaged dll from C# using InteropServices,  but i do not know how to access the managed code from the unmanaged C++, any hints?

I am sure this is possible, but i have never done it.

If anyone has any suggestions for a purely managed solution, i would be thankful

Have you looked into Managed Extensions for C++ at all? I personally have never used it, but it seems to popular way to tie managed and unmanaged code together. The /clr option still compiles it to MSIL, but I'm not sure exactly what Maya's restrictions are.

RichardRudek
RichardRudek
So what do you expect for nothin'... :P
Verdant wrote:
found this article that seems to describe the process i need to use, ugh looks like a lot of steps


I've not read the article, but from the date of it, it's old, pre-2005. They changed the way the C++ managed/unmanaged stuff works with 2005. So unless your using 2003 or 2002, then I probably would take too much notice of that article.

Having said that, I've only done trivial Managed C++ stuff,  and did not have to resort to anything spectacular. Though, I did have to create proxies for most things, like data structures, etc.

A few of those proxies were probably unnecessary, as the builtin marshalling stuff is quite extensive. But I found it harder to get up-to-speed with the marshaling stuff than it was to hand-roll my own proxies. You mileage may vary...

After breakfast (and catching up on the new Ch9 videos), I'll see if I have some time, and do a little sleuthing (it's morning over here...)
RichardRudek
RichardRudek
So what do you expect for nothin'... :P
OK. How performant does this need to be ?  How many threads ?

My initial reaction to this is to use COM, mainly because you have the issue of hosting the CLR, and the Managed C++ code (obviously) needs the CLR - I'm presuming that Maya doesn't host the CLR.

So rather than using Managed C++, just bypass C++ altogether, and expose your Manged Code via COM.

Well, you still need to write the Maya DLL, so you probably still need to write that using C++. But these stubs would be interopting via COM.

If you want to write something rapidily (prototype), then depending on the Interfaces Maya expects, you could probably whip up a Native DLL using VB6 - COM is native to VB6, whereas for C++, you probably end up using ATL. Raw COM from C/C++ is ugly...
RichardRudek
RichardRudek
So what do you expect for nothin'... :P
COM likes to do things in large chunks because the roundtrip (cross process/ cross machine) is expensive. 100 per second might be OK. I think the last time I benched it, I was able to get up to ~1000 calls per second. But my memory may be wrong in this case. I certainly wouldn't try going much beyond 100, at least on a single core system.

The other thing to consider is [hosting the 1.1 CLR]. That is, within your Maya Plugin DLL, you host a CLR domain, and your managed code runs within this isolated environment. Kind of like adding a scripting engine, but the 'scripts' are your managed code.
page 1 of 1
Comments: 6 | Views: 1268
Microsoft Communities