简体   繁体   中英

Running same C# application twice

The application is a form application and it is too complicated. It is mostly used to connect to a database with an user interface. It also uses third party dlls.

I copied my VS C# application`s bin folder to my desktop.

"C:\\Users\\asd\\Desktop\\bin"

After that, I made some changes in my solution and building it, I again copied the application`s bin file under C:\\;

"C:\\bin"

Now when I run "C:\\Users\\asd\\Desktop\\bin\\Debug\\LIVE.exe" and let it remain open I can`t run "C:\\bin\\Debug\\LIVE.exe" . There is no error when I try to open the second .exe file. It simply does nothing.

I want both of the applications to be open at the same time.

Depending on the application, there are ways to prevent execution of a second instance (I have actually implemented the described behaviour in production code) so check the production specs of the application to see if that's a desired behaviour on client machines.

Because it's using a database connection and third party DLLs, there may be other specific limitations in place preventing proper execution, so check whether any exceptions are being cuaght by hooking into the FirstChanceException (WARNING: Never use this code outside a debug context!)

#if DEBUG
static Program()
{
    AppDomain.CurrentDomain.FirstChanceException += (sender, e) => { };
}
#endif

Insert this into your Program class, or whichever class houses the Main method (and rename it if it's not Program of course) and then breakpoint the opening of the handler - this will often catch lots of exceptions you're better off not worrying about, but it may also clue you in if there is a problem keeping your code from starting.

As always, make sure to run this from within VS's Debug, so as to see any exceptions as they occur.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM