我正在尝试开发一个在 64 位环境中运行的简单 WCF 服务。
我在Windows 7下启动VS2010
新解决方案-> WCF 项目-> 运行-> 工作正常。
一旦我更改项目的属性以使其在 64 位中编译,运行它就会抛出以下异常:
Could not load file or assembly 'WcfService2' or one of its dependencies.
使用以下程序集加载跟踪
=== Pre-bind state information ===
LOG: User = *****
LOG: DisplayName = WcfService2
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: WcfService2 | Domain ID: 4
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///d:/temp/WcfService2/WcfService2/
LOG: Initial PrivatePath = d:\temp\WcfService2\WcfService2\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: d:\temp\WcfService2\WcfService2\web.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/806f4cb8/df40e9e2/WcfService2.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/806f4cb8/df40e9e2/WcfService2/WcfService2.DLL.
LOG: Attempting download of new URL file:///d:/temp/WcfService2/WcfService2/bin/WcfService2.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
我怎样才能克服这个问题?任何想法?谢谢
EDIT:
The WCF does将平台目标设置为 AnyCPU 后进行编译,但我需要专门设置 64 位编译,因为我正在使用 SharePoint 对象,而 AnyCPU(或 x86)编译会导致所描述的完全相同的问题和错误here(以及网络上的其他地方)。
因此,要么编译 AnyCPU/x86,然后在与 SharePoint 集成时收到错误,要么将目标平台设置为 64 位,然后从 WCF 收到错误。