Form to COM

J

Janiv Ratson

Hello,
I have a Form derived class (in a class library project), and I want to use
this class in an MFC application (via COM).
How do I do it?
I'll appreciate a step by step tutorial.
Thanks,
Janiv Ratson.
 
P

Phil

Thanks Phil.
This is a guide for VS 2003, will it fit VS2005?
Is there an updated guide for VS2005?
I did not understand the deployment part.
What COM file should I deploy to my users?
How do I register the COM on users machines?
Thanks again,

Yes it will work for 2005 (CLR 2), I am doing it in my work.
This command:

REGASM myassem.dll /tlb:com.myassem.tlb

Will create the correct entries in the registry for COM clients to
locate and instantiate your objects. I don't bother with the GAC for
what I need to do. So I just

1. Copy my assembly dll into a dir on the target machine.
2. Run REGASM on my assembly, as above.
3. Use the tlb that is created (I am accessing my assembly via Excel)
so I just go in to Tools->References and browse for the tlb.

That's it, all that is needed. I am doing it with a batch file at the
moment but you could write an installer if you want to.
 
J

Janiv Ratson

Thanks Phil.
This is a guide for VS 2003, will it fit VS2005?
Is there an updated guide for VS2005?
I did not understand the deployment part.
What COM file should I deploy to my users?
How do I register the COM on users machines?
Thanks again,
J.
 
J

Janiv Ratson

Thanks for your help.
I'm trying to do what you have suggested. It doesn't work for me.
I have few major problem:
Using VS2005 the classes are generated but the methods are not.
when i import the tlb file to my MFC project, I can see in the created tlh
file my interface and its method but the concrete class is empty (no
methods).
I compile my C# project on one machine using VS2005, and runs my MFC
application on another machine running VS2003.
Another problem I have, is that I always get class not registered on my MFC
(VS2003) machine (the VS2005 is on a different macine).
The code I use for the implementation is:
ActivationWizardLib::_NewActivationPtr
p(__uuidof(ActivationWizardLib::NewSupernaActivation));

The command I use to register the dll file:
regasm ActivationWizardLib.dll /tlb:ActivationWizardLib.tlb

the class I'm defining in my C# project is:
public interface _NewActivation
{
int Enable();
}

public class NewSupernaActivation : _NewActivation
{
public NewSupernaActivation()
{

}

public int Enable()
{
return 2;
}
};

Thanks for the help.
J.
 

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