Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 220919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:59:04+00:00 2026-05-11T18:59:04+00:00

Creating a WCF Service Library in Visual Studio 2008 on Vista x64 is troublesome

  • 0

Creating a WCF Service Library in Visual Studio 2008 on Vista x64 is troublesome when referencing an x86 DLL. A service that calls a 32-bit DLL is required to have a platform target of x86 to run on a 64-bit OS. When you do this, the WcfSvcHost throws a BadImageFormatException when you attempt to debug the service. There is a bug report on MS connect. The workaround I used was to coreflag WcfSvcHost as 32-bit.

Manifest Problem

The main issue I’ve run in to is this third-party native 32-bit DLL fails to load using certain WCF hosts. I receive the following error when a service operation is invoked that uses the third-party DLL:

System.TypeInitializationException: The type initializer for
” threw an exception.

.ModuleLoadExceptionHandlerException:
A nested exception occurred after the
primary exception that caused the C++
module to fail to load.

System.BadImageFormatException: The module was expected to contain an
assembly manifest. (Exception from
HRESULT: 0x80131018)

NestedException:

The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))

This exception is not raised when WcfSvcHost starts, it’s raised when the a service operation is invoked that references the 32-bit DLL. What’s very interesting, hosting this same service with the same app.config on a console app has no exceptions and works perfectly:

using (ServiceHost host = new ServiceHost (typeof (MsgBrokerService))) {
    host.Open ();
    Console.WriteLine ("running");
    Console.ReadLine ();

This exception occurs right after:

‘WcfSvcHost.exe’ (Managed): Loaded
‘C:\Windows\WinSxS\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.3053_
none_d08d7bba442a9b36\msvcm80.dll’

Again, the console app does not have an exception and loads the same DLL:

‘ConsoleApp.vshost.exe’ (Managed):
Loaded
‘C:\Windows\WinSxS\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.3053_
none_d08d7bba442a9b36\msvcm80.dll’

See answer from Microsoft Product Support.

Update #1: Both the console application and the WcfSvcHost.exe host process runs under the same session and logged-in user (me). I’ve copied WcfSvcHost.exe to the directory of the service, manually launched and experienced the same result. I’ve also checked the Windows Event Log for additional information and used sxstrace, but nothing was logged.

Running Process Explorer, I’ve verified the following are the same between the two processes:

  • Image: 32-bit
  • Current Directory
  • User/SID
  • Session
  • Security (groups denied, privileges disabled)

Running Process Monitor, and configuring symbols, I see WcfSvcHost looks for the following registry and files, while the console host does not. Process Monitor logs a lot of data and I’m not sure what I’m looking for 🙁.

HKLM\SOFTWARE\Microsoft\Fusion\PublisherPolicy\Default\policy.8.0.msvcm80__b03f5f7f11d50a3a
C:\Windows\assembly\GAC_32\msvcm80\8.0.50727.3053__b03f5f7f11d50a3a
C:\Windows\assembly\GAC_MSIL\msvcm80\8.0.50727.3053__b03f5f7f11d50a3a
C:\Windows\assembly\GAC\msvcm80\8.0.50727.3053__b03f5f7f11d50a3a

Update #2: This same exception occurs when the service is hosted in production on IIS 6 / Windows Server 2003.

Update #3: The 3rd-party 32-bit .NET assembly is the StreamBase API:

  • sbclient.dll (managed)
  • monitor.netmodule (managed)
  • dotnetapi.dll (unmanaged)
  • pthreads-vc8.dll (unmanaged)

Update #4: Added manifests without success:

  1. Verified that dotnetapi.dll and pthreads-vc8.dll have RT_MANIFEST. The sbclient.dll .NET assembly did not have a manifest
  2. Removed sbclient.dll from the GAC
  3. Registered sbclient.dll for verification skipping
  4. Added a manifest via mt.exe to both sbclient.dll and monitor.netmodule
  5. Verified manifest was added and that the expected files were loaded during testing (via Visual Studio – debug modules window)
  6. The same BadImageFormatException is thrown under BackgroundWorker.OnDoWork(), and the call stack shows a call to dotnetapi.dll…DefaultDomain.Initalize().

I have verified that msvcm80.dll does not have a manifest, I believe this is the only file loaded that doesn’t have a manifest 🙂

Interesting find

When I load monitor.netmodule in Reflector, it says:

‘monitor.netmodule’ does not contain
an assembly manifest.

Even though it displays an error, Reflector is still able to disassemble the managed code.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:59:04+00:00Added an answer on May 11, 2026 at 6:59 pm

    Microsoft Product Support has resolved this question: It’s by design. The unmanaged code is not loaded in the default AppDomain when using WcfSvcHost or the IIS WCF host.

    A pure image will use a CLR version of
    the C run-time library. However, the
    CRT is not verifiable, so you cannot
    use the CRT when compiling with
    /clr:safe. For more information, see C
    Run-Time Libraries.

    http://msdn.microsoft.com/en-us/library/k8d11d4s.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are creating a WCF service with a companion client DLL (.Net) that we
When creating a new service in a WCF service project, Visual Studio will automatically
Using Visual Studio 2010 when creating a wcf service the template creates a class
I am creating solution and inside I have three projects: A WCF Service Library
I'm creating a WCF service that transfers entity objects created via entity framework. I
I just noticed while creating a RESTful WCF service that the Method parameter on
in the process of creating a WCF service I ran into a term that's
I'm creating a WCF service that may be used either locally or remotely, and
I'm creating a WCF service which uses the .net framework 4 client profile dll.
I just referenced my application domain layer dll to the new WCF service that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.