Solved

Accessing a C# COM control from C++

Posted on 2006-11-01
8
181 Views
Last Modified: 2012-05-05
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-D8A54C81E643")]
    public interface HelloCom {
       
    }
   
    [Guid("111DCC11-900D-431c-B3A0-4B95C539A47D")]
    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 ?
0
Comment
Question by:Sinclair
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 17856173
You can't create ActiveX controls with C#

what you did will work with Dlls, but I'm not sure if that will work for contorls with other languages than .Net
0
 
LVL 2

Author Comment

by:Sinclair
ID: 17856225
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 ?

0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 17857392
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?
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 125 total points
ID: 17857409
take a look at this article, and notice the first paragraph in red

.NET Interop: Get Ready for Microsoft .NET by Using Wrappers to Interact with COM-based Applications
http://msdn.microsoft.com/msdnmag/issues/01/08/Interop/
0
 
LVL 2

Author Comment

by:Sinclair
ID: 17860748
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.
0
 
LVL 2

Author Comment

by:Sinclair
ID: 17883089
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 :-)
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 17887659
I'm sorry I didn't help much
0
 
LVL 2

Author Comment

by:Sinclair
ID: 17887700
I don't blame you, I blame Microsoft :-/
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question