What are all the steps to take to get my SQL Server CE to work on my web host machine - sql-server-ce-4

Edit: My question comes down to, what are all the steps I need to take to build a web app that uses SQL Server CE in medium trust?
I had copied my desktop version into my bin directory before I posted this, but I'm sure there are more steps to take, as that did not work.
Error: Possible file version mismatch detected between ADO.NET Provider and native binaries of SQL Server Compact which could result in an incorrect functionality. This could be due to the presence of multiple instances of SQL Server Compact of different versions or due to wrong binaries with same name as SQL Server Compact binaries. Please install SQL Server Compact binaries of matching version.
Web App: MVC 3 built with VS 2010
Everything works fine on my dev machine.
After reading this post, I got rid of my references and copied SqlServerCE.dll and SqlServerCe.Entity.dll to my bin directory.
That changed the error from
Could not load file or assembly 'System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
to the current one.
I copied SqlServerCE.dll from my desktop folder, so I could run under medium trust.
From my Web.config file:
` <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
<assemblyIdentity name="System.Data.SqlServerCe"
publicKeyToken="89845dcd8080cc91" culture="neutral"/>
<bindingRedirect oldVersion="4.0.0.0-4.0.0.1" newVersion="4.0.0.1"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0" />
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>`
Edit: Thanks everyone.
I do have SqlServerCompact.4.0.8852.1 in my packages directory.
I removed SqlServerCE.dll and SqlServerCe.Entity.dll from my bin directory, as they are in my packages. I copied the Native Binaries into my bin (and they are included in the project), but I still get this message:
Possible file version mismatch detected between ADO.NET Provider and
native binaries of SQL Server Compact which could result in an
incorrect functionality. This could be due to the presence of multiple
instances of SQL Server Compact of different versions or due to wrong
binaries with same name as SQL Server Compact binaries. Please install
SQL Server Compact binaries of matching version.
I was unable to use the nuget package you suggested as I have a newer version of Entity Framework and it rolled back the install.
I'm ready to start over with a new project if anyone can recommend a setup of SQL Server CE that will work in Medium trust on a shared hosting server.
This is what I have been doing (and does not work) when I created my project.
a. Install-Package SqlServerCompact
b. Install-Package System.Web.Providers
c. Install-Package EntityFramework
d. Install-Package EntityFramework.SqlServerCompact

Check at your packages directory if your SqlCompact is this version: SqlServerCompact.4.0.8852.1
If yes, you need to copy the files inside packages\SqlServerCompact.4.0.8852.1\NativeBinaries because they are different.
But this version don´t run at medium trust, because they changed the SqlCompact version to 4.0.0.1 and only the 4.0.0.0 is authorized by default at .NET 4 config file. If you need a version that run at medium trust, try this one https://nuget.org/packages/EntityFramework.SqlServerCompact/4.1.8482.2

Related

C# Windows IoT Core Background Application Assembly Binding Redirects

