Ironpython: How to see when a WPF application fails? - wpf

I am doing an application with GUI using WPF/XAML with Ironpython and SharpDevelop, until now it works fine, when I'm in the development environment I can see the errors in console and know what is wrong.
But when I build and deploy the app for us on other system or I ran it outside of the development environment and there is no longer the console when there is some error or crashes, it fails silently, and I cannot know what went wrong.
How can I alert or log to see what fails?

You could put in some code to catch the error and log it to a file.
Something possibly simpler is to compile your application as a Console Application. This can be done via Project Options - Application - Output type. Then you will get a console window when you run your WPF application and any exception that happens at startup will be logged to this window.

Related

Packaged shell extension killing application

I have a WPF application. To give it an identity to consume UWP APIs, I've added sparse package support. This installs / uninstalls / updates (we're not using MSIX) with my WPF application fine, and my app is running with an identity. It shows in task manager with a Package Name listed on my process.
Now I'm attempting to add context menu support following Microsoft's docs.
I've created a shell extension which will show when opening the context menu for any file and folder, which is pretty much a copy of their sample with different GetIcon(), GetTitle() and Invoke() implementations for IExplorerCommand.
I'm specifying this in the AppxManifest.xml (values anonymised):
<desktop4:Extension Category="windows.fileExplorerContextMenus">
<desktop4:FileExplorerContextMenus>
<desktop5:ItemType Type="*">
<desktop5:Verb Id="MyFileCommand" Clsid="file-guid"/>
</desktop5:ItemType>
<desktop5:ItemType Type="Directory">
<desktop5:Verb Id="MyFolderCommand" Clsid="folder-guid"/>
</desktop5:ItemType>
</desktop4:FileExplorerContextMenus>
</desktop4:Extension>
<com:Extension Category="windows.comServer">
<com:ComServer>
<com:SurrogateServer DisplayName="SSVerbHandler">
<com:Class Id="file-guid" Path="my-shell-extension.dll" ThreadingModel="STA"/>
</com:SurrogateServer>
<com:SurrogateServer DisplayName="SSVerbHandler">
<com:Class Id="folder-guid" Path="my-shell-extension.dll" ThreadingModel="STA"/>
</com:SurrogateServer>
</com:ComServer>
</com:Extension>
This works, my context menu entry is listed and performs the action as expected. But here's the issue: each time the context menu is opened for the first time, it kills the already running instance of my WPF application. By first time, I mean restarting explorer.exe and right clicking on a file or folder.
My gut feeling is this is related to UWP side of things. This is because originally it would always kill my application when right clicking to open a context menu. But with a little trial and error I solved this by configuring multi-instance support in my AppxManifest.xml:
<Package
...
xmlns:desktop4="http://schemas.microsoft.com/appx/manifest/desktop/windows10/4"
xmlns:iot2="http://schemas.microsoft.com/appx/manifest/iot/windows10/2"
IgnorableNamespaces="uap mp desktop4 iot2">
...
<Applications>
<Application Id="App"
...
desktop4:SupportsMultipleInstances="true"
iot2:SupportsMultipleInstances="true">
...
</Application>
</Applications>
...
</Package>
I'm hoping someone can suggest any troubleshooting ideas as I'm now struggling.
I've sprinkled some ol' trusty MessageBox functions within the shell extension in DllMain, DllCanUnloadNow and DllGetClassObject. But for that first load attempt, no message boxes are shown, no context menu item listed and my application is still killed.
I've poked around in the event viewer hoping to see any errors or warnings listed recently, plus in Applications and Service Logs\Microsoft\Windows\Appx* and Applications and Service Logs\Microsoft\Windows\AppModel-Runtime. Nothing has jumped out at me.
According to this SO anwser, if there's an error with the shell extension itself, it may not show. That does fit, but I'm sceptical as it always works on subsequent attempts, and the previously solved UWP killing issue.
In the scenario where my application stops, using these powershell commands I get:
$process = Start-Process .\MyApp.exe -PassThru -Wait
$process.ExitCode
1
I do have crash logging in my app, but nothing gets logged. This is the only place Environment.Exit(1) is called within the WPF application.
I did try the silent monitoring detection in GFlags on the WPF application, but couldn't seem to trigger it. Only when I manually closed the application. (Ignore Self Exits unchecked for testing). I'm not sure if that's because the exit code is 1.
When the error occurs with process monitor running, I can see lots of ThreadExit before a final ProcessExit with the exit code 1. That would imply it's exiting cleanly with my application itself returning 1?
It's also worth mentioning I've lived in managed / .NET land for the last decade or so, I don't have much experience with C++ (or unmanaged languages in general) or UWP, and the first time I've attempted to write a shell extension.

