New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running .Net Core 3.0 Winforms app targeting x86 in windows 10 #304

Open
pveliz opened this Issue Jan 8, 2019 · 3 comments

Comments

Projects
None yet
6 participants
@pveliz
Copy link

pveliz commented Jan 8, 2019

I'm trying to run a WinForms App targeting x86 but the application closes immediately and I'm got this error:

'WindowsFormsAppCore3.exe' (CoreCLR: DefaultDomain): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.0.0-preview-27122-01\System.Private.CoreLib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The program '[316] WindowsFormsAppCore3.exe: Program Trace' has exited with code 0 (0x0).
The program '[316] WindowsFormsAppCore3.exe' has exited with code -532462766 (0xe0434352).

How to replicate it:

First open File Explorer and create a folder to host your project. Then open a command prompt of your choice, move to the folder you have just created and then execute the following command:

dotnet new winforms

Open visual Studio 2019 Preview, Create a Blank Solution, then add the recently created project to the solution, then right click on the project -> properties -> Build -> Platform terget: x86 and then run it.

In the event viewer I got this:

Faulting application name: WindowsFormsAppCore3.exe, version: 1.0.0.0, time stamp: 0x5bf60478
Faulting module name: KERNELBASE.dll, version: 10.0.17134.441, time stamp: 0x428de48c
Exception code: 0xe0434352
Fault offset: 0x000000000003a388
Faulting process id: 0x1b7c
Faulting application start time: 0x01d4a761408d779b
Faulting application path: C:\XXXX\poc\WindowsFormsAppCore3\bin\Debug\netcoreapp3.0\WindowsFormsAppCore3.exe
Faulting module path: C:\Windows\System32\KERNELBASE.dll
Report Id: 20ffea93-24b8-4e77-bdbb-94b05dd2e04c
Faulting package full name: 
Faulting package-relative application ID: 

Other information that I got from WinDbg is this:

Microsoft (R) Windows Debugger Version 10.0.18303.1000 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.

CommandLine: C:\XXX\poc\WindowsFormsAppCore3\bin\Debug\netcoreapp3.0\WindowsFormsAppCore3.exe

