473,473 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Calling C# DLL from C



Hi,

Can u plz help me out with how to call a C# DLL from C...
I tried to find out by searching in net..but i couldnot find anything on
it....

Thanku
Virajitha

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
5 1761

"Virajitha Sarma" <vi**************@yahoo.com> wrote in message
news:uf**************@TK2MSFTNGP12.phx.gbl...


Hi,

Can u plz help me out with how to call a C# DLL from C...
I tried to find out by searching in net..but i couldnot find anything on
it....

Thanku
Virajitha

*** Sent via Developersdex http://www.developersdex.com ***


You have two main options, COM interop and managed wrapper classes using
Managed C++ (VS2003) (or VS2005 C++/CLI).

Check this URL for more info:
http://msdn2.microsoft.com/library/z...us,vs.80).aspx

Willy.
Nov 17 '05 #2
I believe there is a third option, hosting the CLR runtime. This
involves using COM to "load" the CLR runtime, but not to have the
particular assemblies "registered" like typical Active-X stuff.
Willy Denoyette [MVP] wrote:
You have two main options, COM interop and managed wrapper classes using
Managed C++ (VS2003) (or VS2005 C++/CLI).

Check this URL for more info:
http://msdn2.microsoft.com/library/z...us,vs.80).aspx

Willy.


--
Joel Lucsy
"The dinosaurs became extinct because they didn't have a space program."
-- Larry Niven
Nov 17 '05 #3

"Joel Lucsy" <jj*****@usol.com> wrote in message
news:eU*************@TK2MSFTNGP10.phx.gbl...
I believe there is a third option, hosting the CLR runtime. This involves
using COM to "load" the CLR runtime, but not to have the particular
assemblies "registered" like typical Active-X stuff.
Willy Denoyette [MVP] wrote:
You have two main options, COM interop and managed wrapper classes using
Managed C++ (VS2003) (or VS2005 C++/CLI).

Check this URL for more info:
http://msdn2.microsoft.com/library/z...us,vs.80).aspx

Willy.


--
Joel Lucsy
"The dinosaurs became extinct because they didn't have a space
program." -- Larry Niven


Well not really, when hosting the CLR, you still need to call managed code
through one of the interop layers be it COM or Managed thunks. True, you
don't need an IA in a COM interop scenarion you can dynamically create a
CCW, but it's not a trivial task though.
Willy.
Nov 17 '05 #4
Willy Denoyette [MVP] wrote:
"Joel Lucsy" <jj*****@usol.com> wrote in message
news:eU*************@TK2MSFTNGP10.phx.gbl...
I believe there is a third option, hosting the CLR runtime. This involves
using COM to "load" the CLR runtime, but not to have the particular
assemblies "registered" like typical Active-X stuff.

Well not really, when hosting the CLR, you still need to call managed code
through one of the interop layers be it COM or Managed thunks. True, you
don't need an IA in a COM interop scenarion you can dynamically create a
CCW, but it's not a trivial task though.
Willy.


Why would you need a CCW? The host uses COM to instantiate the CLR and
then uses those interfaces to call whichever managed code you want. To
call back into the host you could use P/Invoke just fine without having
a CCW around. Of course this method means you can't use classes defined
in the host, but this may not be a problem as it really depends on what
you're trying to accomplish. I've tested this technique just fine.

--
Joel Lucsy
"The dinosaurs became extinct because they didn't have a space program."
-- Larry Niven
Nov 17 '05 #5

"Joel Lucsy" <jj*****@usol.com> wrote in message
news:eK**************@TK2MSFTNGP09.phx.gbl...
Willy Denoyette [MVP] wrote:
"Joel Lucsy" <jj*****@usol.com> wrote in message
news:eU*************@TK2MSFTNGP10.phx.gbl...
I believe there is a third option, hosting the CLR runtime. This involves
using COM to "load" the CLR runtime, but not to have the particular
assemblies "registered" like typical Active-X stuff.

Well not really, when hosting the CLR, you still need to call managed
code through one of the interop layers be it COM or Managed thunks. True,
you don't need an IA in a COM interop scenarion you can dynamically
create a CCW, but it's not a trivial task though.
Willy.


Why would you need a CCW? The host uses COM to instantiate the CLR and
then uses those interfaces to call whichever managed code you want. To
call back into the host you could use P/Invoke just fine without having a
CCW around. Of course this method means you can't use classes defined in
the host, but this may not be a problem as it really depends on what
you're trying to accomplish. I've tested this technique just fine.

--
Joel Lucsy
"The dinosaurs became extinct because they didn't have a space
program." -- Larry Niven


Joel,

I 'm not 100% clear on what you mean here. The host instantiates the CLR
using the COM based hosting API's, that's right, but the CLR is unmanaged
code. And then you say; "then uses those interfaces to call whichever
managed code you want."
If you mean by this that you can use the hosting API's to load an assembly
and START executing this managed ( say C#) code by calling it's entry point,
then I agree, but this is not the same thing as a direct call into managed
objects methods from native code. This is simply not possible has you need a
Object reference in order to call managed methods, or you need a CCW that
translates the .NET object model into a COM interface model so that native
COM clients can create instances and call methods through COM interop, or
you need a wrapper class that thunks the native C++ object into a managed
interface.

Willy.

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Asapi | last post by:
1. Are linkage convention and calling convention referring to the same thing? 2. Does calling convention differ between languages C and C++? 3. How does calling convention differ between...
8
by: Muthu | last post by:
I've read calling conventions to be the order(reverse or forward) in which the parameters are being read & understood by compilers. For ex. the following function. int Add(int p1, int p2, int...
7
by: Klaus Friese | last post by:
Hi, i'm currently working on a plugin for Adobe InDesign and i have some problems with that. I'm not really a c++ guru, maybe somebody here has an idea how to solve this. The plugin is...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
3
by: Mike | last post by:
Timeout Calling Web Service I am calling a .NET 1.1 web service from an aspx page. The web service can take several minutes to complete its tasks before returning a message to the aspx page. ...
2
by: Geler | last post by:
A theoretical question: Sorry if its a beginner question. Here is a quote from the MSDN explaning the C/C++ calling convention.. It demonstrates that the calling function is responsible to clean...
47
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
10
by: sulekhasweety | last post by:
Hi, the following is the definition for calling convention ,which I have seen in a text book, can anyone give a more detailed explanation in terms of ANSI - C "the requirements that a...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.