Skip to content

Commit 6cc33d0

Browse files
author
William Li
committed
Fix P/Invoke signatures for the resource updater.
Port dotnet/sdk#3310 by @peterhuene The resource updater was not specifying a CharSet for the Windows API P/Invoke signatures and therefore the ANSI versions of the APIs were being used. This caused an unhandled exception when customizing the apphost on Windows when the intermediate apphost path contained Unicode characters because the ANSI resource updating API couldn't find the file. Fixes ABdotnet/core-setup#900429. Commit migrated from dotnet/core-setup@0059721
1 parent 1cad465 commit 6cc33d0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/installer/managed/Microsoft.NET.HostModel/AppHost/ResourceUpdater.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ private sealed class Kernel32
2121
// Native methods for updating resources
2222
//
2323

24-
[DllImport(nameof(Kernel32), SetLastError=true)]
24+
[DllImport(nameof(Kernel32), CharSet = CharSet.Unicode, SetLastError=true)]
2525
public static extern SafeUpdateHandle BeginUpdateResource(string pFileName,
2626
[MarshalAs(UnmanagedType.Bool)]bool bDeleteExistingResources);
2727

@@ -71,7 +71,7 @@ public enum LoadLibraryFlags : uint
7171
LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020
7272
}
7373

74-
[DllImport(nameof(Kernel32), SetLastError=true)]
74+
[DllImport(nameof(Kernel32), CharSet = CharSet.Unicode, SetLastError=true)]
7575
public static extern IntPtr LoadLibraryEx(string lpFileName,
7676
IntPtr hReservedNull,
7777
LoadLibraryFlags dwFlags);

0 commit comments

Comments
 (0)