Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / VS Tools for Office / January 2007

Tip: Looking for answers? Try searching our database.

Deployment of Outlook 2003 Add-in using VS2005 SE

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jazza - 30 Jan 2007 13:11 GMT
Hi,

I have built a custom add-in for Outlook 2003 using VSTO 2005 SE. The add-in
runs fine on the development machine when I run it from the IDE. The add-in
fails to load when I run the setup project. I have some questions/issues in
relation to the Setup project.

1. Regarding the VSTO add-in registry entries, the setup project puts these
in HKEY_CURRENT_USER hive by default, but if I look in the registry on my PC,
the registry entries already exist in HKEY_CLASSES_ROOT. Can I add these to
my setup project, or are they created when running the project from the IDE?

2. My add-in is strongly named using .snk key file. Therefore do I still
need to set CAS policy in my setup project? (I have not done this step as I
cannot find the sample SetSecurity project on my PC).

The add-in is not hard disabled, as it is not in the Disabled Items dialog.

However if I turn VSTO alerts on and run Outlook from the command line, I
get the following:

Could not load file or assembly 'StaffSuggestion, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=cfb1bb23cf1562da' or one of its dependencies.
Failed to grant permission to execute. (Exception from HRESULT: 0x80131418)

************** Exception Text **************
System.IO.FileLoadException: Could not load file or assembly
'StaffSuggestion, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=cfb1bb23cf1562da' or one of its dependencies. Failed to grant
permission to execute. (Exception from HRESULT: 0x80131418)
File name: 'StaffSuggestion, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=cfb1bb23cf1562da' ---> System.Security.Policy.PolicyException:
Execution permission cannot be acquired.
  at System.Security.SecurityManager.ResolvePolicy(Evidence evidence,
PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset,
PermissionSet& denied, Boolean checkExecutionPermission)
  at System.Security.SecurityManager.ResolvePolicy(Evidence evidence,
PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset,
PermissionSet& denied, Int32& securitySpecialFlags, Boolean
checkExecutionPermission)
  at
Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.HandleOnlineOffline(Exception e, String basePath, String filePath)
  at
Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.LoadStartupAssembly(EntryPoint
entryPoint, Dependency dependency, Dictionary`2 assembliesHash)
  at
Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ConfigureAppDomain()
  at
Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.LoadAssembliesAndConfigureAppDomain(IHostServiceProvider serviceProvider)
  at
Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.LoadEntryPointsHelper(IHostServiceProvider serviceProvider)

************** Loaded Assemblies **************
mscorlib
   Assembly Version: 2.0.0.0
   Win32 Version: 2.0.50727.42 (RTM.050727-4200)
   CodeBase:
file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Microsoft.VisualStudio.Tools.Applications.Runtime
   Assembly Version: 8.0.0.0
   Win32 Version: 8.0.50727.816
   CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Runtime/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Runtime.dll
----------------------------------------
Microsoft.Office.Tools.Common
   Assembly Version: 8.0.0.0
   Win32 Version: 8.0.50727.816
   CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.Office.Tools.Common/8.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.Common.dll
----------------------------------------
System
   Assembly Version: 2.0.0.0
   Win32 Version: 2.0.50727.42 (RTM.050727-4200)
   CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
   Assembly Version: 2.0.0.0
   Win32 Version: 2.0.50727.42 (RTM.050727-4200)
   CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------

I guess from this message I need to grant permission to the assembly, how
can I achieve this without the sample SetSecurity project?

Regards,

James
qanuc@gmx.at - 30 Jan 2007 13:17 GMT
Hi!
Afaik, there is no way to circumnavigate the CAS settings procedure.
You have to give permission to each library you intend to use in your
add-in
(I recently had to do so for dynamically loaded assemblies...)

 Q

Jazza schrieb:

> Hi,
>
[quoted text clipped - 86 lines]
>
> James
Ken Slovak - [MVP - Outlook] - 30 Jan 2007 15:46 GMT
Don't worry about the registrations in HKCR, those are automatic for you.
You definitely need to use SetSecurity or some other method of granting full
trust to your assembly. Your errors are typical of not setting the security.

In addition to SetSecurity make sure you are deploying Extensibility.dll and
possibly stdole.dll, the first and possibly the second aren't installed by
Office 2003. If using Framework 2.0 you also have to account for KB 908002
(http://support.microsoft.com/kb/908002) which is needed with Office 2003 in
cases where Office 2003 is installed before the .NET 2 Framework. You also
must ensure that the Office and Outlook PIA's are installed, which they
aren't by default.

The VSTO 2005 SE runtime must also be installed, it has the same componentID
as the VSTO 2005 runtime but you have to check the registry at
HKLM\Software\Microsoft\VSTO Runtime setup\v2.0.50727. If the correct
runtime is installed already there will be a REG_DWORD named Update that's
equal to 1.
See http://weblogs.asp.net/mnissen/archive/2005/10/26/428564.aspx and
http://weblogs.asp.net/mnissen/articles/427504.aspx for more information on
SetSecurity. Also see the walkthroughs starting at
http://msdn2.microsoft.com/en-us/library/aa537173(office.11).aspx and look
at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=196504&SiteID=1.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Hi,
>
[quoted text clipped - 102 lines]
>
> James

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.