none
DLL, EXE Corflags changed after System.IO.File.Copy RRS feed

  • Question

  • Yep.  I didn't think it could be possible but it is happening here.

    Here are the details:

    Signed projects in solution.  Platform Target - AnyCPU, both release and debug.  I check the corflags of the executables or dlls in their respective /bin folders after a build.  I also checked the corflags of the files after the File.Copy migration. The environment is VS2008.  The OS is Win7 64bit.

    The corflags of ALL of the files before a System.IO.File.Copy are:

    Version   : v2.0.50727
    CLR Header: 2.5
    PE        : PE32
    CorFlags  : 9
    ILONLY    : 1
    32BIT     : 0
    Signed    : 1

    After a System.IO.File.Copy has been used to migrate the files to another location, the following corflags are present:

    Version   : v2.0.50727
    CLR Header: 2.5
    PE        : PE32
    CorFlags  : 11
    ILONLY    : 1
    32BIT     : 1
    Signed    : 1

    in other words, using the System.IO.File.Copy alters the corflags of files from the target platform of anyCPU to 32bit.

    After a lot of testing it appears that File.Copy's operations are technically broken because it alters the bit flags of the assemblies.

    Any help would be appreciated.

     

    Thursday, August 18, 2011 4:09 PM

Answers

  • "in other words, using the System.IO.File.Copy alters the corflags of files from the target platform of anyCPU to 32bit."

    I can't reproduce this behavior and it's very unlikely that File.Copy has anything to do with this. File.Copy simply calls the Win32 CopyFile function and that's completly unaware of .NET assemblies. Besides, modifying the flags after the assembly was signed would invalidate the signature.

    Are you sure you're looking at the correct files? Maybe there's something else in your environment that changes the flags?

    • Marked as answer by Paul Zhou Friday, August 26, 2011 4:48 AM
    Thursday, August 18, 2011 10:10 PM
    Moderator

All replies

  • "in other words, using the System.IO.File.Copy alters the corflags of files from the target platform of anyCPU to 32bit."

    I can't reproduce this behavior and it's very unlikely that File.Copy has anything to do with this. File.Copy simply calls the Win32 CopyFile function and that's completly unaware of .NET assemblies. Besides, modifying the flags after the assembly was signed would invalidate the signature.

    Are you sure you're looking at the correct files? Maybe there's something else in your environment that changes the flags?

    • Marked as answer by Paul Zhou Friday, August 26, 2011 4:48 AM
    Thursday, August 18, 2011 10:10 PM
    Moderator
  • Yes, I was going bonkers thinking it was a File.Copy problem.  The files were being altered before the copy.

    Monday, August 22, 2011 3:07 PM
  • I'm see a change in corflags after running an install package.  The file in the build directory has the following corflags:

     

    Version   : v2.0.50727
    CLR Header: 2.5
    PE        : PE32
    CorFlags  : 2
    ILONLY    : 0
    32BIT     : 1
    Signed    : 0

    After install I get:

     

    Version   : v2.0.50727
    CLR Header: 2.5
    PE        : PE32
    CorFlags  : 3
    ILONLY    : 1
    32BIT     : 1
    Signed    : 0

     

    Any thoughts?

    Monday, August 22, 2011 3:18 PM