ikel
ikel

Reputation: 1978

run c# app from network share

I'm new to c#, so please forgive me if i ask some entry level questions.

currently, I have a little windows form that have cancel button on it. I noticed that when i run it on local machine the cancel button works fine. but it gives me security exceptions when running from network location on xp machine. the exception is telling me I cannot call unmanaged code etc .... but my form only has one button and the code within eventhandler is: Application.Exit();

after googling around I found that I can make changes through mscorcfg.msc to give permission to intranet. this worked for me.

the other workaround I found is http://msdn.microsoft.com/en-us/library/aa288469(v=vs.71).aspx

however, this is a workaround for one machine only, what if I have a hundred machines????

so I assume there must be some other ways to deal with this problem, can anyone please help??

Upvotes: 2

Views: 2646

Answers (2)

Joel Coehoorn
Joel Coehoorn

Reputation: 416149

Update to a newer version of the framework. .Net no longer enforces this for network shares if you're running .Net 3.5 sp1 or later.

Upvotes: 3

aleroot
aleroot

Reputation: 72696

It is a feature of the .NET framework itself : Code Access Security.

By default, code on a network share will run with the security level of LocalIntranet that have a lower level of privilege than if it is run on the local drive that is a "secure" location.

You can use the tool caspool to get rid of this limitation and give trust execution to an executable also on a network location, so for example :

caspol -machine -addfulltrust program.exe

Upvotes: 3

Related Questions