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.

Re: Form to COM by Phil

Phil
Tue Aug 15 09:28:44 CDT 2006

On Tue, 15 Aug 2006 15:44:41 +0200, "Janiv Ratson" <janivr@gmailcom>
wrote:

>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.
>
>

I have followed these guidelines with success.

http://www.15seconds.com/issue/040721.htm



--
Phil

Re: Form to COM by Janiv

Janiv
Thu Aug 17 04:24:39 CDT 2006

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.

"Phil" <foo@foo.com> wrote in message
news:qfm3e2d8vesfsk38q4sgqkk1jk836risnb@4ax.com...
> On Tue, 15 Aug 2006 15:44:41 +0200, "Janiv Ratson" <janivr@gmailcom>
> wrote:
>
>>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.
>>
>>
>
> I have followed these guidelines with success.
>
> http://www.15seconds.com/issue/040721.htm
>
>
>
> --
> Phil



Re: Form to COM by Phil

Phil
Thu Aug 17 03:42:17 CDT 2006

On Thu, 17 Aug 2006 11:24:39 +0200, "Janiv Ratson" <janivr@gmailcom>
wrote:

>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.
>
>"Phil" <foo@foo.com> wrote in message
>news:qfm3e2d8vesfsk38q4sgqkk1jk836risnb@4ax.com...
>> On Tue, 15 Aug 2006 15:44:41 +0200, "Janiv Ratson" <janivr@gmailcom>
>> wrote:
>>
>>>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.
>>>
>>>
>>
>> I have followed these guidelines with success.
>>
>> http://www.15seconds.com/issue/040721.htm
>>
>>
>>
>> --
>> Phil
>

--
Phil

Re: Form to COM by Janiv

Janiv
Thu Aug 17 05:33:57 CDT 2006

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.



"Phil" <foo@foo.com> wrote in message
news:loa8e2538vjaj9bt0pdmeahifokscnj3ot@4ax.com...
> On Thu, 17 Aug 2006 11:24:39 +0200, "Janiv Ratson" <janivr@gmailcom>
> wrote:
>
>>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.
>>
>>"Phil" <foo@foo.com> wrote in message
>>news:qfm3e2d8vesfsk38q4sgqkk1jk836risnb@4ax.com...
>>> On Tue, 15 Aug 2006 15:44:41 +0200, "Janiv Ratson" <janivr@gmailcom>
>>> wrote:
>>>
>>>>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.
>>>>
>>>>
>>>
>>> I have followed these guidelines with success.
>>>
>>> http://www.15seconds.com/issue/040721.htm
>>>
>>>
>>>
>>> --
>>> Phil
>>
>
> --
> Phil