Ji Zhou 每 MSFT
Hi Arnell,
Sorry about not making my response as clear as possible. Surely, your scenario could be achieved. To some point, it has some familiar features with the Server Deployment Model because we put the document to the network location, right If your document is stored at local driver, it will load the customization codes without any errors. But if you open it from network, the document is not recognized as trusted, even while the assembly in local driver is granted full trust. So you will receive the error message. To avoid this, you should use caspol.exe to trust the document too. The way is in the link I have already posted above. It is same with deploy document part in Server Deployment Model.
I also perform in my virtual machine, it works fine. The following is my steps:
1. Copy the assembly to my want installation directory, in this case, ※C:\LocalAssembly\ToDeploy.dll§.
2. Copy the document to a network location, in my case, ※\\sha-vjzho-vpcxp\Shared\ToDeploy.xlt§
3. Change the embedded manifest to point the assembly to the right place: ※C:\LocalAssembly\ToDeploy.dll§. In your scenario, you use the Environment Variable. I think it does not affect the result when I am using the exact path.
4. Use caspol to grant full trust to the assembly in a user level. Command line is as follow:
Caspol 每u 每ag All_Code 每url ※C:\LocalAssembly\ToDeploy.dll§ FullTrust 每n ※LocalAssembly§
5. Use caspol to grant full trust to the document in machine level. Command line:
Caspol 每m 每ag LocalIntranet_Zone 每url "\\sha-vjzho-vpcxp\Shared\ToDeploy.xlt※ FullTrust -n ※NetworkDocument§
Then I open the document ToDeploy.xlt from the trusted network location, it pops up a message box say ※Deploy Success§, which implemented in my codes. If you want to open the document from other network place, you should trust the new location again. It seems a little inconvenience, but I think it is designed to be so to ensure the security.
Thanks
Ji