WCF 4.0 Issues with IIS 7.0 on x86 and x64 bit Machines(转载)

 

If you are experienced with WCF, you know that in case of installing IIS after installing .NET framework, you need to register ASP.NET using aspnet_regiis.exe with /i option from “%windir%\Microsoft.NET\Framework\v2.0.50727” and WCF handler modules  using ServiceModelReg.exe /i which is found at “%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation”.

That’s true for .NET 3.0 and 3.5SP1, but if you tried this while developing for WCF 4.0 (or WCF Data Services 4.0 which is also WCF service) you will face the following error whenever trying to browse your service

“HTTP Error 500.21 - Internal Server Error
Handler "svc-Integrated" has a bad module "ManagedPipelineHandler" in its module list”

Or the this one

“The current identity (IIS APPPOOL\ASP.NET V4.0) does not have write access to 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files'.”

And you may face the following error while running aspnet_regiis /i from the command line

“Operation failed with 0x8007000B    An attempt was made to load a program with an incorrect format.”

That’s because there are new versions for both executables to register ASP.NET and WCF 4.0 for both x86 and x64 platforms.

In case that you are targeting .NET 4.0 on x86 platforms even if you are developing using x64 machine, then  you need to do the following steps
Use the corresponding x86 executables for .NET 4.0 found at “%windir%\Microsoft.NET\Framework\v4.0.30319”
Enable 32 bit mode for all IIS Application Pools using the command
%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.enable32BitAppOnWin64:true

In case that you are targeting .NET 4.0 on x64 platforms, then  you need to do the following steps
Use the corresponding x64 executables found at “%windir%\Microsoft.NET\Framework64\v4.0.30319”
Update your project to reference the x64 DLLs found at “Program Files\Reference Assemblies\Microsoft\Framework” instead of the x86 versions which is referenced by default from “Program Files(x86)\Reference Assemblies\Microsoft\Framework”

I hope this saves you those painful troubleshooting times that I’ve to go through :(

Have a nice day

posted @ 2011-04-10 12:33  简单不简单  阅读(1024)  评论(0编辑  收藏  举报