Rob Kraft's Software Development Blog

Software Development Insights

Reading from the registry with Silverlight.

Posted by robkraft on May 20, 2010

Yes, you can read from the registry of the local machine using a Silverlight application.  This is subject to these qualifications:

1)     The Silverlight App must be running out-of-browser.  This is necessary so that you can run the Silverlight App with elevated permissions.

2)     The Silverlight App must be running with Elevated Permissions.  This is necessary so that you can access the COM Interop.

3)     The COM Interop Automation Factory must be available.  Honestly, if you are running out of browser with elevated permission I don’t know why it would not be available.

4)     You must be running Silverlight 4.

To do this for yourself:

1)     Create a new Silverlight Application in Visual Studio 2010

2)     Open the Project Properties, select the Silverlight tab, and check the box for “Enable running application out of the browser”.

3)     Click on the “Out-of-Browser Settings” button and check the box for “Require elevated trust when running outside the browser”.

4)     Place a simple button in the Grid your MainPage.xaml.  Use the default name button1.

5)     Paste this code:

          private void button1_Click(object sender, RoutedEventArgs e)


              if (App.Current.IsRunningOutOfBrowser)

                   MessageBox.Show(“Running Out of Browser!”);

              if (App.Current.HasElevatedPermissions)

                   MessageBox.Show(“Has elevated Perms!”);

              if (AutomationFactory.IsAvailable)

                   MessageBox.Show(“Automation Factory is Available!”);

              dynamic WshShell = AutomationFactory.CreateObject(“WScript.Shell”);



6)     Run the app, right-click on the form and choose “Install ..appname… onto this computer…”

7)     Click the button on the “out-of-browser” version of the app.  Hopefully you receive all the expected values.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: