index > Visual Studio Tools for Office > Getting the ExecutingAssembly Location / SecurityException

Getting the ExecutingAssembly Location / SecurityException

Hi, I've added a reference to a class library assembly in my Office Project.

If I do :

System.Reflection.Assembly.GetExecutingAssembly().Location

from my Office application, it works fine. However, if I put the same code in my class library, I get a SecurityException when accessing the Location property when it's called from the Office application.

The goal of the class library is to offer some tools I can use from various .NET projects. In this particular case, I need to know the location of my Office application DLL and use it internally. Passing the path from the application isn't an option.

Does anyone have any idea how to fix this problem?

PS: I use Visual Studio 2005 Beta 1

Thanks, Martin


Martin Lapierre - .NET Consultant
DevInstinct

Any additional assebmly called from VSTO solution requires a separate FullTrust to execute.  Use caspol.exe to trust your library at either user or machine level.  For example:

caspol -u -ag All_Code -url  file://YourAssemblyName.dll FullTrust


Vadim Volkov

VSTO Team




Vadim Volko
Vadim Volkov
Right ... to access that property you'll need to have PathDiscoveryPermission.  If you want to only add one code group to your policy, instead of using a UrlMembershipCondition like above, you could strongly name your assemblies using the same key and then trust that single key.  I give instructions for how to do that here: http://blogs.msdn.com/shawnfa/archive/2005/04/14/408284.aspx

-Shawn


http://blogs.msdn.com/shawnfa
Shawn Farkas - MS
reply 3

You can use google to search for other answers

 

More Articles

• COM Addin, in frame work 1.1 , C# and outlook 2003, it wast wrok...
• Error with vsto
• ListObject binding Help
• ListObject
• Still Unable to Show/Hide NamedRange object from the ActionPane!!...
• vsto - .Net framework 2 security - publisher certificate as avida...
• Strange Behavior On File:/// link in Web Page - New Issue
• Creating new templates
• What is good way for handling about .pst(schedule, task)?
• Large dataset bound to ListObject
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Warning for using Excel.Worksheet.Activa
• Basic setup project for VSTO includes pr
• RemoveCustomization
• Can I create SharePoint Webparts with RTM?
• Save each page of a word merge as pdf file
• How to Freeze Worksheet Panes (C#)
• Error In Action Pane Add In's
• MS Office Automation Question?
• Intercepting Save related commands in Wo
• Make a certain menu invalid or disabled
• Help with Word Interop PLEASE!!! - more
• Accessing shared calendar occurrences
• Can I save information inside a Word Doc
• Outlook 2007 Form Regions and User Prope
• Outlook saves my mail to drafts instead

Hot Articles

• Excel ListObject.ListRows loses last dat
• Newbie understanding of Excel and VSTO
• refresh the reading pane
• Using the dll created by publishing my V
• Why VSTO?
• unload Smart Document on initialize
• Packaging Wizard - Root Installation Fol
• Accessing a Control on a Outlook Custom
• Any update on the shim for COM Add-in su
• How to implement a gallery in ribbon, it
• Excel Application Object question
• Can I create SharePoint Webparts with RTM?
• Unable to connect to the Remote oracle d
• Demonstration at VSLive Orlando
• Unable to rebind ListObject to data source

Recommend Articles

• VBA for Powerpoint
• Integrate my aplication
• Outlook plugin problem.
• Action Pane in SmartTag without VSTO
• Question regarding creating, saving and
• How to insert image into word 2003?
• custom command bar menu disappears off o
• VSTO add-in setup error accessing registry
• when an Excel file is Opened it takes mo
• Dragging and Dropping into a Word Document
• Accessing Sheets from a new class
• Excel 2007 VSTO Addin UDF
• How to add vsto in visual studio 2005 pr
• Showing Error while running the Setup
• Trying to force installer to use VSTOR.e