<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5157921057163462470</id><updated>2011-07-07T16:24:58.902-07:00</updated><title type='text'>软件开发技术相关</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://develop-caihong.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5157921057163462470/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://develop-caihong.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>caihong</name><uri>http://www.blogger.com/profile/14082793430116680633</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5157921057163462470.post-7650331311608286099</id><published>2009-07-01T20:01:00.000-07:00</published><updated>2009-07-07T23:23:05.179-07:00</updated><title type='text'>Grant full trust for multiple assemblies with one SetSecurity Proj</title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;strong&gt;[Objective]&lt;/strong&gt;&lt;br /&gt;With VSTO 2005 SE, an addin that use other .NET dll(assemblies) is developed. In order to deplying the project, we use Windoes Installer follows the instructions as below&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;a href="http://blogs.msdn.com/chcast/archive/2007/03/28/creating-visio-add-ins-with-vsto-2005-se.aspx"&gt;&lt;span style="font-family:courier new;font-size:100%;"&gt;http://blogs.msdn.com/chcast/archive/2007/03/28/creating-visio-add-ins-with-vsto-2005-se.aspx&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;However, after setup, we must grant full trust for all asseblies(including the addin one). In order to do it automatically, we made some modification in SetSecurity project. It is described as below.&lt;br /&gt;&lt;br /&gt;1 Add new method in &lt;strong&gt;[CaspolSecurityPolicyCreator.cs]&lt;/strong&gt; to register multiple asseblies with one parent group&lt;br /&gt;2 Modify &lt;strong&gt;[SetSecurity.cs]&lt;/strong&gt; to use the new method&lt;br /&gt;3 Set &lt;strong&gt;CustomActioData&lt;/strong&gt; in Setup(Installer) project&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;[Solutions]&lt;/strong&gt;&lt;br /&gt;1 In [CaspolSecurityPolicyCreator.cs], Add a new method of AddMultiSecurityPolicy() as following. The code is based on AddSecurityPolicy() with some modification highlighted in　&lt;span style="color:#ff0000;"&gt;red&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;internal static void AddMultiSecurityPolicy(&lt;br /&gt;bool machinePolicyLevel,&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;string assemblyName,&lt;/span&gt;&lt;br /&gt;string solutionCodeGroupName,&lt;br /&gt;string solutionCodeGroupDescription,&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;string targetDir,&lt;/span&gt;&lt;br /&gt;string assemblyCodeGroupName,&lt;br /&gt;string assemblyCodeGroupDescription)&lt;br /&gt;{&lt;br /&gt;string frameworkFolder = GetFrameworkFolder();&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;//string solutionInstallationLocation = Path.GetDirectoryName(assemblyPath);&lt;br /&gt;string solutionInstallationLocation = targetDir;&lt;/span&gt;&lt;br /&gt;string solutionInstallationUrl = Path.Combine(solutionInstallationLocation, "*");&lt;br /&gt;&lt;br /&gt;string policyLevel;&lt;br /&gt;string parentCodeGroup;&lt;br /&gt;if (machinePolicyLevel)&lt;br /&gt;{&lt;br /&gt;policyLevel = "-m"; // Use Machine-level policy.&lt;br /&gt;parentCodeGroup = "My_Computer_Zone"; // Use My_Computer_Zone for assemblies installed on the computer.&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;policyLevel = "-u"; // Use User-level policy.&lt;br /&gt;parentCodeGroup = "All_Code";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Add the solution code group. Grant no permission at this level.&lt;br /&gt;string arguments = policyLevel + " -q -ag " + parentCodeGroup + " -url \"" + solutionInstallationUrl + "\" Nothing -n \"" + solutionCodeGroupName + "\" -d \"" + solutionCodeGroupDescription + "\"";&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;RunCaspolCommand(frameworkFolder, arguments);&lt;br /&gt;}&lt;br /&gt;catch (Exception ex)&lt;br /&gt;{&lt;br /&gt;string error = String.Format("Cannot create the security code group '{0}'.", solutionCodeGroupName);&lt;br /&gt;throw new Exception(error, ex);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Add the assembly code group. Grant FullTrust permissions to the main assembly.&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;Int16 index;&lt;br /&gt;string[] assemblys = assemblyName.Split(',');&lt;br /&gt;&lt;br /&gt;string[] assemblyCGN = assemblyCodeGroupName.Split(',');&lt;br /&gt;index = 0;&lt;br /&gt;foreach (string assembly in assemblys)&lt;br /&gt;{&lt;br /&gt;string assemblyPath = Path.Combine(targetDir, assembly);&lt;br /&gt;&lt;br /&gt;// not using the assembly strong name as the membership condition.&lt;br /&gt;arguments = policyLevel + " -q -ag \"" + solutionCodeGroupName + "\" -url \"" + assemblyPath + "\" FullTrust -n \"" + assemblyCGN[index] + "\" -d \"" + assemblyCodeGroupDescription + "\"";&lt;br /&gt;&lt;br /&gt;RunCaspolCommand(frameworkFolder, arguments);&lt;br /&gt;index++;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;}&lt;br /&gt;catch (Exception ex)&lt;br /&gt;{&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;// Clean the solutionCodeGroupName.&lt;br /&gt;RemoveSecurityPolicy(machinePolicyLevel, solutionCodeGroupName);&lt;br /&gt;}&lt;br /&gt;catch { }&lt;br /&gt;&lt;br /&gt;string error = String.Format("Cannot create the security code group '{0}'.", assemblyCodeGroupName);&lt;br /&gt;throw new Exception(error, ex);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2 Find the codes below in [SetSecurity.cs], and make modification as in &lt;span style="color:#ff0000;"&gt;red&lt;/span&gt;&lt;br /&gt;try&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;bool allUsers = String.Equals(allUsersString, "1");&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color:#ff0000;"&gt;//string assemblyPath = Path.Combine(targetDir, assemblyName);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;// Note that Install method may be invoked during Repair mode and the code group&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;// may already exist.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;// To prevent adding of another code group, remove the code group if it exists.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;try&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;// The solutionCodeGroupName must be a unique name; otherwise, the method might delete wrong code group.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;CaspolSecurityPolicyCreator.RemoveSecurityPolicy(allUsers,&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt; solutionCodeGroupName);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;catch {}&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;/*&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;CaspolSecurityPolicyCreator.AddSecurityPolicy(&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;allUsers,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;solutionCodeGroupName,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;solutionCodeGroupDescription,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;assemblyPath,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;assemblyCodeGroupName,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;assemblyCodeGroupDescription);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;CaspolSecurityPolicyCreator.AddMultiSecurityPolicy&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;allUsers,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;assemblyName,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;solutionCodeGroupName,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;solutionCodeGroupDescription,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;targetDir,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;assemblyCodeGroupName,&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;assemblyCodeGroupDescription);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;stateSaver.Add("allUsers", allUsers);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;catch (Exception ex)&lt;br /&gt;{&lt;br /&gt;throw new InstallException("Cannot set the security policy.", ex);&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;３ In Setup project, the CustomActioData in CustomAction--&gt;Install--&gt;Primary output of SetSecurity--&gt;Property Window, use the following string in one line&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;/&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;assemblyName&lt;/span&gt;=&lt;strong&gt;"AAA.dll,BBB.dll,CCC.dll"&lt;/strong&gt; /&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;targetDir&lt;/span&gt;="[&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;TARGETDIR&lt;/span&gt;]\" /&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;solutionCodeGroupName&lt;/span&gt;="HITACHI.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;kyaddin&lt;/span&gt;" /&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;solutionCodeGroupDescription&lt;/span&gt;="Code group for &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;kyaddin&lt;/span&gt;" /&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;assemblyCodeGroupName&lt;/span&gt;=&lt;strong&gt;"AAA,BBB,&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;CCC&lt;/span&gt;"&lt;/strong&gt; /&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;assemblyCodeGroupDescription&lt;/span&gt;="Code group for &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;kyaddin&lt;/span&gt;" /&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;allUsers&lt;/span&gt;=[&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;ALLUSERS&lt;/span&gt;] &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Build and run the setup.&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;exe&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;With the above &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;modification&lt;/span&gt;, we enhanced the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;SetSecurity&lt;/span&gt; to support granting full trust for multiple &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;asseｍblies&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Limitation&lt;/strong&gt;: All assemblies must be located in same folder.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Comment&lt;/strong&gt;: With similar &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;modifications&lt;/span&gt; the followings can be done to improve &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;SetSecurity&lt;/span&gt;&lt;br /&gt;1 to support different &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;targetdir&lt;/span&gt;&lt;br /&gt;Attention: For those assemblies without strong name, they must be located under the application folder.&lt;br /&gt;2 Now we can support to grant full trust to assemblies that all with strong name or none. In order to grant &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;assemblies&lt;/span&gt; with strong name or without strong name identically, we can consider the followings.&lt;br /&gt;Adding new membership like /&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;StrongName&lt;/span&gt; = "1, 0, 1".&lt;br /&gt;In &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;AddMultiSecurityPolicy&lt;/span&gt;(), add the process to check &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;StrongName&lt;/span&gt; and make &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;different&lt;/span&gt; arguments.&lt;/span&gt; &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5157921057163462470-7650331311608286099?l=develop-caihong.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://develop-caihong.blogspot.com/feeds/7650331311608286099/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://develop-caihong.blogspot.com/2009/07/grant-full-trust-for-multiple-asseblies.html#comment-form' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5157921057163462470/posts/default/7650331311608286099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5157921057163462470/posts/default/7650331311608286099'/><link rel='alternate' type='text/html' href='http://develop-caihong.blogspot.com/2009/07/grant-full-trust-for-multiple-asseblies.html' title='Grant full trust for multiple assemblies with one SetSecurity Proj'/><author><name>caihong</name><uri>http://www.blogger.com/profile/14082793430116680633</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5157921057163462470.post-8738540133810364057</id><published>2009-06-25T08:04:00.000-07:00</published><updated>2009-06-25T08:07:06.245-07:00</updated><title type='text'>Walkthrough: Calling Code in an Application-Level Add-in from VBA(MSDN document)</title><content type='html'>&lt;a href="http://msdn.microsoft.com/en-us/library/bb608614.aspx"&gt;http://msdn.microsoft.com/en-us/library/bb608614.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;1 Define a class that you can expose to other Office solutions&lt;br /&gt;Add the following statements to the top of the file.&lt;br /&gt;&lt;br /&gt;Imports System.Data&lt;br /&gt;Imports System.Runtime.InteropServices&lt;br /&gt;Imports Excel = Microsoft.Office.Interop.Excel&lt;br /&gt;&lt;br /&gt;Replace the empty AddInUtilities class declaration with the following code.&lt;br /&gt;&lt;comvisible(true)&gt;&lt;br /&gt;Public Interface IAddInUtilities&lt;br /&gt;Sub ImportData()&lt;br /&gt;End Interface&lt;br /&gt;&lt;br /&gt;&lt;comvisible(true)&gt;&lt;br /&gt;&lt;classinterface(classinterfacetype.none)&gt;&lt;br /&gt;Public Class AddInUtilities&lt;br /&gt;Implements IAddInUtilities&lt;br /&gt;&lt;br /&gt;' This method tries to write a string to cell A1 in the active worksheet.&lt;br /&gt;Public Sub ImportData() Implements IAddInUtilities.ImportData&lt;br /&gt;&lt;br /&gt;Dim activeWorksheet As Excel.Worksheet = Globals.ThisAddIn.Application.ActiveSheet&lt;br /&gt;&lt;br /&gt;If activeWorksheet IsNot Nothing Then&lt;br /&gt;Dim range1 As Excel.Range = activeWorksheet.Range("A1")&lt;br /&gt;range1.Value2 = "This is my data"&lt;br /&gt;End If&lt;br /&gt;End Sub&lt;br /&gt;End Class&lt;br /&gt;&lt;br /&gt;2 Exposing the method for external use&lt;br /&gt;Add the following code to ThisAddin class&lt;br /&gt;&lt;br /&gt;Private utilities As AddInUtilities&lt;br /&gt;&lt;br /&gt;Protected Overrides Function RequestComAddInAutomationService() As Object&lt;br /&gt;If utilities Is Nothing Then&lt;br /&gt;utilities = New AddInUtilities()&lt;br /&gt;End If&lt;br /&gt;Return utilities&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3 Code to call VSTO Method&lt;br /&gt;Add the following VBA code to the code file. This code first gets a COMAddIn object that represents the ExcelImportData add-in. Then, the code uses the Object property of the COMAddIn object to call the ImportData method.&lt;br /&gt;&lt;br /&gt;Sub CallVSTOMethod()&lt;br /&gt;Dim addIn As COMAddIn&lt;br /&gt;Dim automationObject As Object&lt;br /&gt;Set addIn = Application.COMAddIns("ExcelImportData")&lt;br /&gt;Set automationObject = addIn.Object&lt;br /&gt;automationObject.ImportData&lt;br /&gt;End Sub&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5157921057163462470-8738540133810364057?l=develop-caihong.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://develop-caihong.blogspot.com/feeds/8738540133810364057/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://develop-caihong.blogspot.com/2009/06/walkthrough-calling-code-in-application.html#comment-form' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5157921057163462470/posts/default/8738540133810364057'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5157921057163462470/posts/default/8738540133810364057'/><link rel='alternate' type='text/html' href='http://develop-caihong.blogspot.com/2009/06/walkthrough-calling-code-in-application.html' title='Walkthrough: Calling Code in an Application-Level Add-in from VBA(MSDN document)'/><author><name>caihong</name><uri>http://www.blogger.com/profile/14082793430116680633</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5157921057163462470.post-373987804566582537</id><published>2009-06-25T07:35:00.000-07:00</published><updated>2009-07-07T23:23:42.524-07:00</updated><title type='text'>Delpoying Visio 2007 Addin with VSTO 2005 SE</title><content type='html'>Delpoying Visio 2007 Addin with VSTO 2005 SE&lt;br /&gt;&lt;a href="http://blogs.msdn.com/chcast/archive/2007/03/28/creating-visio-add-ins-with-vsto-2005-se.aspx"&gt;http://blogs.msdn.com/chcast/archive/2007/03/28/creating-visio-add-ins-with-vsto-2005-se.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;0 Creating a VSTO add-in for Visio&lt;br /&gt;&lt;br /&gt;1 Deployment&lt;br /&gt;Steps&lt;br /&gt;1. Install .NET 2.0 Framework&lt;br /&gt;2(*) Install VSTO SE Runtime&lt;br /&gt;3(*) Install Visio 2007 Primary Interop Assembly&lt;br /&gt;4. Add required add-in registry settings&lt;br /&gt;5. Copy add-in assembly.&lt;br /&gt;6. Copy any Visio templates and stencils&lt;br /&gt;7(*). Grant full trust to add-in&lt;br /&gt;&lt;br /&gt;1.1 install OfficeVSTO2005SEWindowsInstaller.msi.&lt;br /&gt;&lt;a href="http://go.microsoft.com/fwlink/?linkid=83721"&gt;http://go.microsoft.com/fwlink/?linkid=83721&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;1.2 Adding the Visual Studio Tools for Office Packages to the Bootstrapper&lt;br /&gt;&lt;br /&gt;1.2.1 Preparing the Runtime&lt;br /&gt;The default location of the {SamplesDir} token below is “C:\Program Files\Microsoft Visual Studio 2005 Tools for Office SE Resources\VSTO2005SE Windows Installer Sample” or something like that&lt;br /&gt;&lt;br /&gt;Microsoft Visual Studio 2005 Tools for Office Second Edition runtime&lt;br /&gt;&lt;a href="http://go.microsoft.com/fwlink/?linkid=49612"&gt;http://go.microsoft.com/fwlink/?linkid=49612&lt;/a&gt;&lt;br /&gt;Copy vstor.exe into the {SamplesDir}\packages\VSTOSERuntime directory.&lt;br /&gt;&lt;br /&gt;Microsoft Visual Studio 2005 Tools for the Microsoft Office System (VSTO2005) Language Package&lt;br /&gt;&lt;a href="http://go.microsoft.com/fwlink/?linkid=56602"&gt;http://go.microsoft.com/fwlink/?linkid=56602&lt;/a&gt;&lt;br /&gt;Copy the file vstolp20.exe into the directory {SamplesDir}\packages\VSTOLP.&lt;br /&gt;&lt;br /&gt;1.2.2 Preparing the Office Component Check&lt;br /&gt;In Visual Studio 2005 Command Prompt, change the directory to {SamplesDir}\projects\Checks&lt;br /&gt;cl.exe /Oxs /MT /GS ComponentCheck.cpp advapi32.lib&lt;br /&gt;copy the executable file ComponentCheck.exe into {SamplesDir}\packages\Office2003PIA and {SamplesDir}\packages\Office2007PIA&lt;br /&gt;&lt;br /&gt;1.2.3 Preparing for the Release of Office2007 Microsoft Office System Update: Redistributable Primary Interop Assemblies&lt;br /&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=59daebaa-bed4-4282-a28c-b864d8bfa513"&gt;http://www.microsoft.com/downloads/details.aspx?familyid=59daebaa-bed4-4282-a28c-b864d8bfa513&lt;/a&gt;&lt;br /&gt;Copy O2007PIA.msi into the directory {SamplesDir}\packages\Office2007PIA&lt;br /&gt;&lt;br /&gt;1.2.4 Copying the Packages into the Bootstrapper Directory&lt;br /&gt;default Bootstrapper directory: C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages&lt;br /&gt;Copy the contents of the directory {SamplesDir}\packages into the bootstrapper directory.&lt;br /&gt;&lt;br /&gt;1.3 Enhancing the Visio Add-in Setup Project&lt;br /&gt;&lt;br /&gt;1.3.1 Signing the Assembly&lt;br /&gt;&lt;br /&gt;1.3.2 Adding the Prerequisites to the Setup Project&lt;br /&gt;&lt;br /&gt;1.3.3 Adding a Custom Action to Grant Trust to the Assembly&lt;br /&gt;&lt;br /&gt;1.3.3.1 add the supplied SetSecurity project&lt;br /&gt;copy the SetSecurity project from the {SamplesDir}\projects directory to the directory that contains your Addin solution.&lt;br /&gt;&lt;br /&gt;1.3.3.2 add the primary output of the custom action project to the Setup project&lt;br /&gt;Right click on Setup project --&gt; View --&gt;Custom Actions&lt;br /&gt;In the Custom Actions editor, right-click Custom Actions --&gt; Add Custom ActionIn the Look&lt;br /&gt;In list, click Application Folder --&gt; Add Output&lt;br /&gt;The Add Project Output Group dialog box opens.&lt;br /&gt;In the Project list, click SetSecurity.&lt;br /&gt;Select Primary output from the list of output types --&gt; OK.&lt;br /&gt;Verify that Primary output from SetSecurity (Active) is added&lt;br /&gt;&lt;br /&gt;1.3.3.3 add the custom action data for the Install method&lt;br /&gt;In the Custom Actions editor, expand Install.Right-click Primary output from SetSecurity (Active) --&gt; Properties Window.&lt;br /&gt;In the Properties window, set the CustomActionData property to the following string. Enter this as one long string, and change MyCompanyName to your company name.&lt;br /&gt;/assemblyName="MyVisioVSTOAddin.dll" /targetDir="[TARGETDIR]\" /solutionCodeGroupName="MyCompanyName.MyVisioVSTOAddin" /solutionCodeGroupDescription="Code group for MyVisioVSTOAddin" /assemblyCodeGroupName="MyVisioVSTOAddin" /assemblyCodeGroupDescription="Code group for MyVisioVSTOAddin" /allUsers=[ALLUSERS]&lt;br /&gt;&lt;br /&gt;1.3.3.4 add the custom action data for the Rollback method&lt;br /&gt;In the Custom Actions editor, expand Rollback.&lt;br /&gt;Right-click Primary output from SetSecurity (Active) --&gt; Properties Window.&lt;br /&gt;In the Properties window, set the CustomActionData property to the following string:&lt;br /&gt;/solutionCodeGroupName="MyCompanyName.MyVisioVSTOAddin"&lt;br /&gt;&lt;br /&gt;1.3.3.5 add the custom action data for the Uninstall method&lt;br /&gt;In the Custom Actions editor, expand Uninstall.Right-click Primary output from SetSecurity (Active) --&gt; Properties Window.&lt;br /&gt;In the Properties window, set the CustomActionData property to the following string:&lt;br /&gt;/solutionCodeGroupName="MyCompanyName.MyVisioVSTOAddin"&lt;br /&gt;&lt;br /&gt;1.3.4 Adding Launch Conditions to the Windows Installer File&lt;br /&gt;&lt;br /&gt;1.3.4.1 add a launch condition for the VSTO 2005 SE runtimeIn the Launch Conditions editor, right-click Requirements on Target Machine --&gt; Add Registry Launch Condition.&lt;br /&gt;Select the newly added search condition, Search for RegistryEntry1.&lt;br /&gt;Rename the search condition to Search for VSTO 2005 SE Runtime.&lt;br /&gt;In the Properties window, change the value of Property to VSTORTVERSION.&lt;br /&gt;Also in the Properties window, set the value of RegKey to the following string.&lt;br /&gt;Software\Microsoft\vsto runtime Setup\v2.0.50727&lt;br /&gt;Leave the Root property set to vsdrrHKLM and change the Value property to Update.&lt;br /&gt;Select the newly added launch condition, Condition1.&lt;br /&gt;Rename it to Display message if the Visual Studio 2005 Tools for Office SE Runtime is not installed.&lt;br /&gt;In the Properties window, change the value of the Condition property to the following string.&lt;br /&gt;VSTORTVERSION &gt;= "#2"&lt;br /&gt;Leave the InstallURL property blank.&lt;br /&gt;Change the value of the Message property to The Visual Studio 2005 Tools for Office SE Runtime is not installed. Please run Setup.exe.&lt;br /&gt;&lt;br /&gt;1.3.4.2 add a launch condition for the Visual Studio 2005 Tools for Office Language Pack&lt;br /&gt;In the Launch Conditions editor, right-click Requirements on Target Machine --&gt; Add Windows Installer Launch Condition.&lt;br /&gt;Select the newly added search condition, Search for Component1.&lt;br /&gt;Rename the search condition to Search for VSTO Language Pack.&lt;br /&gt;In the Properties window, in the ComponentId property, type the following GUID:&lt;br /&gt;{2E3A394E-C9BD-40C3-9990-BA7AF7C8B4AF}&lt;br /&gt;Change the value of Property to COMPONENTEXISTS_VSTOLP.&lt;br /&gt;Select the newly added launch condition, (Condition1).&lt;br /&gt;Rename it to Display message if the Visual Studio 2005 Tools for Office Language Pack is not installed.&lt;br /&gt;In the Properties window, change the value of the Condition property to COMPONENTEXISTS_VSTOLP.&lt;br /&gt;Leave the InstallURL property blank.&lt;br /&gt;Change the value of the Message property to The Visual Studio 2005 Tools for Office Language Pack is not installed. Please run Setup.exe.&lt;br /&gt;&lt;br /&gt;1.4 Testing&lt;br /&gt;&lt;br /&gt;References&lt;br /&gt;1. Deploying Visual Studio 2005 Tools for Office Second Edition Solutions Using Windows Installer (Part 1 of 2)&lt;a href="http://msdn2.microsoft.com/en-us/library/bb332051.aspx"&gt;http://msdn2.microsoft.com/en-us/library/bb332051.aspx&lt;/a&gt;&lt;br /&gt;2. Deploying Visual Studio 2005 Tools for Office Second Edition Solutions Using Windows Installer: Walkthroughs (Part 2 of 2)&lt;a href="http://msdn2.microsoft.com/en-us/library/bb332052.aspx"&gt;http://msdn2.microsoft.com/en-us/library/bb332052.aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5157921057163462470-373987804566582537?l=develop-caihong.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://develop-caihong.blogspot.com/feeds/373987804566582537/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://develop-caihong.blogspot.com/2009/06/delpoying-visio-2007-addin-with-vsto.html#comment-form' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5157921057163462470/posts/default/373987804566582537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5157921057163462470/posts/default/373987804566582537'/><link rel='alternate' type='text/html' href='http://develop-caihong.blogspot.com/2009/06/delpoying-visio-2007-addin-with-vsto.html' title='Delpoying Visio 2007 Addin with VSTO 2005 SE'/><author><name>caihong</name><uri>http://www.blogger.com/profile/14082793430116680633</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
