Brian Wolfe

We are having a problem linking an assembly produced by Visual Studio 2005 to an existing Excel 2003 spreadsheet (.XLS) file. (The assembly is correctly linked to the Excel 2003 spreadsheet created by the Visual Studio 2005 project.)

With Visual Studio 2005 and Microsoft Visual Studio 2005 Tools for Office 2007 SE we have successfully built an install project that deploys a strongly named assembly ExcelWorkbookSimple.dll with ExcelWorkbookSimple.xls. This "app" just puts up a simple ActionPane. The ExcelWorkbookSimple.xls file can be copied anywhere and works -- starting the ActionPane -- as long as the installed directory containing ExcelWorkbookSimple.dll is available and has not been renamed.

We have tried adding the AssemblyLocation / AssemblyName custom properties using Excel and Windows Explorer with no success. Each time we get the following message:

"The current .NET security policy does not permit
ExcelWorkbookSimple to run from the folder C:\The\Actual\Path\.
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."

We are not trying to reference a LAN / network location, nor are we trying to access a web location. We are trying to access a folder on the same computer.

We tried

_AssemblyLocation0 = C:\The\Actual\Path\ and C:\The\Actual\Path
_AssemblyName0 = ExcelWorkbookSimple

and

_AssemblyLocation = C:\The\Actual\Path\ and C:\The\Actual\Path
_AssemblyName = ExcelWorkbookSimple

from both Excel and Windows Explorer.

caspol -lf did not initially show ExcelWorkbookSimple.dll had full trust.

caspol -rsp ExcelWorkbookSimple.dll showed the following before
and after adding full trust:

Microsoft (R) .NET Framework CasPol 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.

Resolving permissions for level = Enterprise
Resolving permissions for level = Machine
Resolving permissions for level = User

Grant =
<PermissionSet class="System.Security.PermissionSet"
version="1"
Unrestricted="true"/>

Success

Granting full trust worked as follows:

C:\The\Actual\Path>caspol -af ExcelWorkbookSimple.dll

Microsoft (R) .NET Framework CasPol 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.

Because all GAC assemblies always get full trust, the full trust list is no long
er meaningful. You should install any assemblies that are used in security policy
y in the GAC to ensure they are trusted.
The operation you are performing will alter security policy.
Are you sure you want to perform this operation (yes/no)
yes
Success

caspol -lf after granting full trust showed the assembly:

Microsoft (R) .NET Framework CasPol 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.

Security is ON
Execution checking is ON
Policy change prompt is ON

Level = Machine

Full Trust Assemblies:

...

22. ExcelWorkbookSimple 1.0.0.0 =
StrongName - 0024000004800000940000000602000000240000525341310004000001000100E7D33901080D61DBD1F68A4A9432F633B28233AB9572BA75763EAF9B59894EA45D36303BD2CB7669052E0508A2EB0C30BAE44E1A49FF43ECC978C100DB42E8A021F66A80F0B35668C8A44DFC5795349AC8C9FCC245FECDB539A964A059544CF2A9A67DE13D6C05A84DB31E36A9031772426E2DC5A1D8A6019F862F5762D176D4 name = ExcelWorkbookSimple version = 1.0.0.0
Success

Even after granting full trust we still get the same message.

Thanks



Re: Visual Studio Tools for Office Problem linking assembly to existing Excel file

Douglas H. Troy

Have you run the application manifest editor on your Excel document to verify that it indeed is pointed to the correct path for your assembly

If not, you can find that here: Application Manifest Editor Sample

If not, since you're installing your assembly in the GAC, have you tried leaving the assembly location empty Since, in theory, anything in the GAC can be 'found' from any location ...

Just some random thoughts of madness. ;)





Re: Visual Studio Tools for Office Problem linking assembly to existing Excel file

Dennis Wallentin

Brian,

Check out the following KB-article if that's relevant for the issue:
Incorrect assembly link location for an Excel 2003 workbook that has a file name with DBCS characters