Click here to Skip to main content
16,022,122 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am getting the following when I try to run ANY .NET, even a basic .NET form with no real coding behind it yet - this is on my local host. I'm trying to be able to run my app locally

Assembly Load Trace: The following information can be helpful to determine why the assembly 'VijilconDefender' could not be loaded.


=== Pre-bind state information ===
LOG: DisplayName = VijilconDefender
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: VijilconDefender | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/inetpub/wwwroot/VijilconDefender/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\VijilconDefender\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\VijilconDefender\web.config
LOG: Using host configuration file: C:\Users\Owner\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/vs/aa637b59/c148c1b3/VijilconDefender.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/vs/aa637b59/c148c1b3/VijilconDefender/VijilconDefender.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/VijilconDefender/bin/VijilconDefender.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

Stack Trace:


[BadImageFormatException: Could not load file or assembly 'VijilconDefender' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +232
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +113
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +23
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +48

[ConfigurationErrorsException: Could not load file or assembly 'VijilconDefender' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +767
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +256
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +58
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +287
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +69
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +137
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +172
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +854

[HttpException (0x80004005): Could not load file or assembly 'VijilconDefender' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +719


What I have tried:

I have tried seeing the build output to x86, and changing the application pool to enable 32 bit applications. Even if I change from .NET 4.7.2 to .NET 2.0, it doesn't change the error at all. I don't know what I'm doing wrong, or what I can do to get a basic .NET form to come up on my local host, but any help is greatly appreciated...
Posted

Quote:
An attempt was made to load a program with an incorrect format
That usually means you're trying to load a 64-bit assembly in a 32-bit process, or vice-versa.

Since this appears to be your own assembly - the only reference Google can find is your own StackOverflow question[^] - there's not much anyone can do to help you. You need to check the build target set for the assembly you're trying to load, and make sure the application that's trying to load it matches.
 
Share this answer
 
Right it's the same question on StackOverflow - yeah, it's my own assembly, but it's very basic - it has almost no code in it - I'm just trying to get a very simple .NET app to work on my localhost. I have set the build target to x86, and the app pool to enable 32 bit. I'm sure I have a 32/64 mismatch somewhere but for the life of me I can't figure out where... It's IIS trying to load the application. I'm not sure where else to look?
 
Share this answer
 
I made some changes, and now I'm getting this error :
Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I've checked that the most recent package is installed, and I've checked my web.config for the assembly reference:
<dependentassembly>
<assemblyidentity name="Newtonsoft.Json"
="" publickeytoken="30AD4FE6B2A6AEED" culture="neutral">
<bindingredirect oldversion="0.0.0.0-6.0.0.0" newversion="6.0.0.0">


The Newtonsoft.Json file exists in bin and is version 4.5, which is what I expect. I'm not sure what else might cause this issue, but seems like somehow Newtonsoft.Json is the culprit here. I'm just not sure how to resolve. any help is appreciated!
 
Share this answer
 
Comments
Richard Deeming 4-Oct-24 3:16am    
Neither of your "solutions" are actually solutions. Don't post them as such.

Also, 6.0.0.0 is far from "the latest version" of Newtonsoft.Json - the latest version is 13.0.3[^].

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900