473,395 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

C++ Calling a C# method

Hi,
I am new to C# (and not an expert in C++). I am trying to use a C++
program to call a C# windows application (to be specific the Main()
method of the C# application). What should I do? Somebody else created
the C# app...and I am just trying to use it.
I am thinking about adding a C++ win32 project to the solution (where
the C# app exists) and somehow link the C# application, which is not a
DLL, to the C++ one. I just do not know how!

If you have done this before, or done something similar, or think that
this is doable please help! I spent A LOT of time searching online, but
almost everybody wants to call C++ functions/dll in a C# app...not the
other way around, which is what I am trying to do. Please help.
Thanks.

P.S. If this is not the right group to post such question, please
direct me to one. Thanks.

Nov 17 '06 #1
3 1636
If you just want to fire the C# applicaiton then just start the exe from the
C++ application using System.Diagnostics.Process.Start("app.exe")

If you want a reference to the C# app from the C++ app, you will have to
convert the C# app to a dll and then add a reference to it in the C++ app.

Hope that helps.

--
Good luck!

Shailen Sukul
Architect
(BSc MCTS, MCSD.Net MCSD MCAD)
Ashlen Consulting Service P/L
(http://www.ashlen.net.au)
"fa*************@gmail.com" wrote:
Hi,
I am new to C# (and not an expert in C++). I am trying to use a C++
program to call a C# windows application (to be specific the Main()
method of the C# application). What should I do? Somebody else created
the C# app...and I am just trying to use it.
I am thinking about adding a C++ win32 project to the solution (where
the C# app exists) and somehow link the C# application, which is not a
DLL, to the C++ one. I just do not know how!

If you have done this before, or done something similar, or think that
this is doable please help! I spent A LOT of time searching online, but
almost everybody wants to call C++ functions/dll in a C# app...not the
other way around, which is what I am trying to do. Please help.
Thanks.

P.S. If this is not the right group to post such question, please
direct me to one. Thanks.

Nov 17 '06 #2
Shailen, thanks for your reply.

What I want to do is call some methods in the C# application (from the
C++ one).I looked under the C# application directory and did not find a
..dll file for the application. If I still need to convert the C# app to
a dll, can I do that w/o changing the code itself (I am referring to an
option some software packages offer..."create an executable" or "create
a dll")? I guess what I am trying to ask is how do I convert the C#
windows application to a DLL. As you can teell, I am very not very
familiar with the Microsoft visual studio C++ IDE.

Thanks.

Shailen Sukul wrote:
If you just want to fire the C# applicaiton then just start the exe from the
C++ application using System.Diagnostics.Process.Start("app.exe")

If you want a reference to the C# app from the C++ app, you will have to
convert the C# app to a dll and then add a reference to it in the C++ app.

Hope that helps.

--
Good luck!

Shailen Sukul
Architect
(BSc MCTS, MCSD.Net MCSD MCAD)
Ashlen Consulting Service P/L
(http://www.ashlen.net.au)
"fa*************@gmail.com" wrote:
Hi,
I am new to C# (and not an expert in C++). I am trying to use a C++
program to call a C# windows application (to be specific the Main()
method of the C# application). What should I do? Somebody else created
the C# app...and I am just trying to use it.
I am thinking about adding a C++ win32 project to the solution (where
the C# app exists) and somehow link the C# application, which is not a
DLL, to the C++ one. I just do not know how!

If you have done this before, or done something similar, or think that
this is doable please help! I spent A LOT of time searching online, but
almost everybody wants to call C++ functions/dll in a C# app...not the
other way around, which is what I am trying to do. Please help.
Thanks.

P.S. If this is not the right group to post such question, please
direct me to one. Thanks.
Nov 17 '06 #3
To convert a windows forms project to a dll go to project properties and
change the output type from Windows Application to Class Library and then
recompile your application.

HTH.
--
Good luck!

Shailen Sukul
Architect
(BSc MCTS, MCSD.Net MCSD MCAD)
Ashlen Consulting Service P/L
(http://www.ashlen.net.au)
"fa*************@gmail.com" wrote:
Shailen, thanks for your reply.

What I want to do is call some methods in the C# application (from the
C++ one).I looked under the C# application directory and did not find a
..dll file for the application. If I still need to convert the C# app to
a dll, can I do that w/o changing the code itself (I am referring to an
option some software packages offer..."create an executable" or "create
a dll")? I guess what I am trying to ask is how do I convert the C#
windows application to a DLL. As you can teell, I am very not very
familiar with the Microsoft visual studio C++ IDE.

Thanks.

Shailen Sukul wrote:
If you just want to fire the C# applicaiton then just start the exe from the
C++ application using System.Diagnostics.Process.Start("app.exe")

If you want a reference to the C# app from the C++ app, you will have to
convert the C# app to a dll and then add a reference to it in the C++ app.

Hope that helps.

--
Good luck!

Shailen Sukul
Architect
(BSc MCTS, MCSD.Net MCSD MCAD)
Ashlen Consulting Service P/L
(http://www.ashlen.net.au)
"fa*************@gmail.com" wrote:
Hi,
I am new to C# (and not an expert in C++). I am trying to use a C++
program to call a C# windows application (to be specific the Main()
method of the C# application). What should I do? Somebody else created
the C# app...and I am just trying to use it.
I am thinking about adding a C++ win32 project to the solution (where
the C# app exists) and somehow link the C# application, which is not a
DLL, to the C++ one. I just do not know how!
>
If you have done this before, or done something similar, or think that
this is doable please help! I spent A LOT of time searching online, but
almost everybody wants to call C++ functions/dll in a C# app...not the
other way around, which is what I am trying to do. Please help.
Thanks.
>
P.S. If this is not the right group to post such question, please
direct me to one. Thanks.
>
>

Nov 17 '06 #4

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

Similar topics

5
by: Chris | last post by:
Hi I have a scenario where I've created another AppDomain to dynamically load a DLL(s) into. In this newly loaded DLL I want to call a static method on a class. The problem arise is that I have...
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: Dave Veeneman | last post by:
I'm using inheritance more than I used to, and I find myself calling a lot of base class methods. I generally call a base method from a dreived class like this: this.MyMethod(); I'm finding...
7
by: JJ | last post by:
Hi, I call a class in my windows service app and in that class I access a method that returns an OleDbReader. Now It does have records in the reader when I step through the method but when I...
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...
12
by: Ron | last post by:
Greetings, I am trying to understand the rational for Raising Events instead of just calling a sub. Could someone explain the difference between the following 2 scenarios? Why would I want to...
5
by: joeblast | last post by:
I have a Web service that gets the financial periods and hold a reference to a disconnected dataset built at initialization. Web methods work on the dataset inside the web service. Everything is...
6
by: Mirek Endys | last post by:
Hello all, another problem im solving right now. I badly need to get typeof object that called static method in base classe. I did it by parameter in method Load, but i thing there should be...
15
by: =?Utf-8?B?VG9tIENvcmNvcmFu?= | last post by:
I've been led to believe by several articles, particularly Eric Gunnerson's C# Calling Code Dynamically, that calling a method dynamically through Reflection was much slower than through a...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
jinu1996
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.