Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have application developed in VS 2010.
In that, I have two projects under one solution in VS 2010.
I want to call another projects sub main from main projects sub main() which executes first.
How to do that ?
whether I have to make an object for that sub main () ?
Posted

1 solution

You don't understand something: "which executes first"… No!

You cannot run two processes and call each others function (I do not consider remote procedure calls which are strictly speaking not calls). Also, when it comes to run time, you should speak of assemblies, not projects. Project is a compile-time notion and can be anything.

So, you can call a method of one assembly by other assembly, but only one of the assembly should start the application and the process. It is called entry assembly (usually *.exe files). All other assemblies should be libraries (usually *.dll, but can be anything, even *.exe; the only important things is it is not started as a process; it can be started like a process, but in this case it would be completely different process).

So, the library assembly should make the method to be called public, as well as the declaring types. (I use plural for "types" because classes and structures can be nested.)

In calling assembly project, on its "References" mode, use "Add references". As both assemblies are already in the same solution, prefer "Project". In this way, you will be presented a choice of projects from the same solutions. It will also setup solution's project dependency automatically.

—SA
 
Share this answer
 
Comments
Albin Abel 17-May-11 6:42am    
My 5
Sergey Alexandrovich Kryukov 17-May-11 15:33pm    
Thank you, Albin.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900