C++ Calling a C# method

  • Thread starter Thread starter fatemah.aldouli
  • Start date Start date
F

fatemah.aldouli

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.
 
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)
 
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.
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top