Friday, November 06, 2009

.Net Application on a network share

I'd developed a .net framework 2.0 winform application for a customer which had to be started on a client pc from a network share. I'd already had framework 3.5 sp1 on my machine, but with setting the .net target right I thought I made solid solution.

The customer could not start it. They got a System.Security.Security exception when starting the application on a client with .net framework 2.0 from the network. When copying the application on the client machine first, it started with no problems.

On clients which already had framework 3.5 sp1 there was no problem starting the application from the network share.

The answer lies in some sort of trust policies, which are changed (or gone) on framework 3.5

By giving the share full trust of the client:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe -m -ag 1 -url "file:////\\computername\sharename\*" FullTrust -exclusive on

The application can be started on a client with .net framework 2.0 from a network share.

NOTE: do not run this command twice on the same computer, the full trust does not work anymore!


Rob said...

Does this statement function as a kind of 'toggle'function? So if you run it the third time, it will be working again?

Frank said...

Probably not, given the option "on" in the command. But I have not tested it!