Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

joanusdmentia

Managed C++ wrapper or DllImport?

This topic is 5221 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m looking at using the recently released ODE 0.5 in a game being written in C#, however the provided .NET wrapper in the contrib/ dir don''t look like they''ve been updated to 0.5 so I''m going to write my own. Does anyone know whether there is any performance difference between writing managed C++ wrapper classes and compiling all of ODE into a managed assembly or just using the DllImport attribute in C# to call the functions in an unmanaged ODE dll? I''m currently leaning towards using DllImport since it would make things a bit more portable (as far as I know mono can''t handle mixed assemblies), but if the speed difference is enough then I''ll go with the C++ wrapper classes.

Share this post


Link to post
Share on other sites
Advertisement
I''d think a Managed C++ solution would be slightly faster than P/Invoke. P/Invoke involves quite a bit of marshalling magic in some cases, and there is a reason why the general guideline is that P/Invoke calls should be few and chunky.

A mixed MC++ assembly shouldn''t require any marshalling.

(All of the above is just educated guesswork based on my knowledge of the technologies - I haven''t actually tested it.)

One thing, which may or may not be relevant in your case, is that mixed-mode MC++ assemblies won''t run under Mono or any other alternative .NET implementation, nor will they compile there unless someone develops an MC++ compiler for them. This is because mixed-mode assembles contain, by definition, unmanaged code, which is bound to the underlying platform.

--
AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.
[Project site] [Blog] [RSS] [Browse the source] [IRC channel]

Share this post


Link to post
Share on other sites
quote:
Original post by Arild Fines
I''d think a Managed C++ solution would be slightly faster than P/Invoke. P/Invoke involves quite a bit of marshalling magic in some cases, and there is a reason why the general guideline is that P/Invoke calls should be few and chunky.

A mixed MC++ assembly shouldn''t require any marshalling.

That makes sense. Not really sure about MC++ assemblies not requiring marshalling though, I would have thought it would still be needed for passing objects between the managed and unmanaged C++ (I haven''t really done much with MC++ before, just C# as far as managed code goes).

quote:
Original post by Arild Fines
One thing, which may or may not be relevant in your case, is that mixed-mode MC++ assemblies won''t run under Mono or any other alternative .NET implementation, nor will they compile there unless someone develops an MC++ compiler for them. This is because mixed-mode assembles contain, by definition, unmanaged code, which is bound to the underlying platform.

This is as I thought and is the reason why I was leaning towards P/Invoke. Having said that though I won''t loose any sleep if it doesn''t end up being portable, it''s just something that would be ''nice'' to have the option of.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!