![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Andrewm My calling application is written in using MFC. I've attempted in my new c#.net component to accept a System.Runtime.InteropServices.ComTypes.IStream as a parameter, but the MFC application compains saying it can't convert an IStream to a System.Runtime.InteropServices.ComTypes.IStream. If the C++ code knows that the parameter type is S.R.IS.ComTypes.IStream you must be compiling with managed code support and referencing the implementing assembly directly. Don't you want to just consume the existing COM interface? Anyway, to turn a native IStream* to the corresponding managed interface, call Marshal.GetObjectForIUnknown and then cast the result to ComTypes.IStream. Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. |
#3
| |||
| |||
|
|
Thanks Mattias, Yes, I am referencing the assembly directly. Since reading your post i've tried using regasm.exe to register the .net assembly and create a .tlb file. The dll registered fine, then in my MFC application I added a COM reference to the dll but I get a message "Type library 'X' was exported from a CLR assembly and cannot be re-imported as a CLR assembly." Given that I was attempting to import the COM types rather than the .NET reference directly, I don't really understand what the message means. thanks for your help, Andrew "Mattias Sjögren" <mattias.dont.want.spam (AT) mvps (DOT) org> wrote in message news:O56wLyBGIHA.536 (AT) TK2MSFTNGP06 (DOT) phx.gbl... Andrewm My calling application is written in using MFC. I've attempted in my new c#.net component to accept a System.Runtime.InteropServices.ComTypes.IStream as a parameter, but the MFC application compains saying it can't convert an IStream to a System.Runtime.InteropServices.ComTypes.IStream. If the C++ code knows that the parameter type is S.R.IS.ComTypes.IStream you must be compiling with managed code support and referencing the implementing assembly directly. Don't you want to just consume the existing COM interface? Anyway, to turn a native IStream* to the corresponding managed interface, call Marshal.GetObjectForIUnknown and then cast the result to ComTypes.IStream. Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |