Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi..

I have a very simple problem tht needs attention. I have 2 .net projects pro1, pro2. Now in pro1 I have a menu "connect" where I wish to execute the output of pro2 and I choose the pro2.exe and paste it in the pro1 folder and from pro1 i add reference and I call the .exe by Process.Start("Pro2.exe"). Now its running fine when pro1 is debugged. BUT it only runs for 1 time and for any other time it shows an win32 exception. Or if there is any state change(like if I open a file in the editor of any state change) then its giving exceptions. What may go wrong?
Posted
Updated 28-Feb-11 4:21am
v2
Comments
#realJSOP 28-Feb-11 10:22am    
What exception are you getting? Which application is throwing the exception, Pro1 or Pro2?
Supratik sadhuka 28-Feb-11 10:31am    
"Win32Exception: The system cannot find the file specified"
the debugging thing shows error on the line

private void ReceivefilemenuItem3_Click(object sender, EventArgs e)
{
Process myProc;
myProc = Process.Start("pro2.exe");<-------this line is showing the error

}
Sergey Alexandrovich Kryukov 28-Feb-11 10:56am    
More detail, please. See my answer. Are you able to run second instance manually (through Shell) when first instance run from pro2.exe is already running?
Please explain why and how are you doing that.
--SA
Supratik sadhuka 28-Feb-11 11:11am    
Thnx for your answere and your interest in my question...
See its like i have 2 projects and i want to integrate them like the when i click on a menu in a form of project1 i am directed to a form of project 2..this is what i want to do actualy...

1 solution

It seems to me the major problem is running the second instance of the process started by running pro2.exe. There can be many reasons for that as you did not provide enough detail, but this is very usual, especially when you try to organize inter-process communication between processes: many ways of doing that imply uniqueness of one of the participating process.

For experimental purpose, try to terminate first instance — you have access to the instance of the started Process returned by Process.Start, so you can use Process.Kill.

I cannot tell you how to "fix" this problem, because this is not a problem unless you share the purpose of all this activity. What you're trying to do is very weird and usually are not done at all. If you want to have a host process which is able to "run" dynamically code of other .NET assemblies playing the role of plug-ins or "applications" using their executable files, you're not using right way. You don't have to run then in different process. You can run them in the same process (albeit possibly in a separate thread) if you load assembly dynamically using System.Reflection.Assembly. If you need to do in more than once, you should load it in a new Application Domain (see System.AppDomain), because you can unload AppDomain, but there is no a way to unload assembly from the process. Again, I'll no more exactly what to do, is you explain your purpose in detail.

Sorry if this did not answer your question. In this case, you need to provide more information. Please show the code of starting the process and getting its "output" (as well as all other ways you're trying to use to communicate between processes). Catch exception you got, make a full dump (including its stack and all inner exceptions, recursively), save the dump in file and post in in your question.

Important! Do not post your follow-up information as Answer. Use "Improve question" or "Add comment" instead.

—SA
 
Share this answer
 
Comments
Supratik sadhuka 28-Feb-11 11:12am    
Thnx for your answere and your interest in my question...
See its like i have 2 projects and i want to integrate them like the when i click on a menu in a form of project1 i am directed to a form of project 2..this is what i want to do actualy...so what do i do...
Sergey Alexandrovich Kryukov 1-Mar-11 3:26am    
First, do you have source code for both or not? Is "pro2.exe" .NET assembly or not?

Please, answer my other questions above. I think I'll be able to offer you something better than what you're trying to do.

--SA
Supratik sadhuka 1-Mar-11 7:39am    
thanx i have been able to do it..here it is how

1.paste the source folder of the project2 in project1
2.from project1 file->add->new project
then select project2
3.from the assemble you also have 2 select the project2 from projects tab
4.now project2 is attached into my project1...so just make a object by
project2.form1 obj=new project2.form1();
obj.show();
done..
Thanx for all those who helped
Sergey Alexandrovich Kryukov 1-Mar-11 14:36pm    
It does not seem reasonable.
What did you want to do with those projects and why? You never explained.
--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