Hi
I know that we can call C++ code from C# using COM interop, how about do
the reverse?
Ricky 12 1923
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Ricky" <sp**@spam.com> wrote in message
news:Ow**************@TK2MSFTNGP14.phx.gbl... Hi
I know that we can call C++ code from C# using COM interop, how about do the reverse?
Ricky
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Ricky" <sp**@spam.com> wrote in message
news:Ow**************@TK2MSFTNGP14.phx.gbl... Hi
I know that we can call C++ code from C# using COM interop, how about do the reverse?
Ricky
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 "registration free COM interop" facility.
"Ricky" <sp**@spam.com> wrote in message
news:Ow**************@TK2MSFTNGP14.phx.gbl... Hi
I know that we can call C++ code from C# using COM interop, how about do the reverse?
Ricky
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 "registration free COM interop" facility.
"Ricky" <sp**@spam.com> wrote in message
news:Ow**************@TK2MSFTNGP14.phx.gbl... Hi
I know that we can call C++ code from C# using COM interop, how about do the reverse?
Ricky
Hi
Sorry, I mean call C# from C++, not C++ from C#.
Ricky
Nicholas Paldino [.NET/C# MVP] wrote: 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.
Hi
Sorry, I mean call C# from C++, not C++ from C#.
Ricky
Nicholas Paldino [.NET/C# MVP] wrote: 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.
Ricky,
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" <sp**@spam.com> wrote in message
news:eW**************@TK2MSFTNGP15.phx.gbl... Hi
Sorry, I mean call C# from C++, not C++ from C#.
Ricky
Nicholas Paldino [.NET/C# MVP] wrote: 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.
Ricky,
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" <sp**@spam.com> wrote in message
news:eW**************@TK2MSFTNGP15.phx.gbl... Hi
Sorry, I mean call C# from C++, not C++ from C#.
Ricky
Nicholas Paldino [.NET/C# MVP] wrote: 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.
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
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Ricky" <sp**@spam.com> wrote in message
news:eW**************@TK2MSFTNGP15.phx.gbl... Hi
Sorry, I mean call C# from C++, not C++ from C#.
Ricky
Nicholas Paldino [.NET/C# MVP] wrote: 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.
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
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Ricky" <sp**@spam.com> wrote in message
news:eW**************@TK2MSFTNGP15.phx.gbl... Hi
Sorry, I mean call C# from C++, not C++ from C#.
Ricky
Nicholas Paldino [.NET/C# MVP] wrote: 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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Pierre Rouleau |
last post by:
I have a GUI application written in Python (with WxPython) which uses
some low level classes also written in Python. These low level Python
classes are given a pointer to some GUI Python object. ...
|
by: Rennie deGraaf |
last post by:
The attached code compiles and works properly when I comment out the
declaration, definition, and invocations of the method 'eck'. With
"eck" in there, g++ fails with
ttest.cpp:23: template-id...
|
by: FrankS |
last post by:
Hi All,
I have a problem with an call-template cmd at xslt 1.0:
With: pCall = 'ExInput'
------
I try to:
<xsl:call-template name="{$pCall}">
<xsl:with-param name="pVal" select="$pValue"/>...
|
by: randy |
last post by:
Hello all,
I have a DataTable which I am building column by column and adding rows
after each new column. The DataTable columns match the columns in my
database table. I'm building the...
|
by: Hiroshi Ochi |
last post by:
Hello,
Is it possible to initialize javascript function parameters (using MSIE
6.0 and above)? According to the link below, it seems possible to do
this.
...
|
by: Arno R |
last post by:
Hi all,
Is the above possible?
I guess I need an API call for this ? How and where to find this?
One of my new apps is used as a sort of 'dedicated' thing.
Users see an empty desktop with...
|
by: Jack |
last post by:
Hello,
I have a 3-level class hirarchy:
1=Grandparent
2=Parent
3=Child
The Grandparent has a method called OnPaint which I want to override
from the Child class. I can do this, but how...
|
by: Arquitecto |
last post by:
Hi ,i would like to give u a piece of code and discuss if it is
possible to call the hidden_function without modify code to call it .
I have read on internet about buffer overflows and i can...
|
by: gnewsgroup |
last post by:
I know that we can re-use/share code by placing the code in App_Code.
But, is it possible for MyPage.aspx.cs to call a method defined in
AnotherPage.aspx.cs?
Suppose, in AnotherPage.aspx.cs,...
|
by: Simon |
last post by:
I heard that we could do that by using AJAX. Could anybody share how to do
it? Thanks.
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |