PRB: Errors occur after you change the security policy for a managed code solution (824002)



The information in this article applies to:

  • Microsoft Office Word 2003
  • 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 <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.

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 errors that is listed in the "Symptoms" 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.

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.

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"

Modification Type:MajorLast Reviewed:3/23/2006
Keywords:kbOfficeSmartDoc kbnofix KB824002 kbAudDeveloper