Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by mrvcmrvc · Oct 23, 2014 at 03:04 PM · c#eventsexecutable

System.Diagnostics.Process.Exited not firing in executable

Hi, i am using system.diagnostics.process to create and start a unity project in batchmode. I have everything working great. I am calling unity.exe in process with some arguments like, -batchMode, -quit, and -logFile. When i start app in unity editor, process creates a project, then process.Exited fires, then another process puts some files and starts the project in batchMode.

My problem is that when i build this app, and start its executable, the process again creates the project however it does not fires exited event, eventually other steps wont begin due to first process not firing exited event. I do not know why System.Diagnostics.Process.Exited is not firing when builded. I could not find any solution, so i am asking the reason for it in here.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by pbVax · Dec 08, 2014 at 09:02 PM

I just encountered this problem myself, and discovered a solution: In your "Build Settings", under the "Other Settings" section, set your "Api Compatibility Level" to ".NET 2.0".

My guess is that Unity Editor is uses .NET 2.0 when you run your program, but when you execute your program separately, the ".NET 2.0 Subnet" doesn't support the Exited functionality.

I suspect this solution will work only under Windows. :)

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image lavos2300 · Jun 09, 2016 at 09:33 AM 1
Share

This is the correct answer.

avatar image DoofDilla · Feb 24, 2018 at 06:23 PM 0
Share

2018, worked for me while using ffmpeg, thanks for this, saved me alot of time

avatar image demilp · Dec 12, 2018 at 07:43 PM 0
Share

Works like a charm

avatar image
1

Answer by Landern · Oct 23, 2014 at 03:06 PM

Not sharing the Process object instantiation isn't helping.

Have you set EnableRaisingEvents on the Process object to true? If it is not set, it will not raise the Exited event amongst others.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mrvcmrvc · Oct 23, 2014 at 03:41 PM 0
Share
         string strCmdText = " -batch$$anonymous$$ode -quit -createProject \"" + projectPath + "\" -logFile \"" + Application.dataPath + "/createProjectLogFile.txt\" ";

         ProcessStartInfo startInfo = new ProcessStartInfo();
         startInfo.UseShellExecute = false;
         startInfo.FileName = @"C:\Program Files (x86)\Unity\Editor\Unity.exe";
         startInfo.Arguments = strCmdText;

         Process process = new Process();
         process.EnableRaisingEvents = true;
         process.Exited += new EventHandler(CreateProjectFinished);
         process.StartInfo = startInfo;
         process.Start();

 void CreateProjectFinished(object sender, EventArgs e)
 {
     isProjectCreated = true;
 }

Yes, i have enabled it, i am checking if isProjectFinished becomes true in Update method. But, it never becomes true.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Question about unsubscribing eventhandlers OnDisable and OnEnable 2 Answers

Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer

Execute method from unknown script set as variable in inspector 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges