MFC and C#

S

Steven Blair

I have a MFC application written in Visual Studio 6.0 and now have a
requirement to hook in a C# dll for Database processing.
So a few questions on this:

1. Is it possible to allow my MFC application to hook directly into the
C# dll, and if yes, how could I do this?
2. The existing application uses COM to talk to the existing Database
layer.
Would it be advisable to continue using COM and add a COM wrapper
around my C# dll?

Any help or suggestions on this matter is appreciated.

Steven
 
S

Sericinus hunter

Steven said:
I have a MFC application written in Visual Studio 6.0 and now have a
requirement to hook in a C# dll for Database processing.
So a few questions on this:

1. Is it possible to allow my MFC application to hook directly into the
C# dll, and if yes, how could I do this?
2. The existing application uses COM to talk to the existing Database
layer.
Would it be advisable to continue using COM and add a COM wrapper
around my C# dll?

I think this is the only option you have. There is no need for
a wrapper, regasm tool makes the process of exposing C# dll as COM
component easy.
 
V

VJ

Yes sure you can make the C# COM visible and then include in MFC project to
use it... the best way with the framework you have.

VJ
 
S

Steven Blair

Thanks for the replies.

Is there any other issues I should be aware of before embarking on this
COM route, e.g. disposing memory?
Just anything you think might be helpful to know before I start down
this track.

Steven
 
S

Sericinus hunter

Steven said:
Thanks for the replies.

Is there any other issues I should be aware of before embarking on this
COM route, e.g. disposing memory?
Just anything you think might be helpful to know before I start down
this track.

Give your interface manually generated GUID, using attribute, like this:

[Guid("your_manually_generated_guid_string_representation")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
interface ISomeInterface
{
}

Otherwise, it will be regenerated in every build.
 
V

VJ

Yes one of the main things for COM interop is you implement your own
IDisposeable interface, C# library should do it... I belivie the MSDN has
some articles on hand for writing C# based COM Interop, more like what you
should be aware of... I can't seem to get it now... you could try..

Vijay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top