I am setting up my first Windows IoT Core background application that is running on a Raspberry Pi, but I am running into a problem with conflicting assembly versions and I have been unable to resolve them.
Specifically, I am getting an error message that states:
No way to resolve conflict between "System.Data.Common, Version=4.2.1.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Data.Common,
Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing
"System.Data.Common, Version=4.2.1.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
Upon closer inspection, there are two versions of the System.Data.Common.dll that my application is referencing.
The first is coming from the installed package Microsoft.NETCore.UniversalWindowsPlatform (v 6.2.8). The assembly version of System.Data.Common here is 4.2.1.0 (which is the version I want to use):
Assembly System.Data.Common version 4.2.1.0
C:\Users\mikel\.nuget\packages\Microsoft.NETCore.UniversalWindowsPlatform\6.2.8\ref\uap10.0.15138\System.Data.Common.dll
The second is apparently being included as a dependency with the .netstandard:
Assembly System.Data.Common version 4.1.0.0
C:\Users\mikel\.nuget\packages\System.Data.Common\4.3.0\ref\netstandard1.2\System.Data.Common.dll
I am having a little harder time pinpointing exactly what is forcing NuGet to download and install the second package. Perhaps one of my other packages that I need is referencing it as a dependency (not sure).
Either way, I would like to setup assembly binding remapping so that any attempt to reference 4.1.0.0 will redirect and use 4.2.1.0.
When I do a build of my project, I get this warning:
1> Consider app.config remapping of assembly "System.Data.Common, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" from Version "4.1.0.0"
[C:\Users\mikel\.nuget\packages\System.Data.Common\4.3.0\ref\netstandard1.2\System.Data.Common.dll]
to Version "4.2.1.0"
[C:\Users\mikel\.nuget\packages\Microsoft.NETCore.UniversalWindowsPlatform\6.2.8\ref\uap10.0.15138\System.Data.Common.dll]
to solve conflict and get rid of warning.
However from what I have read, Universal Windows Projects do not support the use of app.config files. At any rate though, I added an app.config file to the root of my project, set the build action to Embedded Resource, selected Copy Always and put this in the file (to no affect):
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Data.Common" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="4.1.0.0" newVersion="4.2.1.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I have also tried setting the NuGet project management format to PackageReference and added <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> to each PropertyGroup in my .csproj file. This did not have any impact.
My Universal Windows project targets are as follows:
Target version: Windows 10 Fall Creators Update (10.0; Build 16299)
Minimum Version: Windows 10 Fall Creators Update (10.0; Build 16299)
I should also state that I want to use the 4.2.1.0 version of the assembly, as 4.1.0.0 is missing a few things I need to implement the wrapper I am using around SQLite. My preference is to not have to re-write those wrappers.
At this point I am very confused as to how to resolve this conflict. How do I enable binding redirects to resolve this error?
Any help would be greatly appreciated.

Visual Studio Debugging dll dependency error

In Visual Studio 2015, I have Project A (Web Api Application) and Project B (MVC Application) in the same solution.
I can debug application A and application B separately.
But, When application B calls rest api from A, I receive dll dependency error from application A.
"Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference".
When I clean build project A, at the first time call is successful, however subsequent calls receive same error.
How can I fix this?
(I use IIS 7.5)
To solve this, please mark sure that your two projects used the same Newtonsoft.Json version.
You can run the following command:
update-package Newtonsoft.Json -reinstall
Please also view your web.config, maybe you could remove the old version like:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> </dependentAssembly>
Generally if we want to ensure all Newtonsoft.Json packages are the same version, we also can specify the version:
update-package Newtonsoft.Json -version 6.0.0 -reinstall
Reference:
Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0
http://blog.myget.org/post/2014/11/27/Could-not-load-file-or-assembly-NuGet-Assembly-Redirects.aspx

When deploying a Windows CE 6 application I get the error: file or assembly system system.data.sqlserverce not found

