473,385 Members | 1,546 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,385 software developers and data experts.

Is it possible to have two Main() in one solution?

ano
Hi,

I'm a C# newbie. My application (Solution) contains two Windows application
projects. They create their own ".exe" output that means there are 2 Main()
methods in one solution.

Is is possible to do this? If it's possible, how Project A (A.exe) calls
Project B to start (B.exe) application?

I can't add a project reference in Project A to call Project B because
Project B doesn't contains .dll.

Thanks,
Mar 30 '06 #1
11 2163
You can use the Process.Start method to run B.exe from A.exe

http://msdn.microsoft.com/library/de...tarttopic3.asp
ano wrote:
Hi,

I'm a C# newbie. My application (Solution) contains two Windows application
projects. They create their own ".exe" output that means there are 2 Main()
methods in one solution.

Is is possible to do this? If it's possible, how Project A (A.exe) calls
Project B to start (B.exe) application?

I can't add a project reference in Project A to call Project B because
Project B doesn't contains .dll.

Thanks,


Mar 30 '06 #2
ano
Sorry I didn't mean to run B.exe by using Process.Start.
I mean how to call Project B: Application.Run() in Project A.

thanks.

"ad*********@gmail.com" wrote:
You can use the Process.Start method to run B.exe from A.exe

http://msdn.microsoft.com/library/de...tarttopic3.asp
ano wrote:
Hi,

I'm a C# newbie. My application (Solution) contains two Windows application
projects. They create their own ".exe" output that means there are 2 Main()
methods in one solution.

Is is possible to do this? If it's possible, how Project A (A.exe) calls
Project B to start (B.exe) application?

I can't add a project reference in Project A to call Project B because
Project B doesn't contains .dll.

Thanks,


Mar 30 '06 #3
Hi,

You cannot.

You have a solution with two separate executables. They live endependently
one of the other. If you want to start running an instance of one from the
other you have to use Process.Start.
Otherwise, why you want to run B.App_Run ?
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"ano" <an*@discussions.microsoft.com> wrote in message
news:BE**********************************@microsof t.com...
Sorry I didn't mean to run B.exe by using Process.Start.
I mean how to call Project B: Application.Run() in Project A.

thanks.

"ad*********@gmail.com" wrote:
You can use the Process.Start method to run B.exe from A.exe

http://msdn.microsoft.com/library/de...tarttopic3.asp
ano wrote:
> Hi,
>
> I'm a C# newbie. My application (Solution) contains two Windows
> application
> projects. They create their own ".exe" output that means there are 2
> Main()
> methods in one solution.
>
> Is is possible to do this? If it's possible, how Project A (A.exe)
> calls
> Project B to start (B.exe) application?
>
> I can't add a project reference in Project A to call Project B because
> Project B doesn't contains .dll.
>
> Thanks,


Mar 30 '06 #4
> I'm a C# newbie. My application (Solution) contains two Windows application
projects. They create their own ".exe" output that means there are 2 Main()
methods in one solution.
Is is possible to do this?
Of course, that's the point of having "solutions"; grouping several EXEs and
DLLs together and managing their relationships.
If it's possible, how Project A (A.exe) calls
Project B to start (B.exe) application?
I don't see why you would want to, but see below if you do. What is it
you're trying to achieve? You probably don't even want to have two EXEs, if
the goal is perhaps A has a main form and B has a dialog that A needs to
pop-up, then B should be in a DLL rather than an EXE (it can still be its own
project if you like, I have some dialogs that I use with several forms) form
A would then instantiate and show it, there is no need to call a Main to show
the dialog.
I can't add a project reference in Project A to call Project B because
Project B doesn't contains .dll.


Of course you can, an EXE is an assembly.

-----

I did it with console EXEs, but it ought to work with WinForms as well.

1) Make sure the class for B is public and its Main is public
2) Add a reference to project B to project A
3) In A, use: classB.Main ( args ) ;
Mar 30 '06 #5
ano
Thanks PIEBALD.

Now I can call B.Main(). But I need to change the output type to Class
Library otherwise I can't add a reference.

"PIEBALD" wrote:
I'm a C# newbie. My application (Solution) contains two Windows application
projects. They create their own ".exe" output that means there are 2 Main()
methods in one solution.
Is is possible to do this?


Of course, that's the point of having "solutions"; grouping several EXEs and
DLLs together and managing their relationships.
If it's possible, how Project A (A.exe) calls
Project B to start (B.exe) application?


I don't see why you would want to, but see below if you do. What is it
you're trying to achieve? You probably don't even want to have two EXEs, if
the goal is perhaps A has a main form and B has a dialog that A needs to
pop-up, then B should be in a DLL rather than an EXE (it can still be its own
project if you like, I have some dialogs that I use with several forms) form
A would then instantiate and show it, there is no need to call a Main to show
the dialog.
I can't add a project reference in Project A to call Project B because
Project B doesn't contains .dll.


Of course you can, an EXE is an assembly.

-----

I did it with console EXEs, but it ought to work with WinForms as well.

1) Make sure the class for B is public and its Main is public
2) Add a reference to project B to project A
3) In A, use: classB.Main ( args ) ;

Mar 30 '06 #6
> Now I can call B.Main(). But I need to change the output type to Class
Library otherwise I can't add a reference.


No you don't. You can add a reference to an assembly that's in an EXE.
May 15 '06 #7
>> No you don't. You can add a reference to an assembly that's in an EXE.

I believe what he is saying is that the Right-Click "Add reference"
feature on Visual Studio will refuse to add the reference until the
assembly has a DLL extension.

May 15 '06 #8
> I believe what he is saying is that the Right-Click "Add reference"
feature on Visual Studio will refuse to add the reference until the
assembly has a DLL extension.


The EXE projects in my solution show up as available for reference from the
other projects.
May 15 '06 #9
I think that is a 2.0 feature IIRC.

--
William Stacey [MVP]

"PIEBALD" <PI*****@discussions.microsoft.com> wrote in message
news:AA**********************************@microsof t.com...
|> I believe what he is saying is that the Right-Click "Add reference"
| > feature on Visual Studio will refuse to add the reference until the
| > assembly has a DLL extension.
|
| The EXE projects in my solution show up as available for reference from
the
| other projects.
May 16 '06 #10
William Stacey [MVP] <wi************@gmail.com> wrote:
I think that is a 2.0 feature IIRC.


Well, it's a Visual Studio 2005 feature. Even in .NET 1.1 you can get
the command-line compiler to add a reference to an executable, but to
get it to work in VS.NET 2003 you have to hack the project file a bit.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
May 16 '06 #11
>>> The EXE projects in my solution show up as available for reference from the other projects. <<<

But if you try adding it (in VS2003), it will give an error.

May 16 '06 #12

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

Similar topics

9
by: sojin | last post by:
#include<stdio.h> void change() { /* Write something in this function so that the output of printf in main function should give 5 . Do not change the main function */ } void main() {
20
by: alainpoint | last post by:
Hi I wonder if Python is capable of the following: define a function which returns its argument. I mean: def magic_function(arg): ...... some magic code ... that behaves the following way:
27
by: susiedba | last post by:
when you guys have a solution for _ALL_ of those scenarios is when I stop VB 2005 doesn't support code reuse or portability I want to know what I am supposed to do.. am I really still supposed...
4
by: plowgrammer2010 | last post by:
Hi All, I am trying to get Form keydown event in compact framework 3.5 but event is not triggering. I have just one form form1. Public Class Form1 Dim oBinarySave As New...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
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...
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
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.