Visual Studio Developer Center > Visual Studio Forums > Visual Studio Tools for Office > Why doesn’t my VSTO add in load after the deployment, but works on my development machine when debugging in Visual Studio?
Ask a questionAsk a question
 

LockedWhy doesn’t my VSTO add in load after the deployment, but works on my development machine when debugging in Visual Studio?

Locked

  • Sunday, February 08, 2009 12:30 PMJi.ZhouMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Why doesn’t my VSTO add in load after the deployment, but works on my development machine when debugging in Visual Studio?



    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Answers

  • Sunday, February 08, 2009 12:31 PMJi.ZhouMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    There may be various reasons that can cause the Add-in not to load, but the first one we should check is the security state. We need to use the tool caspol (Code Access Security Policy Tool) to grant full trust to the Add-in assembly and all of its referenced assemblies on the installing machine before the solution gets run.  This is true for the following projects which are running on VSTO Runtime 2.0

    1. Office 2003 Add-ins developed by VSTO SE

    2. Office 2007 Add-ins developed by VSTO SE

    3. Office 2003 Add-ins developed by Visual Studio 2008

    The caspol command line used to grant full trust looks like:

    caspol -u -ag All_Code -url "{The assembly’s full path}" FullTrust -n "{The code group name}".

    To integrate the caspol process into the setup project, we need to create a custom action to call caspol at the end of the deployment. Microsoft has released two articles about this topic in the following links. It also provides a sample project named SetSecurity which is used as the custom action. Make sure to use the right CustomActionData in your setup project. There is a space between each element in that CustomActionData string.

    http://msdn.microsoft.com/en-us/library/bb332051.aspx

    http://msdn.microsoft.com/en-us/library/bb332052.aspx

    (Related forum thread http://social.msdn.microsoft.com/forums/en-US/vsto/thread/0b794df0-5012-41a2-9623-0dbc5b865994/ )




    For more FAQ about Visual Studio Tools for Office, please see Visual Studio Tools for Office FAQ



    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

All Replies

  • Sunday, February 08, 2009 12:31 PMJi.ZhouMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    There may be various reasons that can cause the Add-in not to load, but the first one we should check is the security state. We need to use the tool caspol (Code Access Security Policy Tool) to grant full trust to the Add-in assembly and all of its referenced assemblies on the installing machine before the solution gets run.  This is true for the following projects which are running on VSTO Runtime 2.0

    1. Office 2003 Add-ins developed by VSTO SE

    2. Office 2007 Add-ins developed by VSTO SE

    3. Office 2003 Add-ins developed by Visual Studio 2008

    The caspol command line used to grant full trust looks like:

    caspol -u -ag All_Code -url "{The assembly’s full path}" FullTrust -n "{The code group name}".

    To integrate the caspol process into the setup project, we need to create a custom action to call caspol at the end of the deployment. Microsoft has released two articles about this topic in the following links. It also provides a sample project named SetSecurity which is used as the custom action. Make sure to use the right CustomActionData in your setup project. There is a space between each element in that CustomActionData string.

    http://msdn.microsoft.com/en-us/library/bb332051.aspx

    http://msdn.microsoft.com/en-us/library/bb332052.aspx

    (Related forum thread http://social.msdn.microsoft.com/forums/en-US/vsto/thread/0b794df0-5012-41a2-9623-0dbc5b865994/ )




    For more FAQ about Visual Studio Tools for Office, please see Visual Studio Tools for Office FAQ



    Please remember to mark the replies as answers if they help and unmark them if they provide no help.