Microsoft KB Archive/824002

= Errors occur after you change the security policy for a managed code solution =

Article ID: 824002

Article Last Modified on 5/11/2007

-

APPLIES TO


 * Microsoft Office Word 2007
 * Microsoft Office Word 2003
 * Microsoft Office Excel 2007
 * Microsoft Office Excel 2003
 * Microsoft Visual Studio Tools for the Microsoft Office System version 2003

-



SYMPTOMS
When you try to load a managed code extension that was created by using Microsoft Visual Studio Tools for the Microsoft Office System in either Microsoft Office Excel or Microsoft Office Word, you receive the following error message:

The current .NET security policy does not permit WordProject1 to run from the folder . Do not change the security policy in your computer. The .NET security policy is controlled by your administrator or the developer who wrote the custom macros. You can still edit and save the document. Contact your administrator or the author of this document for further assistance.

Alternatively, when you try to load a managed smart document solution in either Excel or Word, you receive the following error message:

The XML expansion pack or the Smart Document program is missing or invalid. Contact your system administrator or the person who provided this document.



CAUSE
This problem occurs because the change to the security policy does not take effect until the application is restarted. Managed code solutions for Excel and Word require that the solution have a code access security policy with full trust granted to the solution. If you have updated a security policy for your solution, and if you have not restarted all Office applications after the update, you may receive one of the error messages that are listed in the &quot;Symptoms&quot; section.



RESOLUTION
To resolve this problem, after you change a security policy, quit all Office applications before you load the managed code solution.

Note Make sure that all instances of Excel and Word are not running. To do this, examine the list of processes that are running in Windows Task Manager. If you use Word as your e-mail editor in Outlook, quit all instances of Outlook.



STATUS
This behavior is by design.



Steps to reproduce the behavior
 Create a new Word Document project:  On the File menu, point to New, and then click Project. The New Project dialog box appears. In the list of project types, double-click Microsoft Office System Projects, and then click Visual Basic Projects. In the list of project templates, click Word Document, and then click OK. The Microsoft Office Project Wizard appears. Make a note of the document location in the Office Project Wizard dialog box, and then click Finish.</li></ol> </li> On the Build menu, click Build Solution.</li> Start Word.</li> On the File menu, click Open to open the document for your project.

Result: The document opens without error.</li> On the File menu, click Close to close your document.</li> Leave Word running while you return to Visual Studio .NET.</li> In Solution Explorer, click the project name to select the project.</li> On the View menu, click Properties Window.</li> In the properties window, change the Assembly Link Location to C:\WordTest .</li> On the Build menu, click Build Solution.</li> Return to the instance of Word that is still open, and then click Open on the File menu to open the document again.

Result: You receive an error message.

If you quit all instances of Word that are running, and then you open the document again, the document opens without error.</li></ol>

<div class="references_section">