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 =)
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.
来源:https://stackoverflow.com/questions/19884171/servicestack-testing-ormlite-installed-with-nuget-but-i-get-error-filenotfoun