C# Unity 3.0和DataContractSerializerMessageCompactImporter

C# Unity 3.0和DataContractSerializerMessageCompactImporter,c#,wcf,visual-studio-2013,unity-container,prism,C#,Wcf,Visual Studio 2013,Unity Container,Prism,我尝试在Visual Studio 2013中将新的服务引用添加到我的类库项目中 但在生成代码之前,VS.NET会抛出以下内容: Warning 2 Custom tool warning: Cannot import wsdl:portType Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerialize

我尝试在Visual Studio 2013中将新的服务引用添加到我的类库项目中

但在生成代码之前,VS.NET会抛出以下内容:

Warning 2   Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Could not load file or assembly 'Microsoft.Practices.Unity, Version=2.1.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='IWcfXXXService'] c:\Projects\...\Service References\ServiceReference1\Reference.svcmap   1   1   Domain.XXX
我使用的是Prism 4.1,因此Unity 3.0是必须的,它工作得很好-除了生成服务引用时。我真的很困惑:Unity和DataContractSerializerMessageCompactImporter的共同点是什么

如果我移除Prism.UnityExtension,那么一切都正常


我能做什么?我不想在每次服务参考刷新时将Unity 3.0更改为2.1.505.0。

Prism 4.1是根据Unity 2.1.505.0构建的,Unity的组件与Prism 4.1一起装运

如果您确实想使用Unity 3.0,并且不想更改程序集引用,那么可以使用程序集重定向来强制在请求Unity 2.1时加载Unity 3.0

将以下内容添加到应用程序的配置文件中

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="Microsoft.Practices.Unity"
                        publicKeyToken="31bf3856ad364e35"
                       />
      <!-- Assembly versions can be redirected in application, publisher policy, or machine configuration files. -->
      <bindingRedirect oldVersion="2.1.505.0"
                       newVersion="3.0.1304.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="Microsoft.Practices.Unity.Interception"
                        publicKeyToken="31bf3856ad364e35"
                       />
      <!-- Assembly versions can be redirected in application, publisher policy, or machine configuration files. -->
      <bindingRedirect oldVersion="2.1.505.0"
                       newVersion="3.0.1304.0"/>
    </dependentAssembly>
  </assemblyBinding>
</runtime>

Aha,Prism 4.1与Unity 2.1兼容-我错过了它。非常感谢。