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
32-bit binaries don't work #901
Comments
@nguerrera you had some context on this. Can you share any info. @fahadash do you need the image to be marked as 32-bit or can you just run it with the 32-bit |
I need image to be 32 bit. I am referencing a com interop 32 bit assembly. |
I've just hit the same problem. I need a 32 bit image for interop as well. I just experimented. Visual studio is using the path environment variable to locate dotnet.exe so the temporary fix seems to be to ensure that 32 is higher in the search order than 64. However I think this is really something the programming environment should handle not the user externally. |
By default, VS (and dotnet run) will just use the dotnet.exe that comes first on your PATH to run the application. So, one (very inconvenient, ugly) approach is to make sure c:\Program Files (x86)\dotnet comes before c:\Program Files\dotnet on PATH before launching VS. But since that's global, it will give you the opposite problem: failure to run x64 apps. Better option: you can override the default `$(RunCommand)~ to redirect to the more appropriate dotnet:
<Project>
<PropertyGroup
Condition="'$(OS)' == 'Windows_NT' and
'$(PlatformTarget)' == 'x86' and
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
'$(SelfContained)' != 'true'"
>
<RunCommand>$(MSBuildProgramFiles32)\dotnet\dotnet</RunCommand>
</PropertyGroup>
</Project> This says: if I'm evaluating the project on Windows and I'm targeting x86 with a framework-dependent .NET Core app, use dotnet from Program Files(x86). As a cheap fix. we could consider putting this directly in the SDK as the new default. I have some more elaborate thoughts on how to make the experience switching between x86 and x64 to account for scenarios other than just F5 and where dotnet 32-bit/64-bit are in locations other the Program Files defaults. I plan to write those ideas up soon, but hopefully above is enough to keep folks unblocked... |
@nguerrera thanks for help! |
I think that's the wrong link, did you mean MSBuild .Targets Files? Using that I've added a specific x64 override as well do no matter your environment variable order it'll pick the right version for the platform if you specify the platform. AnyCPU will use the default.
|
Both links have info about Directory.Build.targets/props |
Glad that worked for you. Having the symmetric case for x64 handled is goodness. Thanks for sharing that improvement. |
You can simplify handling both x86 and x64 by using a single property group and moving the PlatformTarget condition to the RunCommand: <Project>
<PropertyGroup
Condition="'$(OS)' == 'Windows_NT' and
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
'$(SelfContained)' != 'true'"
>
<RunCommand Condition="'$(PlatformTarget)' == 'x86'">$(MSBuildProgramFiles32)\dotnet\dotnet</RunCommand>
<RunCommand Condition="'$(PlatformTarget)' == 'x64'">$(ProgramW6432)\dotnet\dotnet</RunCommand>
</PropertyGroup>
</Project> |
Closing this as a duplicate of https://github.com/dotnet/cli/issues/7532 |
Regardless of what app type (Console, MVC Web, etc), you compile a 32-bit binary and it crashes.
I have tried the following steps in Windows 7, 10, VS2015 CE and VS2017 CE.
I have Windows 10, Visual Studio 2017. .NET Core App (any kind) will certifiably crash. Here is what you have to do: Start VS2017, Start a new .NET Core Console App, change the build settings to compile x86, hit play button. That's right! no code change, just the wizard generated "hello world" crashes immediately upon start. It has been going on since .NET Core 1.0, I thought they fixed it in 1.1; I have been searching internet for so long and exhausted possibilities I would love to get this fixed because I have a use case to run x86.
It has been going on since 1.0, and the latest one still crashes. Any solutions folks?
The text was updated successfully, but these errors were encountered: