views:

209

answers:

2

My C# application uses pointers and hence is complied using the "Allow Unsafe Code" setting. I know that it is quite difficult or not possible at all to run such an application from a network location.(or is there any way to run it??) What I would like to know is, is there any way to handle the error that occurs while trying to run this application from a network location and make the application fail gracefully. I am getting the following error... "Application has encountered a problem and needs to close". Exception Information contains the following code: 0xe0434f4d

+1  A: 

Change security settings (using the CASPOL utility) to allow this execution. it is not that difficult - you can / should at least put your intranet known locations into the intranet zone there ;)

otherwise - yes and no. You can not get that exception, but you can actually check / claim the needed CAS rights in code to make sure you have them in the first place.

CAS is like - complicated. And not many people know about it.

Check http://support.microsoft.com/kb/315529 as a starting point.

TomTom
+1 TomTom. You can use Visual Studio project settings too to do that in VS 2008 and 2010 too. Simply right click the project and select properties. Then go to the security tab.
Ikaso
A: 

From .NET 3.5 sp1 then running code from a network share gets the same rights as running on a local machine. You should be able to run unsafe code if the machine has .NET 3.5 sp1.

Arve
But if it's only .net 2.0, or .net 3.5 (no SP) then it will simply crash when running from the network. The only fix for this is to change the network permissions to make .net think that the LAN is a "trusted" location.
Jason Williams