locked
Webservice -- Could not load file or Assembly 'Microsoft.Dynamics.BusinessConnectorNet.dll' RRS feed

  • Question

  • Hi,

    I've create a webservice using BusinessConnector to communicate with Microsoft Dynamics AX2009.

    I've developped it by adding reference to Microsoft.Dynamics.BusinessConnectorNet.dll into webservice.
    The Path for dll is correct but when I try to test webservice, I receive an error loading file or assembly !!!

    Here is the error :

    Server Error in '/AXWebserviceISA' Application.
    --------------------------------------------------------------------------------
    
    Could not load file or assembly 'Microsoft.Dynamics.BusinessConnectorNet' 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 'Microsoft.Dynamics.BusinessConnectorNet' 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 'Microsoft.Dynamics.BusinessConnectorNet' could not be loaded.
    
    
    === Pre-bind state information ===
    LOG: User = XXX\xxxxx
    LOG: DisplayName = Microsoft.Dynamics.BusinessConnectorNet
     (Partial)
    LOG: Appbase = file:///C:/AXWebserviceISA/AXWebserviceISA/AXWebserviceISA/
    LOG: Initial PrivatePath = C:\AXWebserviceISA\AXWebserviceISA\AXWebserviceISA\bin
    Calling assembly : (Unknown).
    ===
    LOG: This bind starts in default load context.
    LOG: Using application configuration file: C:\AXWebserviceISA\AXWebserviceISA\AXWebserviceISA\web.config
    LOG: Using host configuration file: \\?\C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\aspnet.config
    LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\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/v2.0.50727/Temporary ASP.NET Files/axwebserviceisa/724bc418/67e696a0/Microsoft.Dynamics.BusinessConnectorNet.DLL.
    LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/axwebserviceisa/724bc418/67e696a0/Microsoft.Dynamics.BusinessConnectorNet/Microsoft.Dynamics.BusinessConnectorNet.DLL.
    LOG: Attempting download of new URL file:///C:/AXWebserviceISA/AXWebserviceISA/AXWebserviceISA/bin/Microsoft.Dynamics.BusinessConnectorNet.DLL.
    ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
    
     
    
    Stack Trace: 
    
    
    [BadImageFormatException: Could not load file or assembly 'Microsoft.Dynamics.BusinessConnectorNet' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
       System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
       System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +416
       System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +166
       System.Reflection.Assembly.Load(String assemblyString) +35
       System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +190
    
    [ConfigurationErrorsException: Could not load file or assembly 'Microsoft.Dynamics.BusinessConnectorNet' 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) +11200744
       System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +388
       System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +232
       System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +48
       System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +210
       System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +76
       System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +502
       System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +476
       System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +116
       System.Web.UI.WebServiceParser.GetCompiledType(String inputFile, HttpContext context) +77
       System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +231
       System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +89
       System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +564
       System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +142
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +263
    
    Have someone any ideas ? I try to solve this point since 3 days and any solution. And I didn't find anything on the net.
    ](*,)

    Thanks for your help !
    Tuesday, June 30, 2009 9:43 AM

Answers

  • I'm pretty sure the problem is not that it cannot find the file - the error 'BadImageFormatException' will only occur when it tries to read the file
    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk
    • Marked as answer by Jim Glass Jr Thursday, July 9, 2009 8:06 PM
    Wednesday, July 1, 2009 10:29 AM
    Moderator

All replies

  • Not a specific problem I've met, but the errors look like it's an issue with 64-bit code, or a combination of 32 and 64-bit code. The following link gives some information about this, though the solution depends on compilation flags when you build an assembly, whereas I believe you're using a pre-built assembly.

    You may be able to fix the problem by enabling 32-bit code on the Application Pool in IIS Manager
    Microsoft CRM MVP - http://mscrmuk.blogspot.com/  http://www.excitation.co.uk
    Tuesday, June 30, 2009 3:57 PM
    Moderator
  • I don't think it is able to find the DLL, please verify the directory path.

    I remember recieving a similar error when deploying my .NET 3.0 web app to a web server that didn't have .NET 3.0 installed.
    http://mscrmblog.net
    Microsoft Certified Business Management Solutions Specialist
    Microsoft Certified CRM Developer
    Wednesday, July 1, 2009 5:01 AM
  • I'm pretty sure the problem is not that it cannot find the file - the error 'BadImageFormatException' will only occur when it tries to read the file
    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk
    • Marked as answer by Jim Glass Jr Thursday, July 9, 2009 8:06 PM
    Wednesday, July 1, 2009 10:29 AM
    Moderator
  • Hi, I have the same problem. Any solution??
    Thursday, July 16, 2009 11:33 AM
  • Hi guys, i know this is bit old and you may not be looking for a solution - In order to fix this simply install .net connector on the pc which will register the dll being referenced. Sorted.
    • Proposed as answer by ZeroBoy Wednesday, August 25, 2010 11:42 AM
    Wednesday, August 25, 2010 11:41 AM
  • I had the same problem and in my case this is the answer. The running platform it’s a 64 bit computer and the platform used to build the project it’s on 32 bit computer. Changing the destination platform in project building options to 64 bit works perfect! (It's a windows form project, not "IIS invoved")

    Thank you DavidJennaway!!!


    http://www.markcortada.com/

    Tuesday, May 22, 2012 4:13 PM
  • The cause of the problem is that .NET Business Connector is not compatible from .NET Framework 4.0 onward.
    Friday, June 10, 2016 12:24 PM