How to debug a Silverlight application with OpenFileDialog?

I am trying to debug a silverlight application containing an OpenFileDialog.ShowDialog () call, and I get a security error message ("SecurityException was not processed by user code: Dialogs must be initiated by the user")

When I run the application without debugging, I do not get this exception.

But I have to run it in debug mode, because I need to see that I am doing the right thing with the file that the client selects ...

How can I run it in debug mode?

Thanks for any help.

+4
source share
3 answers

If you, and I assume that you are initiating a ShowDialog () call with a button click, Silverlight has some strange heuristics to determine if an action has been triggered.

It works with debugging, but if you execute the code from Button_Click to ShowDialog (), it seems that due to the delay this is not an action initiated by the user.

To get around this, I would recommend using logging instead of moving on to debugging the application. Silverlight is known for throwing these exceptions when trying to debug ShowDialog () calls.

* EDIT

Silverlight does not use the Click () event to determine if the button was triggered by the user. It uses many heuristics to determine correctly, including a timer (which causes debugging to fail)

+2
source

make sure that when you open a dialog box, it is launched by pressing a button. This is done for security reasons.

Edit

There seems to be an error in IE that can cause this error to increase even when the user initiated

http://forums.silverlight.net/forums/p/208282/491053.aspx

Another β€œDialogue” game must be user initiated. "Silverlight printing security exception

0
source

Source: https://habr.com/ru/post/1341770/


All Articles