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?
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
Related
I'm using the Desktop Bridge to create a Full-Trust UWP app so I can run cmd commands from my UWP app. I followed this tutorial and got everything working just fine. However I noticed that when closing the UWP or the trusted process (WinForms app in my case) or both the packaged project keeps running. The debug mode keeps running and I can see the process in my task manager. Is there something extra I have to do to avoid that?
Okay so it wasn't actually an issue. The app will stay running for 30 to 60 seconds then exit. I guess it's to save memory in case it gets launched right after closing. Don't quote me on that though.
I am entangled in how to work so that after I finish building the wpf app, I can give it to another computer by downloading the app (for example, downloading the .exe file). I also tried it, but when I ran the .exe file, it only showed a popup cmd and then disappeared. Then I have pulish with self-contanied deployment mode. Here is an image of the following files when I published at bin\release:
Path: C:\Users\ASUS\Source\Repos\UserService\WpfApp1\bin\Release\netcoreapp3.0\publish
If I run the .exe file in a folder then run normally. But when I copy it to a deskop and run it is still the same (can't run).
I want to ask how can I help my app to be used by other computers. Thank you mn! Forget more, my app is using .net core 3.0 already.
I have a Raspberry Pi v2 running Windows 10 IoT and am trying to run a dotnet 2.0 console application on it.
I have a powershell script start it on startup, but then I do not get the console output from it. I was wondering if there was a way to attach to the running process with powershell on my computer, like you would to a docker container, to get the console output.
I do not want to run my program on my computer, and the Raspberry Pi is the only computer I want to leave on overnight to run the program.
If you can't or don't want to re-start your Application
You are rather limited in this case, since, as stated in another SE Answer by Harry Johnston:
Windows does not provide any mechanism to retroactively give another
process a standard output handle if it was created without one.
(Besides, in most cases an application will check the standard output
handle only during startup.)
If you need to read something that already has been written to the Console, you are probably out of luck.
You should however be able to get any future output by attaching to the process with debugging tools.
In case of the Visual Studio Remote Debugger, this would even allow you to debug the execution of your Console Application, provided you wrote it.
An accepted answer on Superuser.com suggests that StraceNT is also capable of read the output of a running Console Application. This will probably be your best bet if the running Application wasn't written by yourself.
If the Application can be stopped and restarted
Powershell Remoting is probably the best way.
You would need to enable Powershell Remoting on your Raspberry Pi, and then you can use enter-pssession [RaspberryPi-Hostname-or-IP] in your local Powershell console to connect to your Raspberry Pi.
At that point you can just start your console application as if you were running it on your local machine and get all the console output you want.
No need to attach to anything.
You can redirect the output of your console app to a txt file in the current directory. If you run the console app from powershell you can do it like this:
.\[YOURAPP].exe | tee test.txt
And you can access the test.txt from Windows file sharing.
I have an not trivial task to do. I need to run website as a screensaver in windows 8. So I used next approach to achieve it:
http://www.codeproject.com/Articles/31376/Making-a-C-screensaver
The solution is working well when I run from the Visual studio or run a compiled .exe or .scr directly. But when I try to set the resulting .scr as a screensaver and try to push preview button in windows 8(on the same machine where the same .scr is running well) I get the error - "SHIM_NOVERSION_FOUND".
I found that this error can appear when required version of .NET framework is not installed, but it's not my case cause when I run directly that '.scr' it's working.
Thanks for any advance!
Problem has been solved, I've just put screensaver.scr to c:/temp folder and all started working, probably I didn't have some kind of rights to access screensaver from c:/windows/system32
I have an application that I am attempting to profile with CLRProfiler, written in .NET 4.0 and WPF running on the .NET Framework 4 Client Profile. The application loads a data file shortly after startup, the location to which is in app.config (so it is not selected interactively when the program is running). When the application is launched from Visual Studio or Windows Explorer, everything works fine.
When launching the application from CLRProfiler, however, the application crashes with an UnauthorizedAccessException attempting to load the file.
Attempting to fix the issue, I gave Full Control permissions to said file to myself, Domain Users, and Everyone yet the issue continues. When monitoring Task Manager, the short-lived process shows up has having been launched under my user ID.
Does anyone know how to resolve this issue with CLRProfiler?
Ultimately, this turned out to be a combination of two problems:
Not running as administrator.
The data file referenced above had a path specified in a configuration file, but the path was relative. When CLRProfiler launched the application, the working directory remained that of the profiler instead of being switched to the application under analysis. Since I was running unprivileged, the failure to open the data file was actually manifested as an UnauthorizedException because the application did not have permissions to root around in the folder where the profiler was installed.
After correcting both of these (the first by running as administrator the second by changing the config file to use an absolute path), the issues disappeared.