none
HELP An error:An attempt was made to load a program with an incorrect format.

    Question

  • I use a lib called needleseekAPI.dll. It is written in c++ using CLR. I can use it in console application. When I want to change my application to a webservice. I add the webservice needleseekAPI.dll but occured this error.

    My OS is windows server SP1 64bit, Visual Studio's version is 2010. I have searched the same problem. They just say that change the IIS Application Pool's Enable 32-bit Application to true. Someone said that change the Project Properties in Visual Studio's Build->platform target to Any CPU or X86. It didn't work at.

    The whole error log are here:

     

     

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

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.BadImageFormatException: Could not load file or assembly 'NeedleSeekAPI' or one of its dependencies. An attempt was made to load a program with an incorrect format.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

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

    WRN: Assembly binding logging is turned OFF.
    To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
    Note: There is some performance penalty associated with assembly bind failure logging.
    To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
    

    Stack Trace:

    [BadImageFormatException: Could not load file or assembly 'NeedleSeekAPI' 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, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
      System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39
      System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132
      System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +144
      System.Reflection.Assembly.Load(String assemblyString) +28
      System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46
    
    [ConfigurationErrorsException: Could not load file or assembly 'NeedleSeekAPI' 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) +618
      System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +209
      System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
      System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
      System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +94
      System.Web.Compilation.BuildManager.CallPreStartInitMethods() +332
      System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +591
    
    [HttpException (0x80004005): Could not load file or assembly 'NeedleSeekAPI' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
      System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8950644
      System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
      System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258
    


     

    • Moved by Paul Zhou Thursday, January 20, 2011 5:20 AM ASP.NET (From:Visual C# General)
    Saturday, January 15, 2011 7:00 AM

All replies


  • You should probably try asking this on the asp.net forums (http://forums.asp.net/).
     
    They will probably ask you one key question which I do not see in your post, which is, "Does the dll work correctly on this same machine in an a non-webservice project?".  The key to the error may be the phrase "... or one of its dependencies.".

    --
    Mike
    Saturday, January 15, 2011 2:20 PM
  • Hi worldterminator,

     

    Welcome to the MSDN forum!

     

    According to your description, I’d like to move your thread to off-topic because it is a problem related to ASP.NET. ASP.NET technology is not support here.

    I suggest that you can post here: http://forums.asp.net/

    There are more experts in that forum so that you may get more useful help there.

     

    Thank you for your posting and understanding.


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, January 20, 2011 5:19 AM