Tuesday 2 September 2014

How to launch external application or file from Silverlight/Trusted applications

Trusted applications require that Silverlight runs out of browser, and even if the user confirmed the trust request, there were several restrictions in place...

One thing to understand first is that this feature obviously is not meant for random internet applications. It requires signed XAPs, locally installed certificates and a certain registry key to be set.

The first thing to do to use this feature is to enable in-browser elevated trust support in the project settings, an option that is new for Silverlight 5.


1)Require evaluated trust when running in-browser.


2)Out of browser setting as below.


3)Signing the xap in silverlight project


4)install certificate 


5)Store certificate in trusted publisher.




 6)Need DLL Microsoft.CSharp

C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Client\Microsoft.CSharp.dll

7)Use following namespace

using System.Runtime.InteropServices.Automation;


   private void btncallwpf_Click(object sender, RoutedEventArgs e)
        {
            try
            {
            if (App.Current.HasElevatedPermissions)
            {


//for notepad
                dynamic notepad = AutomationFactory.CreateObject("WScript.shell");
                notepad.Run(@"C:\WINDOWS\NOTEPAD.EXE");
//for your file

                dynamic abc = AutomationFactory.CreateObject("WScript.shell");
                abc.Run(@"path");

            }

            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.ToString());
            }

        }


No comments:

Post a Comment