Reputation: 5133
I've made a WPF application based on .NET framework 4. This application will be copied to a pendrive, and the client will have to run it from there.
In order to check if the client has Framework 4 installed, I've made a batch file that read the output of "clrver.exe", and if the framework 4 is installed it runs the application using the command START "application path"
The problem is that few seconds after the WPF application is running it crashes.
So I've tried to make a C# Console application, just to check, and using Process.Start() I've started the WPF application. The behaviour is exactly the same.
If I try to run the WPF application by clicking directly on the executable it runs perfectly. If I try to run it from a console, it crashes after few seconds (5~6 seconds).
Does anyone know the reason or an idea on how to run it?
Upvotes: 0
Views: 1059
Reputation: 5133
The problem was dued by the working directory that cause some problem when the application is launched by a console application or a batch file.
I've solved replacing all relative paths in my code with absolute paths retrieved at runtime with: System.AppDomain.CurrentDomain.BaseDirectory
Upvotes: 1