In my WPF application, I have to allow the user to select a certificate. I do this using the X509Certificate2UI.SelectFromCollection method. For proper handling of the dialog, the SelectFromCollection method requires the IntPtr of the Hwnd parents. For this, I found the following code:
HwndSource source = (HwndSource)HwndSource.FromVisual(Window.GetWindow(this)); var certificates= X509Certificate2UI.SelectFromCollection(...,source.Handle);
So far, this works fine. My question is that I donβt know much knowledge about Win32 or interop, if after that I need to do the cleaning code, or if there are some problems using the HwndSource class, as I did above?
I saw that HwndSource implements IDisposable, but deleting the object after use closes the parent window. Therefore, this does not seem to be intended for use.
source share