Sinclair
asked on
Accessing a C# COM control from C++
Hi all,
I wrote a very simple user control in C#, and I'm trying to access it from my C++/MFC code. The control contains a single label in it. Here's the control code itself:
namespace HelloCom {
[Guid("F0AE1BB2-A840-4341- B785-D8A54 C81E643")]
public interface HelloCom {
}
[Guid("111DCC11-900D-431c- B3A0-4B95C 539A47D")]
public partial class HelloComImpl : UserControl, HelloCom {
public HelloComImpl() {
InitializeComponent();
}
}
}
Here's what I've done so far:
* Signed my control with a strong key
* Clicked the "expose assembly to COM interop" and "make visible to COM" options
* regasm HelloCom.dll /tlb:HelloCom.tlb
* gacutil -i HelloCom.dll
However, despite all this, I still cannot see my control in the Toolbox on the C++ side, nor can I insert it via the "Insert ActiveX Control" menu option. What am I doing wrong ?
I wrote a very simple user control in C#, and I'm trying to access it from my C++/MFC code. The control contains a single label in it. Here's the control code itself:
namespace HelloCom {
[Guid("F0AE1BB2-A840-4341-
public interface HelloCom {
}
[Guid("111DCC11-900D-431c-
public partial class HelloComImpl : UserControl, HelloCom {
public HelloComImpl() {
InitializeComponent();
}
}
}
Here's what I've done so far:
* Signed my control with a strong key
* Clicked the "expose assembly to COM interop" and "make visible to COM" options
* regasm HelloCom.dll /tlb:HelloCom.tlb
* gacutil -i HelloCom.dll
However, despite all this, I still cannot see my control in the Toolbox on the C++ side, nor can I insert it via the "Insert ActiveX Control" menu option. What am I doing wrong ?
ASKER
Ugh... I really need this to be an ActiveX control. Are you sure there's no way to do this easily ? If so, what would you recommend ? Wrap the DLL in a C-based ActiveX wrapper, maybe ?
honesntly, I haven't tried to do that before
but why you want to use C# to created managed component that will be access from unmanaged code?
but why you want to use C# to created managed component that will be access from unmanaged code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
mnasman:
I need a C# ActiveX control because our company is slowly switching to C#, but we have a massive (as in, prohibitively huge with respect to porting) legacy app written in C++/MFC that still needs to be extended from time to time with new features.
Thanks for that "red paragraph" article; I'll check it out right now and let you know how things turned out.
I need a C# ActiveX control because our company is slowly switching to C#, but we have a massive (as in, prohibitively huge with respect to porting) legacy app written in C++/MFC that still needs to be extended from time to time with new features.
Thanks for that "red paragraph" article; I'll check it out right now and let you know how things turned out.
ASKER
Yeah, so it looks like there really isn't a good solution to this, unfortunately. Thanks for your help, mnasman, even though it's bad news for me :-)
I'm sorry I didn't help much
ASKER
I don't blame you, I blame Microsoft :-/
what you did will work with Dlls, but I'm not sure if that will work for contorls with other languages than .Net