What you need to do is add an installer class to your addin. This install
class performs the functions creating the configuration required to all your
add-in dlls to be fully trusted on a deployment machine. The CRM
Integration code block from Microsoft at:
http://www.microsoft.com/downloads/details.aspx?familyid=078124E9-1E88-4F51-8C98
-3C1999CFE743&displaylang=en
and Eric Carter's VSTO book can give you valid ways to do what you are
asking.
In a nutshell, once you have your custom installer made, go into the setup
project that is created when you create new VSTO addin project and
double-click on the Custom Actions Editor button that is displayed on the
Solution Explorer view. In the Install folder that is displayed go and a
new custom action right click and add the project output of the add-in dll
that you added your customer installer class to. If you are like me, and
would like the answer now, here is the class that you need to add.
using System;
using System.Security;
using System.Security.Policy;
[System.ComponentModel.RunInstaller(true)]
public class Installer : System.Configuration.Install.Installer
{
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
try
{
ConfigureSecurityPolicy();
}
catch (Exception ex)
{
throw new System.Configuration.Install.InstallException("SomeException
occurred", ex);
}
}
public override void Uninstall(System.Collections.IDictionary savedState)
{
base.Uninstall(savedState);
try
{
DeleteSecurityPolicy();
}
catch (Exception ex)
{
throw new
System.Configuration.Install.InstallException(Resources.InstallerInstallExceptionText,
ex);
}
}
private void ConfigureSecurityPolicy()
{
// Find the machine policy level
PolicyLevel machinePolicyLevel = GetMachinePolicyLevel();
// Get the install directory of the current installer
string assemblyPath = Context.Parameters["assemblypath"];
string installDirectory =
assemblyPath.Substring(0, assemblyPath.LastIndexOf("\\"));
if (!installDirectory.EndsWith(@"\"))
installDirectory += @"\";
installDirectory += "*";
// Create the code group
CodeGroup codeGroup = new UnionCodeGroup(
new UrlMembershipCondition(installDirectory),
new PolicyStatement(new NamedPermissionSet("FullTrust")));
codeGroup.Description = Resources.CasPolicyDescription;
codeGroup.Name = Resources.CasPolicyName;
// Add the code group
machinePolicyLevel.RootCodeGroup.AddChild(codeGroup);
// Save changes
SecurityManager.SavePolicy();
}
private static void DeleteSecurityPolicy()
{
PolicyLevel machinePolicy = GetMachinePolicyLevel();
foreach (CodeGroup codeGroup in machinePolicy.RootCodeGroup.Children)
{
if (codeGroup.Name == Resources.CasPolicyName)
machinePolicy.RootCodeGroup.RemoveChild(codeGroup);
}
SecurityManager.SavePolicy();
}
private static PolicyLevel GetMachinePolicyLevel()
{
System.Collections.IEnumerator policyHierarchy =
SecurityManager.PolicyHierarchy();
while (policyHierarchy.MoveNext())
{
PolicyLevel level = (PolicyLevel)policyHierarchy.Current;
if (level.Type == PolicyLevelType.Machine)
return level;
}
throw new VerificationException("Exception occurred");
}
}
Hope this helps you out,
Thaddaeus.
> http://msdn.microsoft.com/office/default.aspx?pull=/library/en-us/odc_vsto2005_t
a/html/OfficeVSTOWindowsInstallerWalkthrough.asp
>
[quoted text clipped - 5 lines]
>
> can someone elaborate please.. thank you.