I am deploying a legacy C# mobile application onto a Windows CE 6 device.
The application compiles within Visual Studio 2008 and deploys onto the device, but an error appears when running my application on the device:
File or assembly name 'System.Data.SqlServerCe, version = 3.0.3600.0, culture=neutral, PublicKeyToken=3B3235DF1C802AD3' or one of it's dependencies, was not found'.
This application (as you've probably guessed) uses SQL Server Compact, I've tried various methods to get the application to run (reinstalled SQL Server compact on the device etc) but no joy.
I've also tried altering the app.config file to map remap this missing dependency:
<dependentassembly>
<assemblyidentity name="System.Data.SqlServerCe" culture="neutral" publickeytoken="3be235df1c8d2ad3" />
<bindingredirect newVersion="3.5.0.0" oldVersion="3.0.3600.0" />
</dependentassembly>
But I am getting still the same issue.

Error when I try t oopen the QB template in VS 2010

I am running Visual Studio 2010 Ultimate. I have installed the Intuiut SDK v12.0 to its default location. I copied the file "IntuitWizardQBFC.zip" and pated it into the templates folder for visual studio. The icon for the quick books template is on the interview screen but when I click on it I get an error message. It states "Could not load file or assembly 'Interop QBFC10, Version=11.0.0.132, Culture=neutral, PublicKeyToken=31d8aec64e18259' or one of it's dependencies. The system cannot find the specified file" I saw a similar post regaurding an existing application. I cannot open the template to create the first application. My machine is Windows 7 64 bit. When I write programs for class I set the target to x86 so If I can test them on older computers. This setting is usually set after the solution is created when the new project is started. Please help I am currently using access to get data from my QB data base and want to do something diffrent.
The template wizard assembly IntuitWizardQBFC has a reference to version 11.0.0.132 of Interop.QBFC10, which is not present on your system. Go to C:\Windows\Assembly, look for Interop.QBFC10, and see what it says in the Version column. In my case, it says 11.0.0.29.
You can force Visual Studio to use version 11.0.0.29 instead of 11.0.0.132 by redirecting assembly versions. Edit devenv.exe.config, and just before the closing </assemblyBinding> tag, add this:
<dependentAssembly>
<assemblyIdentity name="Interop.QBFC10" publicKeyToken="31d8aec643e18259" culture="neutral"/>
<bindingRedirect oldVersion="11.0.0.132" newVersion="11.0.0.29"/>
</dependentAssembly>
Close Visual Studio if it was open; start it up, and create a new project using the template. Instead of showing the error message, it should launch the wizard.
Try installing QBFC10 and then try the template. It is possible I forgot to update the template when SDK 12 was built.
You can download QBFC10 from the same location you got the SDK.
William
I just downloaded the QuickBooks Desktop SDK v13 today and it still has this issue with the VS.NET Project Wizard.
Following up on Adam C's post above, the complete path to this node in the devenv.exe.config is as follows:
<?xml version ="1.0"?>
<configuration>
...
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
...
<dependentAssembly>
<assemblyIdentity name="Interop.QBFC10" publicKeyToken="31d8aec643e18259" culture="neutral"/>
<bindingRedirect oldVersion="11.0.0.132" newVersion="11.0.0.29"/>
</dependentAssembly>
...
</assemblyBinding>
</runtime>
...
</configuration>

Connection nHibernate to Oracle Issues

I am trying to connect to an Oracle Database using nHibernate. I can connect using the .Net driver:
<property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
However I would prefer to use the OracleDataClientDriver that ships with Oracle (or nHibernate? I forget). Anyway I was using the instructions of this blog:
http://tiredblogger.wordpress.com/2008/11/07/using-oracle-odp-with-nhibernate-from-a-c-class-library/
All is fine but when I add the app.config with the following setting to my Unit Test class:
<runtime>
<assemblyBinding xmlns=“urn:schemas-microsoft-com:asm.v1“>
<qualifyAssembly partialName=“Oracle.DataAccess“
fullName=“Oracle.DataAccess,
Version=2.111.6.20,
Culture=neutral,
PublicKeyToken=89b483f429c47342“ />
</assemblyBinding>
</runtime>
And attempt to run my test I get the following error:
Test 'M:UTOracleImporter.UT_SchemaDAO.Test_GetCustomer' failed: Could not load type 'TestDriven.Framework.Resident.IResidentTestRunner' from assembly 'TestDriven.Framework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=50ecb853f8c6b8d2'.
System.TypeLoadException: Could not load type 'TestDriven.Framework.Resident.IResidentTestRunner' from assembly 'TestDriven.Framework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=50ecb853f8c6b8d2'.
at TestDriven.TestRunner.AdaptorTestRunner.Run(ITestListener testListener, ITraceListener traceListener, String assemblyPath, String testPath)
at TestDriven.TestRunner.ThreadTestRunner.Runner.Run()
Any advice?
Edit: I have added the Test Driven assemblies to the GAC and now am getting a different error:
NHibernate.HibernateException : The
IDbCommand and IDbConnection
implementation in the assembly
Oracle.DataAccess could not be found.
Ensure that the assembly
Oracle.DataAccess is located in the
application directory or in the Global
Assembly Cache. If the assembly is in
the GAC, use
element in the application
configuration file to specify the full
name of the assembly.
Which is the same error that it meant to be addressed in the App.Config. The Oracle.DataAccess has been added to the GAC and I have also tried it in the application folder. Yet error still appears.
I don't see any references to Oracle (or NHibernate) in that error.
In any case, I recommend you upgrade to NH 3.0 Alpha2. The assemblyBinding stuff isn't needed anymore.

Resources