"Ricky" <spam@spam.co m> wrote in message
news:OwMuyTzlEH A.2864@TK2MSFTN GP14.phx.gbl...[color=blue]
> Hi
>
> I know that we can call C++ code from C# using COM interop, how about do
> the reverse?
>
> Ricky[/color]
"Ricky" <spam@spam.co m> wrote in message
news:OwMuyTzlEH A.2864@TK2MSFTN GP14.phx.gbl...[color=blue]
> Hi
>
> I know that we can call C++ code from C# using COM interop, how about do
> the reverse?
>
> Ricky[/color]
Yes, you can expose C# classes as a COM classes.
However, you have to respect some basic rules and preferably set some
attributes for this to work correctly, you also have to explicitly "register
the assembly for COM interop" [1].
For details, check the "COM interop tutorials" in the C# programmers
reference" on MSDN.
Willy.
[1] Windows XP SP2 offers a "registrati on free COM interop" facility.
"Ricky" <spam@spam.co m> wrote in message
news:OwMuyTzlEH A.2864@TK2MSFTN GP14.phx.gbl...[color=blue]
> Hi
>
> I know that we can call C++ code from C# using COM interop, how about do
> the reverse?
>
> Ricky[/color]
Yes, you can expose C# classes as a COM classes.
However, you have to respect some basic rules and preferably set some
attributes for this to work correctly, you also have to explicitly "register
the assembly for COM interop" [1].
For details, check the "COM interop tutorials" in the C# programmers
reference" on MSDN.
Willy.
[1] Windows XP SP2 offers a "registrati on free COM interop" facility.
"Ricky" <spam@spam.co m> wrote in message
news:OwMuyTzlEH A.2864@TK2MSFTN GP14.phx.gbl...[color=blue]
> Hi
>
> I know that we can call C++ code from C# using COM interop, how about do
> the reverse?
>
> Ricky[/color]
Nicholas Paldino [.NET/C# MVP] wrote:[color=blue]
> Ricky,
>
> If you want to call a COM component from .NET, you just have to add a
> reference to it in your VS.NET project (go to "Add References").
>
> If you were working from the command line, you would run the TLBIMP
> utility to generate a Runtime Callable Wrapper, and then set a reference to
> that.
>
> You can also call C++ code through the P/Invoke layer, if the C++ code
> exposes functions through a DLL.
>
> Or, finally, you can wrap the C++ code in a managed wrapper (using
> Managed Extensions for C++) and then call it like a normal assembly.
>
> Hope this helps.
>
>[/color]
Nicholas Paldino [.NET/C# MVP] wrote:[color=blue]
> Ricky,
>
> If you want to call a COM component from .NET, you just have to add a
> reference to it in your VS.NET project (go to "Add References").
>
> If you were working from the command line, you would run the TLBIMP
> utility to generate a Runtime Callable Wrapper, and then set a reference to
> that.
>
> You can also call C++ code through the P/Invoke layer, if the C++ code
> exposes functions through a DLL.
>
> Or, finally, you can wrap the C++ code in a managed wrapper (using
> Managed Extensions for C++) and then call it like a normal assembly.
>
> Hope this helps.
>
>[/color]
Yes, it is. You can export your .NET types to COM using the TLBEXP
tool, which will generate a type library for your .NET types.
However, going from .NET to COM is a little tricker than the other way
around. Before doing this, you should read the section of the .NET
framework documentation titled "", located at (watch for line wrap):
"Ricky" <spam@spam.co m> wrote in message
news:eWLJ7pzlEH A.3712@TK2MSFTN GP15.phx.gbl...[color=blue]
> Hi
>
> Sorry, I mean call C# from C++, not C++ from C#.
>
>
> Ricky
>
> Nicholas Paldino [.NET/C# MVP] wrote:[color=green]
>> Ricky,
>>
>> If you want to call a COM component from .NET, you just have to add a
>> reference to it in your VS.NET project (go to "Add References").
>>
>> If you were working from the command line, you would run the TLBIMP
>> utility to generate a Runtime Callable Wrapper, and then set a reference
>> to that.
>>
>> You can also call C++ code through the P/Invoke layer, if the C++
>> code exposes functions through a DLL.
>>
>> Or, finally, you can wrap the C++ code in a managed wrapper (using
>> Managed Extensions for C++) and then call it like a normal assembly.
>>
>> Hope this helps.
>>[/color][/color]
Yes, it is. You can export your .NET types to COM using the TLBEXP
tool, which will generate a type library for your .NET types.
However, going from .NET to COM is a little tricker than the other way
around. Before doing this, you should read the section of the .NET
framework documentation titled "", located at (watch for line wrap):
"Ricky" <spam@spam.co m> wrote in message
news:eWLJ7pzlEH A.3712@TK2MSFTN GP15.phx.gbl...[color=blue]
> Hi
>
> Sorry, I mean call C# from C++, not C++ from C#.
>
>
> Ricky
>
> Nicholas Paldino [.NET/C# MVP] wrote:[color=green]
>> Ricky,
>>
>> If you want to call a COM component from .NET, you just have to add a
>> reference to it in your VS.NET project (go to "Add References").
>>
>> If you were working from the command line, you would run the TLBIMP
>> utility to generate a Runtime Callable Wrapper, and then set a reference
>> to that.
>>
>> You can also call C++ code through the P/Invoke layer, if the C++
>> code exposes functions through a DLL.
>>
>> Or, finally, you can wrap the C++ code in a managed wrapper (using
>> Managed Extensions for C++) and then call it like a normal assembly.
>>
>> Hope this helps.
>>[/color][/color]
"Ricky" <spam@spam.co m> wrote in message
news:eWLJ7pzlEH A.3712@TK2MSFTN GP15.phx.gbl...[color=blue]
> Hi
>
> Sorry, I mean call C# from C++, not C++ from C#.
>
>
> Ricky
>
> Nicholas Paldino [.NET/C# MVP] wrote:[color=green]
>> Ricky,
>>
>> If you want to call a COM component from .NET, you just have to add a
>> reference to it in your VS.NET project (go to "Add References").
>>
>> If you were working from the command line, you would run the TLBIMP
>> utility to generate a Runtime Callable Wrapper, and then set a reference
>> to that.
>>
>> You can also call C++ code through the P/Invoke layer, if the C++
>> code exposes functions through a DLL.
>>
>> Or, finally, you can wrap the C++ code in a managed wrapper (using
>> Managed Extensions for C++) and then call it like a normal assembly.
>>
>> Hope this helps.
>>[/color][/color]
"Ricky" <spam@spam.co m> wrote in message
news:eWLJ7pzlEH A.3712@TK2MSFTN GP15.phx.gbl...[color=blue]
> Hi
>
> Sorry, I mean call C# from C++, not C++ from C#.
>
>
> Ricky
>
> Nicholas Paldino [.NET/C# MVP] wrote:[color=green]
>> Ricky,
>>
>> If you want to call a COM component from .NET, you just have to add a
>> reference to it in your VS.NET project (go to "Add References").
>>
>> If you were working from the command line, you would run the TLBIMP
>> utility to generate a Runtime Callable Wrapper, and then set a reference
>> to that.
>>
>> You can also call C++ code through the P/Invoke layer, if the C++
>> code exposes functions through a DLL.
>>
>> Or, finally, you can wrap the C++ code in a managed wrapper (using
>> Managed Extensions for C++) and then call it like a normal assembly.
>>
>> Hope this helps.
>>[/color][/color]
Nicholas Paldino [.NET/C# MVP] wrote:[color=blue]
> Oops, it would help if I gave the title and the link:
>
> Qualifying .NET Types for Interoperation
>
> http://msdn.microsoft.com/library/de...roperation.asp
>
>[/color]
Nicholas Paldino [.NET/C# MVP] wrote:[color=blue]
> Oops, it would help if I gave the title and the link:
>
> Qualifying .NET Types for Interoperation
>
> http://msdn.microsoft.com/library/de...roperation.asp
>
>[/color]
Comment