CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Feb 2011

    WCF Service Error Bad Image Format Exception on x86

    I am getting an error Bad Image Format Exception when i change the Platform Target to x86 from Any CPU.
    It doesn't throw an exception when running on "Any CPU" as Platform Target.

    My OS is Win 7 x64. I figured out that as 64-bit framework being used, it is throwing the exception.
    "LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config."

    Now the problem is i am using Sybase database and i have a 32-bit dll and not x64.
    So if "Any CPU" is selected and i run the service, i am getting exception for memory location just while i create a connection object.
    AseConnection oAseCon = new AseConnection(str);

    Is there a solution that i can run a 3rd party 32-bit dll in a WCF Service on 64 bit machine.

    Help would be appreciated.

    Thanks .

  2. #2
    Join Date
    Feb 2011

    Re: WCF Service Error Bad Image Format Exception on x86

    I tried to place the 32 bit dll in Bin directory and also SYSWOW64 dir.

    The problem is when i run in "Any CPU" mode .. i get error while initializing the 32 bit dll and when i change the Platform Target to x86 i get the following error.

    Note: This is WCF Service which i am running and i get this error when i try to start with Default Client for WCF Service "WcfTestClient.exe".


    System.BadImageFormatException: Could not load file or assembly 'file:///C:\Users\CShah\Documents\Visual Studio 2010\Projects\SilverLight\SSQueueServiceLibrary\bin\Debug\SSQueueServiceLibrary.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
    File name: 'file:///C:\Users\CShah\Documents\Visual Studio 2010\Projects\SilverLight\SSQueueServiceLibrary\bin\Debug\SSQueueServiceLibrary.dll'
    at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
    at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
    at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
    at Microsoft.Tools.SvcHost.ServiceHostHelper.LoadServiceAssembly(String svcAssemblyPath)

    === Pre-bind state information ===
    LOG: User = CShah
    LOG: Where-ref bind. Location = C:\Users\CShah\Documents\Visual Studio 2010\Projects\SilverLight\SSQueueServiceLibrary\bin\Debug\SSQueueServiceLibrary.dll
    LOG: Appbase = file:///C:/Users/CShah/Documents/Visual Studio 2010/Projects/SilverLight/SSQueueServiceLibrary/bin/Debug
    LOG: Initial PrivatePath = NULL
    Calling assembly : (Unknown).
    LOG: This bind starts in LoadFrom load context.
    WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
    LOG: Using application configuration file: C:\Users\CShah\Documents\Visual Studio 2010\Projects\SilverLight\SSQueueServiceLibrary\bin\Debug\SSQueueServiceLibrary.dll.config
    LOG: Using host configuration file:
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
    LOG: Attempting download of new URL file:///C:/Users/CShah/Documents/Visual Studio 2010/Projects/SilverLight/SSQueueServiceLibrary/bin/Debug/SSQueueServiceLibrary.dll.
    ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated."

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.