AspNetCompiler - An attempt was made to download a program with the wrong format

I only create a 64-bit web application ( AssemblyA) and refer to another application that I created, which is also only 64-bit ( AssemblyB).

When I add AssemblyBas a link to AssemblyA, I get the following compilation error in Visual Studio:

ASPNETCOMPILER Failed to load file or assembly "AssemblyB" or one of its dependencies. An attempt was made to download a program with the wrong format.

Both target parameters of my application platform are set to x64, both Target Framework settings are equal to .Net Framework 4.6and Prefer 32bit is unchecked.

I tried to link to each dependent link AssemblyBin AssemblyA, making sure that the versions of all the dependent links are the same.

I used this question: How to determine if a .NET assembly was built for x86 or x64? to confirm that all referenced assemblies are either MSIL, or AMD64.

I used the command line tool aspnet_compiler.exewith the option turned on errorstackand got the following stack trace:

[BadImageFormatException]: Failed to load file or assembly "AssemblyB" or one of its dependencies. An attempt was made to download a program with the wrong format.

System.Reflection.RuntimeAssembly._nLoad (AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark & stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntro spection, Boolean suppressSecurityChecks)

System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String code Base, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark & sMailMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntros pection, Boolean suppressSecurityChecks)

System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark & stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)

System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark & stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)

System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark & stackMark, Boolean forIntrospection)

System.Reflection.Assembly.Load(String assemblyString)

System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)

[ConfigurationErrorsException]: "AssemblyB" . .

System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective)

System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomain BinDirectory()

System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai)

System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)

System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()

System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStar tInitListPath, Boolean & isRefAssemblyLoaded)

System.Web.Compilation.BuildManager.ExecutePreAppStart()

System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, Host ingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)

, . IIS, , , 32- , :

, . , 32-, IIS, .

.

?

+4

Source: https://habr.com/ru/post/1627714/


All Articles