Reference.svcmap: Could not load file or assembly

2019-02-13 21:29发布

I have a simple webforms website project. The project uses Microsoft Application Block Unity 3.5 (DI Container) added via NuGet.

Now I am using this 3rd party web service. After I add Service Reference and build I get this:

Error 19 Reference.svcmap: Could not load file or assembly 'Microsoft.Practices.ServiceLocation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) App_WebReferences/MyExternalService/

So I installed Microsoft.Practices.ServiceLocation but it still keeps complaining about that assembly.

enter image description here

I tried adding this to my web.config but still doesn't work.

 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>

As soon as I uninstall Unity package, all is good. No errors and I can use the Service proxy

Tried Clean Build, etc. but nothing works.

Any idea?

1条回答
三岁会撩人
2楼-- · 2019-02-13 21:42

I was installing wrong package for getting reference to Microsoft.Practices.ServiceLocation

Wrong package: enter image description here

Correct package is: enter image description here

查看更多
登录 后发表回答