Cannot obtain metadata error after configuring

Feb 6, 2013 at 2:01 AM
Hello, I have been trying for the last few hours to get this to work within my WCF service application however when ever I go to run the service I get the following exception:
Could not load file or assembly 'TestWCFAPI' 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 'TestWCFAPI' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Here is a snippet of my service.svc.cs, the .svc markup and finally the container from the WcfServiceHostFactory class :

The markup:
<%@ ServiceHost Language="C#" Debug="true" Service="TestWCFAPI.TestWCFService"  Factory="TestWCFAPI.WcfServiceFactory" %> The Service code behind:
namespace TestWCFAPI
{
    public class TestWCFService : ITestWCFService
    {      
        //_xDoc is used for converting returned string xml from exisitng remoting services
        private XDocument _xDoc { get; set; }
        private readonly IXResident _xResident = null;

        public CamARService(IXResident XResident)
        {
            _xResident = XResident;
        }

Ect …

And finally the WCF Service Host Factory:
namespace TestWCFAPI
{
public class WcfServiceFactory : UnityServiceHostFactory
    {
        protected override void ConfigureContainer(IUnityContainer container)        
        {
            / Register all your components with the container here
             * When working with components that implement IDisposable, 
             *  use .RegisterType<DataContext>(new ()); 
/
            container
                .RegisterType<ITestWCFService, TestWCFService>() //I also tried commenting out this line was sure if it was needed or not
                .RegisterType<IXResident, XResident>();
        } 
    } 
}

I am running VS 2012 Update 1 and all projects are .NET 4.0 (not client profile). Also, if I remove the Unity.WCF and constructor and run as a regular service everything seems to work as normal. Any suggestions on what I might be missing here?

Thanks,
Allen D.
Feb 6, 2013 at 3:33 PM
Just to update, I was able to resolve this. It turns out I had the project to compile with CPU 64 instead of Any. This may become an issue later but for now everything is working.