Microsoft KB Archive/824015

= PRB: Office 2003 Managed Code Extension Does Not Load =

Article ID: 824015

Article Last Modified on 11/26/2007

-

APPLIES TO


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

-



SYMPTOMS
When you open a Microsoft Office Excel workbook or a Microsoft Office Word document, the managed code extension does not load. However, you do not receive an error message.



CAUSE
The _AssemblyLocation0 property and the _AssemblyName0 property in the workbook or the document provide details to the managed code loader about a managed code extension. If you encrypt the document properties, and then you change the value of the _AssemblyLocation0 property or the _AssemblyName0 property later by using any one of the following methods, the managed code extension will not load:
 * Use the build process in Microsoft Visual Studio .NET to build your managed code extension.

-or-
 * Use the Persistence Control that is included with Microsoft Visual Studio Tools for the Microsoft Office System.

-or-
 * Use the Properties window in Microsoft Windows Explorer.



RESOLUTION
To resolve this problem, decrypt the document properties of the workbook or the document before you change the value of the _AssemblyLocation0 property or the _AssemblyName0 property. Re-encrypt the document properties after you making your changes. To do this, follow the steps under &quot;Resolution&quot; in the &quot;More Information&quot; section of this article.



Steps to Reproduce the Behavior
 Create a new Excel workbook that has encrypted document properties:  Start Microsoft Office Excel 2003, and then create a new workbook. On the Tools menu, click Options. In the Options dialog box, click the Security tab. Under File encryption and settings, click Advanced. In the Choose an encryption type list box, click RC4, Microsoft Base Cryptographic Provider v1.0.</li> Click to select the check box for Encrypt document properties, and then click OK.</li> In the Password to open text box, type a password. Click OK. Type the password again when you are prompted to do so.</li> Save the workbook as C:\Encrypt.xls .</li> Close the workbook, and then quit Excel.</li></ol> </li> Create a new Excel workbook project: <ol style="list-style-type: lower-alpha;"> Start Visual Studio .NET 2003.</li> On the File menu, point to New, and then click Project.</li> Under Project Types, expand Microsoft Office System Projects, and then click Visual Basic Projects.</li> Under Templates, click Excel Workbook. Name the new project EncryptedBook, and then click OK.

The Microsoft Office Project Wizard starts.</li> In the Microsoft Office Project Wizard, click Use existing document, locate C:\Encrypt.xls, and then click Finish.</li></ol> </li>  Add the following code to the ThisWorkbook_Open procedure: MessageBox.Show(&quot;ThisWorkbook_Open&quot;) </li> Press F5 to build and then run the project.

The workbook opens. However, the message box does not appear.</li></ol>

Resolution
<ol> Open the C:\Encrypt.xls file in Excel.</li> Remove encryption from the document properties: <ol style="list-style-type: lower-alpha;"> On the Tools menu, click Options.</li> In the Options dialog box, click the Security tab.</li> <li>Under File encryption and settings, click Advanced.</li> <li>In the Encryption Type dialog box, click to clear the check box for Encrypt document properties, and then click OK.</li> <li>In the Options dialog box, click OK.</li></ol> </li> <li>Save the workbook, and then quit Excel.</li> <li>In Visual Studio .NET, open the EncryptedBook project.</li> <li>In Solution Explorer, click the project.</li> <li>On the View menu, click Properties Window.</li> <li>In Properties, change the value of the Assembly Link Location property to ..\EncryptedBook_bin, and then change the value of the Copy Assembly property to True.</li> <li>Press F5 to build and then run the project.

The workbook opens and the message box appears.</li></ol>

<div class="references_section">