简体   繁体   中英

Could not load file or assembly... An attempt was made to load a program with an incorrect format

I am having issues with a dll that I made reference to in a visual studio website project. It works fine on my local machine. The file is in the bin folder of the project, but when I uploaded it to my web server, I get the following error.

Could not load file or assembly 'phdapinet' or one of its dependencies. An attempt was made to load a program with an incorrect format. 

It is almost like it can't see the file in the bin. I looked through the code VS exported when I published it, and I don't even see a reference to the file anywhere. is it just supposed to automatically check the bin folder? Or is there something I am missing.

Here is the stack trace as well.

    [BadImageFormatException: Could not load file or assembly 'phdapinet' 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) +210
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +242
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +17
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +122

[ConfigurationErrorsException: Could not load file or assembly 'phdapinet' 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) +12761078
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +503
   System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +142
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +203
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +152
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151

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

Sorry I am new to asp.net and web programming, and still am trying to figure alot out.

Allan was correct.

It was a 32 bit file. I enabled 32 bit applications and it fixed that issue.

change publish settings: configuration - Test(/debug/release) Any CPU

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question Could not load file or assembly... An attempt was made to load a program with an incorrect format (System.BadImageFormatException) Could not load file or assembly 'SharpSvn' or one of its dependencies. An attempt was made to load a program with an incorrect format Could not load file or assembly 'MyLibrary' or one of its dependencies. An attempt was made to load a program with an incorrect format Could not load file or assembly ... An attempt was made to load a program with an incorrect format (System.BadImageFormatException) Could not load file or assembly xxx or one of its dependencies. An attempt was made to load a program with an incorrect format. Could not load file or assembly 'xxx' or one of its dependencies. An attempt was made to load a program with an incorrect format BadImageFormatException Could not load file or assembly or one of its dependencies. An attempt was made to load a program with an incorrect format Could not load file or assembly 'MWArray' or one of its dependencies. An attempt was made to load a program with an incorrect format Could not load file or assembly '...' or one of its dependencies. An attempt was made to load a program with an incorrect format Could not load file or assembly 'sapnco' or one of its dependencies. An attempt was made to load a program with an incorrect format
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM