Silverlight 4 COM interop feature demo (VBSL4COMInterop)

This project demonstrates how to inter-operate with COM components in Silverlight 4.

VB.NET (49.8 KB)
5 Star
9,413 times
Add to favorites
E-mail Twitter Digg Facebook


This project created a simple application, which could interoperate with COM components,
exporting data to notepad or Microsoft Excel applications.


To test the silverlight4 COM interaction feature, please try the following steps:
1. Install the silverlight application to local machine with evaluated permission.
	a. Open VBSL4COMInterop solution and compile.
	b. Run the project.
	c. Right click the silverlight application in browser, select "Install VBSL4COMInterop
	   application on to this computer...", then click "Install" button in the popup panel.
2. Test the application in OOB mode
    a. double click "VBSL4COMInterop Application" shortcut on desktop to start the
	b. edit data by manipulating the datagrid.
	c. click the buttons to export data to different applications.


Silverlight 4 Tools RC2 for Visual Studio 2010

Silverilght 4 runtime

Microsoft Office 2007 or higher

Code Logic:

1. What's the precondition of interoperating COM in silverlight?
    Interoperate with COM is the new feature in Silverlight4, to develop the COM interop 
	silverlight	application, we need use Silverlight4 SDK. Also, to interop with COM, the silverlight
	application need to be running under elevated trust OOB mode.

	For details about Trusted Application, please refer to

	To determine if COM interop is available, we could use this code:

2. How to manipulate the Microsoft Word automation in silverlight?
    1. Use AutomationFactory to create word application automation object.
		Dim word = AutomationFactory.CreateObject("Word.Application")

	2. Create new word document, and then write Text and apply format.
	    Dim doc = word.Documents.Add()
        Dim range1 = doc.Paragraphs[1].Range
        range1.Text = "Silverlight4 Word Automation Sample" & vbLf
        range1.Font.Size = 24
        range1.Font.Bold = true

	3. Print document

3. How to manipulate the Windows Notepad in silverlight?
	1. Use AutomationFactory to create WSHShell object.
		Dim shell = AutomationFactory.CreateObject("WScript.Shell")
	2. Run Notepad.exe
		shell.Run(@"%windir%\notepad", 5)

	3. Send Keys to Notepad application

AutomationFactory Class

How to: Use Automation in Trusted Applications