473,409 Members | 1,970 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,409 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 1637
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: 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
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: 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
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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,...
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...

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.