************* Path validation summary **************
Response                         Time (ms)     Location
Deferred                                       srv*
Symbol search path is: srv*
Executable search path is: 
ModLoad: 00007ff6`59e50000 00007ff6`59ea7000   apphost.exe
ModLoad: 00007ffd`6d2a0000 00007ffd`6d481000   ntdll.dll
ModLoad: 00007ffd`6c760000 00007ffd`6c812000   C:\Windows\System32\KERNEL32.DLL
ModLoad: 00007ffd`69ad0000 00007ffd`69d43000   C:\Windows\System32\KERNELBASE.dll
ModLoad: 00007ffd`69880000 00007ffd`6997a000   C:\Windows\System32\ucrtbase.dll
(2924.4920): Break instruction exception - code 80000003 (first chance)
ntdll!LdrpDoDebuggerBreak+0x30:
00007ffd`6d36c93c cc              int     3
0:000> .sympath srv*
Symbol search path is: srv*
Expanded Symbol search path is: cache*;SRV*https://msdl.microsoft.com/download/symbols

************* Path validation summary **************
Response                         Time (ms)     Location
Deferred                                       srv*
0:000> .reload
Reloading current modules
.....
0:000> g
ModLoad: 00007ffd`16a20000 00007ffd`16ab4000   C:\Program Files\dotnet\host\fxr\3.0.0-preview-27122-01\hostfxr.dll
ModLoad: 00007ffd`16980000 00007ffd`16a16000   C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.0.0-preview-27122-01\hostpolicy.dll
ModLoad: 00007ffd`020d0000 00007ffd`0268b000   C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.0.0-preview-27122-01\coreclr.dll
ModLoad: 00007ffd`6d0e0000 00007ffd`6d181000   C:\Windows\System32\ADVAPI32.dll
ModLoad: 00007ffd`6a880000 00007ffd`6a91e000   C:\Windows\System32\msvcrt.dll
ModLoad: 00007ffd`6a820000 00007ffd`6a87b000   C:\Windows\System32\sechost.dll
ModLoad: 00007ffd`6c020000 00007ffd`6c144000   C:\Windows\System32\RPCRT4.dll
ModLoad: 00007ffd`6aa80000 00007ffd`6abd1000   C:\Windows\System32\ole32.dll
ModLoad: 00007ffd`6c2a0000 00007ffd`6c5c2000   C:\Windows\System32\combase.dll
ModLoad: 00007ffd`69d50000 00007ffd`69dca000   C:\Windows\System32\bcryptPrimitives.dll
ModLoad: 00007ffd`6a920000 00007ffd`6a948000   C:\Windows\System32\GDI32.dll
ModLoad: 00007ffd`69dd0000 00007ffd`69f62000   C:\Windows\System32\gdi32full.dll
ModLoad: 00007ffd`69980000 00007ffd`69a1f000   C:\Windows\System32\msvcp_win.dll
ModLoad: 00007ffd`6c5d0000 00007ffd`6c760000   C:\Windows\System32\USER32.dll
ModLoad: 00007ffd`69860000 00007ffd`69880000   C:\Windows\System32\win32u.dll
ModLoad: 00007ffd`6c150000 00007ffd`6c212000   C:\Windows\System32\OLEAUT32.dll
ModLoad: 00007ffd`6d210000 00007ffd`6d261000   C:\Windows\System32\SHLWAPI.dll
ModLoad: 00007ffd`56ac0000 00007ffd`56aca000   C:\Windows\SYSTEM32\VERSION.dll
ModLoad: 00007ffd`690b0000 00007ffd`690d5000   C:\Windows\SYSTEM32\bcrypt.dll
ModLoad: 00007ffd`6d010000 00007ffd`6d03d000   C:\Windows\System32\IMM32.DLL
(2924.4920): Unknown exception - code 04242420 (first chance)
ModLoad: 00007ffc`e09e0000 00007ffc`e11b8000   C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.0.0-preview-27122-01\System.Private.CoreLib.dll
ModLoad: 00007ffd`08070000 00007ffd`081c4000   C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.0.0-preview-27122-01\clrjit.dll
ModLoad: 00007ffd`69630000 00007ffd`69641000   C:\Windows\System32\kernel.appcore.dll
ModLoad: 00000208`05840000 00000208`05848000   C:\XXX\poc\WindowsFormsAppCore3\bin\Debug\netcoreapp3.0\WindowsFormsAppCore3.dll
ModLoad: 00000208`05840000 00000208`05848000   WindowsFormsAppCore3.exe
(2924.4920): C++ EH exception - code e06d7363 (first chance)
(2924.4920): C++ EH exception - code e06d7363 (first chance)
(2924.4920): C++ EH exception - code e06d7363 (first chance)
(2924.4920): C++ EH exception - code e06d7363 (first chance)
(2924.4920): C++ EH exception - code e06d7363 (first chance)
(2924.4920): CLR exception - code e0434352 (first chance)
(2924.4920): CLR exception - code e0434352 (!!! second chance !!!)
KERNELBASE!RaiseException+0x68:
00007ffd`69b0a388 488b8c24c0000000 mov     rcx,qword ptr [rsp+0C0h] ss:0000006d`a9badde0=0000402aa92ca8eb

Any idea how to solve this?

Thank you

@danmosemsft

This comment has been minimized.

Copy link
Member

danmosemsft commented Jan 8, 2019

-532462766 (0xe0434352). is the code for "some managed exception"

Can you get a managed callstack in windbg? Something like this, from memory

sxe ld coreclr    // break on coreclr load
g    // go
// it will break on coreclr load
.loadby sos coreclr   // find sos.dll next to coreclr.dll
sxe clr   // break on managed exceptions
g   // go
// hits exception
!pe -nested   // dump exception
!clrstack   // dump managed stack
@pveliz

This comment has been minimized.

Copy link

pveliz commented Jan 9, 2019

Please let me know if this will help, if not, please let me know the steps to get the info that you need.

Microsoft (R) Windows Debugger Version 10.0.18303.1000 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.

CommandLine: C:\XXXXX\poc\WindowsFormsAppCore3\bin\Debug\netcoreapp3.0\WindowsFormsAppCore3.exe

************* Path validation summary **************
Response                         Time (ms)     Location
Deferred                                       srv*
Symbol search path is: srv*
Executable search path is: 
ModLoad: 00007ff6`ce1e0000 00007ff6`ce237000   apphost.exe
ModLoad: 00007ffd`6d2a0000 00007ffd`6d481000   ntdll.dll
ModLoad: 00007ffd`6c760000 00007ffd`6c812000   C:\Windows\System32\KERNEL32.DLL
ModLoad: 00007ffd`69ad0000 00007ffd`69d43000   C:\Windows\System32\KERNELBASE.dll
ModLoad: 00007ffd`69880000 00007ffd`6997a000   C:\Windows\System32\ucrtbase.dll
(313c.e70): Break instruction exception - code 80000003 (first chance)
ntdll!LdrpDoDebuggerBreak+0x30:
00007ffd`6d36c93c cc              int     3
0:000> .sympath srv*
Symbol search path is: srv*
Expanded Symbol search path is: cache*;SRV*https://msdl.microsoft.com/download/symbols

