You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.
By default, Visual Studio 2022 uses a 64-bit MSBuild, unlike earlier versions that used a 32-bit MSBuild. When I follow the instructions here, step 6. 'The OS should now build.' fails with the following message:
11>D:\Source\Repos\FlingOS\Kernel\Kernel\bin\Debug\Kernel.dll : error LDR0003: Library Loader encountered an unexpected error. Could not load file or assembly 'file:///D:\Source\Repos\FlingOS\Kernel\Kernel\bin\Debug\Kernel.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
11>D:\Source\Repos\FlingOS\Kernel\Kernel\bin\Debug\Kernel.dll : error LDR0003: at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
11>D:\Source\Repos\FlingOS\Kernel\Kernel\bin\Debug\Kernel.dll : error LDR0003: at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
11>D:\Source\Repos\FlingOS\Kernel\Kernel\bin\Debug\Kernel.dll : error LDR0003: at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
11>D:\Source\Repos\FlingOS\Kernel\Kernel\bin\Debug\Kernel.dll : error LDR0003: at System.Reflection.Assembly.LoadFrom(String assemblyFile)
11>D:\Source\Repos\FlingOS\Kernel\Kernel\bin\Debug\Kernel.dll : error LDR0003: at Drivers.Compiler.LibraryLoader.LoadILLibraryFromFile(String FilePath) in D:\Source\Repos\FlingOS\Drivers\Compiler\LibraryLoader.cs:line 74
An attempt was made to load a program with an incorrect format.
What is happening is the MSBuild task, built under configuration Any CPU, is being run as a 64-bit process by Visual Studio. However, the Kernel binary, built under configuration x86, is a 32-bit file. Hence the 'incorrect format' exception.
The solution here is to run the 32-bit MSBuild task instead. Several ways exist to do that, in my case I added Architecture="x86" to the following lines in Kernel.csproj ie.
Microsoft guidance specifically says, 'This change is backward compatible... we recommend making this change unconditionally and not trying to detect Visual Studio 2022'
The x86/32-bit kernel now compiles successfully.
The text was updated successfully, but these errors were encountered:
By default, Visual Studio 2022 uses a 64-bit MSBuild, unlike earlier versions that used a 32-bit MSBuild. When I follow the instructions here, step 6. 'The OS should now build.' fails with the following message:
An attempt was made to load a program with an incorrect format.
What is happening is the MSBuild task, built under configuration
Any CPU
, is being run as a 64-bit process by Visual Studio. However, theKernel
binary, built under configurationx86
, is a 32-bit file. Hence the 'incorrect format' exception.This exact issue was written about in a Microsoft blog, here: https://devblogs.microsoft.com/dotnet/msbuild-and-64-bit-visual-studio-2022/
The solution here is to run the 32-bit MSBuild task instead. Several ways exist to do that, in my case I added
Architecture="x86"
to the following lines inKernel.csproj
ie.Microsoft guidance specifically says, 'This change is backward compatible... we recommend making this change unconditionally and not trying to detect Visual Studio 2022'
The x86/32-bit kernel now compiles successfully.
The text was updated successfully, but these errors were encountered: