System.IO.File.SetAccessControl on WS2008 (x64) RRS feed

  • Question

  • User1272547317 posted


    I have deployment project of my web application in which I add some security on files.







    fileName = @"C:\WINDOWS\SYSTEM32\myFile.dll";

    FileSecurity fSecurity = System.IO.File.GetAccessControl(fileName);


    fSecurity.AddAccessRule(new FileSystemAccessRule("NETWORK SERVICE", FileSystemRights.FullControl, AccessControlType.Allow));




    .SetAccessControl(fileName, fSecurity);


    This code works properly on WS2003 32bits, WS2008 32 bits but not WS2008 64 bits (Code is executed, no exception is generated but NETWORK SERVICE is not set on file).

    When I execute this in simple test exe on WS2008 64 bits - this works also fine .

    The only difference in my code of the installer is property: TargetPlatform = x64

    I dont found any help on internet.. help would be very appreciated - i'm perplex on this...




    Wednesday, March 30, 2011 9:48 AM

All replies

  • User470413944 posted


    As far as I know x64 dll may placed in SysWOW64 folder if there is an x64 system.

    If you are using x86 dll files in references please set TargetPlatform = AnyCPU.

    I'm looking forward for your test result.

    Tuesday, April 5, 2011 5:52 AM
  • User1272547317 posted


    Thank you for your help.

    In fact msi installer copy DLL in :

    - windows\system32 where security file are not changed by msi

    - windows\SysWOW64 where security file are changed properly by msi

    Note that file is DLL extension but is not really a real DLL, it is just a binary file not compiled.

    I cannot use TargetPlatform = AnyCPU because if I'm using this option : dll is copied in system32 on 32 bits system and copied in SysWOW64 in 64 bits system. but I need to have always my files in system32 (because my website is using this path only).

    Wednesday, April 6, 2011 4:13 AM
  • User470413944 posted


    As far as I know, you can try to exclude this file from web setup project, then add a custom action which copy this file to system32 folder.

    I hope this can be helpful for you.

    Friday, April 8, 2011 5:26 AM
  • User1272547317 posted

    Yes, it could be a good option. I will look in this way.

    Thank you for you help.

    Sunday, April 10, 2011 6:24 AM