2

I am Silverlight beginner and Under a situation that i have to created the login pop up which lets the user go in further on entering the "Ok" button but i want the application to be closed on "Cancel" button click .

Actually this login pop up is a ChildWindow

I have tried both Application.Current.MainWindow.Close(); and Application.Current.Exit; none of them work. Could some one please help me in achieving my target.

user3735822
  • 337
  • 2
  • 12
  • Probably an obvious question, but this isn't running in a browser, right? – eddie_cat Jul 17 '14 at 13:38
  • Also what happens when this code is called? Does it just not close or is there an exception? – eddie_cat Jul 17 '14 at 13:38
  • @Savanna yes it is not running in browser. – user3735822 Jul 17 '14 at 13:44
  • Check this SO question. http://stackoverflow.com/questions/11255442/silverlight-out-of-browser-application-will-not-close-using-mainwindow-close-met It's possible that it's a permissions issue. – eddie_cat Jul 17 '14 at 13:45
  • But it's solution of permission problem ? (because the answer there are not marked as answer) – user3735822 Jul 17 '14 at 13:47
  • Read the info there. It should give you an idea of what the problem could be. The question explains how to check your code to see if it is, in fact the same error that you are having. – eddie_cat Jul 17 '14 at 13:47
  • If it's a "trust" issue, this should be helpful too. http://msdn.microsoft.com/en-us/library/ee721083(v=vs.95).aspx – eddie_cat Jul 17 '14 at 13:49
  • @Savanna I have an exception : Access to the property call or method is not permitted unless the application has elevated permissions or if the code was called through an action initiated by the user ON DOING : App.Current.MainWindow.Close(); – user3735822 Jul 17 '14 at 13:49
  • So there you go. THat's your issue. Follow the second link and make your application install with elevated permissions. – eddie_cat Jul 17 '14 at 13:50

1 Answers1

1

You need to configure your application to require elevated trust when running outside the browser.

See here: http://msdn.microsoft.com/en-us/library/dd833073(v=vs.95).aspx

To configure out-of-browser support In Solution Explorer, select the Silverlight project for which you want to enable out-of-browser support. On the Project menu, select project name Properties. On the Silverlight tab, select Enable running application out of the browser. Click Out-of-Browser Settings. The Out-of-Browser Settings dialog box appears. Specify values for the indicated fields and then click OK. All fields are optional except for the following: Window, Title, Shortcut name, Application description

Set the SecuritySettings.ElevatedPermissions property to Required.

http://msdn.microsoft.com/en-us/library/system.windows.securitysettings.elevatedpermissions(v=vs.95).aspx

eddie_cat
  • 2,527
  • 4
  • 25
  • 43