Wcf – Problems targeting a .NET 4 WCF service to be 64 bit

.net-4.064-bitcassiniiiswcf

I’m having problems targeting a .NET 4 WCF service to be 64 bit. I take the following steps on a 64bit Vista OS:

Create a new WCF Service project in Visual Studio 2010.

Change the Platform target to x64.

After doing this my WCF service will no longer run in either Cassini or IIS. A point to note is that taking these same actions and targeting .NET 3.5 everything works fine. The project builds without issue. Any help much appreciated. The error I’m getting when loading the service is:

(I’m not looking for the answer “compile this as Any CPU”. I’m more interested in knowing why this is happening. :-))

Server Error in '/' Application.
The type 'WcfService3.Service1', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
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.InvalidOperationException: The type 'WcfService3.Service1', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.

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.

Stack Trace:

[InvalidOperationException: The type 'WcfService3.Service1', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.]
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +51902
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1440
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +615

[ServiceActivationException: The service '/Service1.svc' cannot be activated due to an exception during compilation. The exception message is: The type 'WcfService3.Service1', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found..]
System.Runtime.AsyncResult.End(IAsyncResult result) +679246
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +190
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext, Boolean ensureWFService) +234
System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +355
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

Best Answer

I think the reasons around this are the fact that the Cassini web host is a 32bit application so you cannot share x64 and x86 runtimes inside the same process.

For IIS are you running it in it's own app pool? Again the app pool may be shared with 32bit applications which will then stop you from running a x64 process. If you associate your virtual directory with a new app pool the process should load ok.