Transform Classes With Dex For Debug is making Windows crash

I'm building a React Native app. Everything was working fine but now when I try to run on Android it gets to the task :app:transformClassesWithDexForDebug, it hangs for 30-60 seconds and then Windows shuts down.
I tried to setup multidex as mentioned here: https://stackoverflow.com/a/56875424 but the result is the same.
I'm not getting any error message, the computer just shuts down abruptly and I have to turn it on again.
Any advice is much appreciated.
In the end, it was two problems mixed:
I was using the new Windows Terminal which is still in beta so I guess the shutdown problem was something to do with it, because I changed to normal good ol' cmd and the shutdown problem disappeared.
The actual error in the compilation process was actually the setup of multidex. I was not extending the MultiDexApplication class.
Thank you all.

How to debug C and Matlab code at the same time?

I have some Matlab .m files that use a C function I've created.
When Debugging in Matlab, or Visual-Studio, is there any way to run step by step both C and Matlab codes in a way that both Matlab a C variables remain usable for debug?
This addresses only the MSVS half of your question...
The steps to use step-by-step debugging using Visual Studio are outlined here. This is just an except centering around a .dll that is hosted by a pre-existing application. Matlab qualifies as a host application, whether it is also being run in debug mode, or not.
Start debugging from the calling app
The app that calls a DLL can be:
An app from a Visual Studio project in the same or a different solution from the DLL.
An existing app that is already deployed and running on a test or production computer.
Located on the web and accessed through a URL.
A web app with a web page that embeds the DLL.
To debug a DLL from a calling app, you can:
Open the project for the calling app, and start debugging by selecting Debug > Start Debugging or pressing F5.
or
Attach to an app that is already deployed and running on a test or production computer. Use this method for DLLs on websites or in web
apps. For more information, see How to: Attach to a running process.
Before you start debugging the calling app, set a breakpoint in the
DLL. See Using breakpoints. When the DLL breakpoint is hit, you can
step through the code, observing the action at each line. For more
information, see Navigate code in the debugger.
During debugging, you can use the Modules window to verify the DLLs
and .exe files the app loads. To open the Modules window, while
debugging, select Debug > Windows > Modules. For more information, see
How to: Use the Modules window. Use the Immediate window
You can [also] use the Immediate window to evaluate DLL functions or methods
at design time. The Immediate window plays the role of a calling app.
[and so on....]

How to get windows store app crash logs

I'am developing windows store application. Sometimes application gets hang and crash. In the development environment is there any best way to get crash reports and analyze those reports. I have gone through some articles regarding application crashes. In those they've mentioned about windows application logs and report.wer files. But those files not contained much information about application crash (like stack trace). Please help.
For published apps on Windows Store (metro apps) and Windows Phone, all info about crashes (exceptions) you can get in Dashboard, where you submit the application, in Crash reports section.
For each application you can download excel file, where you can see all occurred exceptions and stack trace for each exception.
Or you can create your own logging system and submit crash log from user device in automatic mode or let the user to choose.
(Automatic send mode is not recommended, just for option)
You can get the crash reports from crash window which contains break and continue buttons. It might be applicable when you don't get the stack trace from your code. Now you can close the crash window and the bug line will be highlighted, mousehover on the args of that event and you can find TextVisualizer.
Now open that and you can find the stacktrace of the exception

Application crashes on start when running through remote desktop

I am developing a WPF application. I am accessing an admin account on a clients machine using remote desktop. When I try to run the application I am getting a xaml parse exception when the program attempts to initialise.
The strange thing is if I run the program without remote desktop on the same account it works fine.
Has anyone experienced anything like this before?

Resources