************* Path validation summary **************
Response                         Time (ms)     Location
Deferred                                       srv*
0:000> .reload
Reloading current modules
.....
0:000> sxe ld coreclr
0:000> g
ModLoad: 00007ffd`34240000 00007ffd`342d4000   C:\Program Files\dotnet\host\fxr\3.0.0-preview-27122-01\hostfxr.dll
ModLoad: 00007ffd`24220000 00007ffd`242b6000   C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.0.0-preview-27122-01\hostpolicy.dll
ModLoad: 00007ffd`027c0000 00007ffd`02d7b000   C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.0.0-preview-27122-01\coreclr.dll
ntdll!NtMapViewOfSection+0x14:
00007ffd`6d33aea4 c3              ret
0:000> .loadby sos coreclr
0:000> sxe clr
0:000> g
ModLoad: 00007ffd`6d0e0000 00007ffd`6d181000   C:\Windows\System32\ADVAPI32.dll
ModLoad: 00007ffd`6a880000 00007ffd`6a91e000   C:\Windows\System32\msvcrt.dll
ModLoad: 00007ffd`6a820000 00007ffd`6a87b000   C:\Windows\System32\sechost.dll
ModLoad: 00007ffd`6c020000 00007ffd`6c144000   C:\Windows\System32\RPCRT4.dll
ModLoad: 00007ffd`6aa80000 00007ffd`6abd1000   C:\Windows\System32\ole32.dll
ModLoad: 00007ffd`6c2a0000 00007ffd`6c5c2000   C:\Windows\System32\combase.dll
ModLoad: 00007ffd`69d50000 00007ffd`69dca000   C:\Windows\System32\bcryptPrimitives.dll
ModLoad: 00007ffd`6a920000 00007ffd`6a948000   C:\Windows\System32\GDI32.dll
ModLoad: 00007ffd`69dd0000 00007ffd`69f62000   C:\Windows\System32\gdi32full.dll
ModLoad: 00007ffd`69980000 00007ffd`69a1f000   C:\Windows\System32\msvcp_win.dll
ModLoad: 00007ffd`6c5d0000 00007ffd`6c760000   C:\Windows\System32\USER32.dll
ModLoad: 00007ffd`69860000 00007ffd`69880000   C:\Windows\System32\win32u.dll
ModLoad: 00007ffd`6c150000 00007ffd`6c212000   C:\Windows\System32\OLEAUT32.dll
ModLoad: 00007ffd`6d210000 00007ffd`6d261000   C:\Windows\System32\SHLWAPI.dll
ModLoad: 00007ffd`56ac0000 00007ffd`56aca000   C:\Windows\SYSTEM32\VERSION.dll
ModLoad: 00007ffd`690b0000 00007ffd`690d5000   C:\Windows\SYSTEM32\bcrypt.dll
ModLoad: 00007ffd`6d010000 00007ffd`6d03d000   C:\Windows\System32\IMM32.DLL
(313c.e70): Unknown exception - code 04242420 (first chance)
ModLoad: 00007ffc`ff690000 00007ffc`ffe68000   C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.0.0-preview-27122-01\System.Private.CoreLib.dll
ModLoad: 00007ffd`03bc0000 00007ffd`03d14000   C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.0.0-preview-27122-01\clrjit.dll
ModLoad: 00007ffd`69630000 00007ffd`69641000   C:\Windows\System32\kernel.appcore.dll
ModLoad: 000001cd`8ec80000 000001cd`8ec88000   C:\XXXXX\poc\WindowsFormsAppCore3\bin\Debug\netcoreapp3.0\WindowsFormsAppCore3.dll
ModLoad: 000001cd`8ec80000 000001cd`8ec88000   WindowsFormsAppCore3.exe
(313c.e70): C++ EH exception - code e06d7363 (first chance)
(313c.e70): C++ EH exception - code e06d7363 (first chance)
(313c.e70): C++ EH exception - code e06d7363 (first chance)
(313c.e70): C++ EH exception - code e06d7363 (first chance)
(313c.e70): C++ EH exception - code e06d7363 (first chance)
(313c.e70): CLR exception - code e0434352 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
KERNELBASE!RaiseException+0x68:
00007ffd`69b0a388 488b8c24c0000000 mov     rcx,qword ptr [rsp+0C0h] ss:00000023`147fe160=0000eb93b9028502
0:000> !pe -nested
Exception object: 000001cd909d0e80
Exception type:   System.BadImageFormatException
Message:          Could not load file or assembly 'C:\XXXXX\poc\WindowsFormsAppCore3\bin\Debug\netcoreapp3.0\WindowsFormsAppCore3.dll'. An attempt was made to load a program with an incorrect format.
InnerException:   <none>
StackTrace (generated):
<none>
StackTraceString: <none>
HResult: 8007000b
0:000> !clrstack
OS Thread Id: 0xe70 (0)
        Child SP               IP Call Site
GetFrameContext failed: 1
0000000000000000 0000000000000000 
0:000> !DumpObj /d 000001cd909d0e80
Name:        System.BadImageFormatException
MethodTable: 00007ffcffa46380
EEClass:     00007ffcff701448
Size:        160(0xa0) bytes
File:        C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.0.0-preview-27122-01\System.Private.CoreLib.dll
Fields:
              MT    Field   Offset                 Type VT     Attr            Value Name
00007ffcffa6f0f0  40001a7        8        System.String  0 instance 0000000000000000 _className
00007ffcffa78728  40001a8       10 ...ection.MethodBase  0 instance 0000000000000000 _exceptionMethod
00007ffcffa6f0f0  40001a9       18        System.String  0 instance 000001cd909d17f0 _message
00007ffcffa67f80  40001aa       20 ...tions.IDictionary  0 instance 0000000000000000 _data
00007ffcffa6f340  40001ab       28     System.Exception  0 instance 0000000000000000 _innerException
00007ffcffa6f0f0  40001ac       30        System.String  0 instance 0000000000000000 _helpURL
00007ffcffa6f680  40001ad       38        System.Object  0 instance 0000000000000000 _stackTrace
00007ffcffa6f680  40001ae       40        System.Object  0 instance 0000000000000000 _watsonBuckets
00007ffcffa6f0f0  40001af       48        System.String  0 instance 0000000000000000 _stackTraceString
00007ffcffa6f0f0  40001b0       50        System.String  0 instance 0000000000000000 _remoteStackTraceString
00007ffcffa71e80  40001b1       78         System.Int32  1 instance                0 _remoteStackIndex
00007ffcffa6f680  40001b2       58        System.Object  0 instance 0000000000000000 _dynamicMethods
00007ffcffa71e80  40001b3       7c         System.Int32  1 instance      -2147024885 _HResult
00007ffcffa6f0f0  40001b4       60        System.String  0 instance 0000000000000000 _source
00007ffcffa71358  40001b5       68        System.IntPtr  1 instance                0 _xptrs
00007ffcffa71e80  40001b6       80         System.Int32  1 instance       -532462766 _xcode
00007ffcffa2cfb0  40001b7       70       System.UIntPtr  1 instance                0 _ipForWatsonBuckets
00007ffcffa6f680  40001a6       68        System.Object  0   shared           static s_EDILock
                                 >> Domain:Value  000001cd8edc4c20:NotInit  <<
00007ffcffa6f0f0  40001f0       88        System.String  0 instance 000001cd909d0dc0 _fileName
00007ffcffa6f0f0  40001f1       90        System.String  0 instance 000001cd909a13c0 _fusionLog
0:000> !U /d 0000000000000000
Unmanaged code
00000000`00000000 ??              ???
00000000`00000001 ??              ???
00000000`00000002 ??              ???
00000000`00000003 ??              ???
00000000`00000004 ??              ???
00000000`00000005 ??              ???
00000000`00000006 ??              ???
00000000`00000007 ??              ???
00000000`00000008 ??              ???
00000000`00000009 ??              ???

Thank you

@merriemcgaw merriemcgaw added this to the 3.0 milestone Jan 14, 2019

@wjk

This comment has been minimized.

Copy link

wjk commented Jan 18, 2019

@pveliz What's probably happening here is that only the managed DLL is compiled as x86. The rest (CoreCLR, launcher EXE, etc.) is compiled as x64. As we all know, we cannot mix-and-match two architectures in the same process, and the exception message is stating this (albeit in a rather unclear manner). Hence, changing the architecture in the Properties dialog is the wrong way to build a 32-bit application. The correct way (AFAIK) is to add the following code to your csproj:

<PropertyGroup>
  <RuntimeIdentifier>win-x86</RuntimeIdentifier>
</PropertyGroup>

Then restore and rebuild the project. Note that doing this may cause VS/.NET CLI to download x86 versions of the entire .NET Core runtime, which may take a while. Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment