ServiceStack: Testing OrmLite, installed with NuGet but I get error "FileNotFoundException"
Asked Answered
H

2

3

I just installed OrmLite (for MySql) via NuGet in Visual Studio 2012.

The installation passes without any errors, and all DLL:s seem to be added as reference:

ServiceStack.Common (3.9.70.0)
ServiceStack.Interfaces (1.0.0.0)
ServiceStack.Text (3.9.70.0)
ServiceStack.OrmLite (3.9.70.0)
ServiceStack.OrmLite.MySql (3.9.70.0)

Compile gives no errors. However, when I run this line:

dbConnCommOrm.CreateTableIfNotExists<ModuleSettings>();

Then I get this error:

Could not load file or assembly 'ServiceStack.Common, Version=3.9.69.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

The ServiceStack.Common dll references (via NuGet) is version 3.9.70.0 so its not very strange that it cannot find 3.9.69.0.

The question is: why am I getting 3.9.70.0 installed when it requires 3.9.69.0 instead? Is there something wrong with the NuGet "script" (or however that works), or what am I missing?

The weird thing is that even though I get an exception on the line mentioned above, the table "ModuleSettings" is created correctly nonetheless!

Also, downloading the ZIP-file from GitHub and extracting the DLLs from there doesnt work either: In ServiceStack.OrmLite-master\lib there are the three first files (see above), and for some reason I find ServiceStack.Ormlite.dll in ServiceStack.OrmLite-master\lib/signed folder, but there is no ServiceStack.OrmLite.MySql.dll anywhere in the ZIP-file.


I might also add that installing an older version doesnt work either. I tried this: http://www.nuget.org/packages/ServiceStack.OrmLite.MySql/3.9.69

PM> Install-Package ServiceStack.OrmLite.MySql -Version 3.9.69

And it still installed ServerStack.Common/Text v 3.9.70.0


Any tips would be appreciated =)

Hollingsworth answered 9/11, 2013 at 22:57 Comment(0)
G
4

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>
Gummy answered 9/11, 2013 at 23:29 Comment(8)
Thanks! But tThis is not a web project... this is a dll project, so I do not have a web.config. Where would I put such a redirect then?Hollingsworth
you can use the same functionality in an app.config file. If you don't have one, just right click the project, add, configuration file.Gummy
Thx, I just discovered that such a binding redirect was added to the app.config, but for MySql.Data. I just added your bit, and it works =) Thanks a lot for the quick answer, much appreciated.Hollingsworth
And you think this is a bug on the ServerStack-end? Cause one shouldnt have to do this workaround, right?Hollingsworth
I know alot of the Microsoft product updates (MVC, EntityFramework, etc) will add these redirects automatically from NuGet. I wouldn't call it a bug, just that you just installed 6 assemblies, one of them wasn't updated by the creator when another one was to reference the correct assembly version. Thus, this "workaround" helps updating one .dll in your project from breaking others with dependencies on a specific version.Gummy
Thanks for the answer again. In this case, it is strange that one DLL with version 3.9.70.0 requires another DLL with version 3.9.69.0, when there in fact exists a version 3.9.70.0...Hollingsworth
I have no idea how this did anything. The CLR specifically ignores all usages of binding redirects for weak named assemblies: #10325472Biarritz
@ChrisMarisic The note mentioned in that answer (as a comment) does not appear on the .NET 4.5 MSDN page, but does appear in all the other versions 1.1 and higher. So, perhaps this was a CLR change in 4.5? Granted, the OP did not specify his framework version. Either way, it was a suggestion that worked in this case. :)Gummy
B
-1

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.

Biarritz answered 23/9, 2014 at 20:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.