Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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 <FolderName>. 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.

↑ Back to the top


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 "Symptoms" section.

↑ Back to the top


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.

↑ Back to the top


Status

This behavior is by design.

↑ Back to the top


More information

Steps to reproduce the behavior

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

    Result: The document opens without error.
  5. On the File menu, click Close to close your document.
  6. Leave Word running while you return to Visual Studio .NET.
  7. In Solution Explorer, click the project name to select the project.
  8. On the View menu, click Properties Window.
  9. In the properties window, change the Assembly Link Location to C:\WordTest.
  10. On the Build menu, click Build Solution.
  11. 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.

↑ Back to the top


References

For additional information, see the following topics in the Visual Studio Tools for Office documentation:
  • "Troubleshooting in Office at Run Time"
  • "Security Requirements to Run Office Solutions"

↑ Back to the top


Keywords: KB824002, kbnofix, kbofficesmartdoc

↑ Back to the top

Article Info
Article ID : 824002
Revision : 5
Created on : 5/11/2007
Published on : 5/11/2007
Exists online : False
Views : 467