ServiceStack: Testing OrmLite, installed with NuGet but I get error “FileNotFoundException”

人盡茶涼 提交于 2019-12-01 09:34:35

Have you tried to add an assembly redirect in your web.config?

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="ServiceStack.Common" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.9.70.0" newVersion="3.9.70.0" />
      </dependentAssembly>
   </assemblyBinding>
</runtime>

It could be that one of the items in the package that you installed is specifically looking for the 3.9.69.0 version and has not been updated yet. Using the assembly binding redirect should override that and redirect all request for that assembly to the 3.9.70 version.

Edit

This works for non web projects as well. Open (or add) an app.config file, and add the same information. It is a top level element inside of the <configuration></configuration> element.

If an empty app.config file:

<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="ServiceStack.Common" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-3.9.70.0" newVersion="3.9.70.0" />
          </dependentAssembly>
       </assemblyBinding>
    </runtime>
</configuration>

In my solution I have the projects: Site, BusinessLogic, DAL

With the call chain: Site -> BusinessLogic -> DAL (OrmLite here)

Because of the loose coupling of ServiceStack the Site project was not pulling in the reference to ServiceStack.Common. My solution was to

Install-Package ServiceStack.Common -Version 3.9.71 -DependencyVersion Highest

For the site project. Note the usage of DependencyVersion otherwise you will get a lesser version of ServiceStack.Text and things will be unhappy.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!