FileIOPermission, Autorun from Network Share RRS feed

  • Question

  • Hi,

    I`ve got an executable Windows Form-Project built with the .NET 2.0 Framework. This works fine when started either from my local desktop or from a network share.

    My account has read/execute permission for the exe as well as for a custom config-File that is read from my exe when loaded. (locally and on the share)

    Now the exe is called from a shortcut that links to the network file and this shortcut  is put into the autorun, folder but:

    While booting my application throws an error "Request for the permission System.Security.Permission.FileIOPermission failed" which must be the loading of the config-file.

    Is the autorun-process started within another user context or is there something other that can be done to be able to execute my Windows application?
    Thursday, September 3, 2009 9:04 AM


All replies

  • I think the user context is different and that is reason exception is being thrown. You can impersonate the user in your windows application code so the logged on user context does'nt matter with your application execution.

    .Net Goodies
    Remember to click "mark as answered" when you get a correct reply to your question
    Thursday, September 3, 2009 9:17 AM
  • You need to use the .NET configuration management tool and increase the trust for the assembly. This seems to be a two hop problem and .NET by default does not allow you to run applications from a network share using a shortcut. You can get around this by using the .NET configuration manager and increasing the assembly trust.
    Thursday, September 3, 2009 11:04 AM
  • Thanx for the answers but i really do have a problem with increasing the assemby trust as the EXE should be available to all network users: when logging in they just have the autorun-shortcut and the EXE in the network share. So I`d need to set the trust level for the file on all PCs in the entire network.

    My programm shall replace an older version that is written in good old plain VB (not VB .NET) that didn't take care of any CAS rules :o(

    I'm not able to change the company's global security restrictions for .NET assemblies.


    Does anyone has other ideas how to get around this problem?

    Thursday, September 3, 2009 11:14 AM
  • As long as your stuck with .NET 2.0, you are also stuck with visiting each machine that uses the app and running Caspol.exe on it.  One solution is to upgrade everybody to .NET 3.5 SP1, it assigns full trust to network shares by default.

    Hans Passant.
    Friday, September 4, 2009 2:15 AM