diff --git a/CMS-SC-Data/obj/Debug/CMS-SC-Data.csproj.CoreCompileInputs.cache b/CMS-SC-Data/obj/Debug/CMS-SC-Data.csproj.CoreCompileInputs.cache deleted file mode 100644 index 0300cc2..0000000 --- a/CMS-SC-Data/obj/Debug/CMS-SC-Data.csproj.CoreCompileInputs.cache +++ /dev/null @@ -1 +0,0 @@ -c1a877f67844947b3231fcb9d1106ff280872007 diff --git a/CMS-SC-Data/obj/Debug/CMS-SC-Data.csproj.FileListAbsolute.txt b/CMS-SC-Data/obj/Debug/CMS-SC-Data.csproj.FileListAbsolute.txt index 08e7c6b..8cf1d62 100644 --- a/CMS-SC-Data/obj/Debug/CMS-SC-Data.csproj.FileListAbsolute.txt +++ b/CMS-SC-Data/obj/Debug/CMS-SC-Data.csproj.FileListAbsolute.txt @@ -94,7 +94,6 @@ C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Deb C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\System.Threading.Tasks.Extensions.xml C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\Pipelines.Sockets.Unofficial.xml C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\obj\Debug\CMS-SC-Data.csprojAssemblyReference.cache -C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\obj\Debug\CMS-SC-Data.csproj.CoreCompileInputs.cache C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\obj\Debug\CMS-SC-Data.csproj.CopyComplete C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\obj\Debug\CMS-SC-Data.dll C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\obj\Debug\CMS-SC-Data.pdb @@ -105,3 +104,20 @@ C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Deb C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\README.txt C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\System.Buffers.dll C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\System.Buffers.xml +C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\MongoDB.Driver.dll +C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\System.IO.Pipelines.dll +C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\MongoDB.Driver.Core.dll +C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\MongoDB.Bson.dll +C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\netstandard.dll +C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\System.Numerics.Vectors.dll +C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\DnsClient.dll +C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\Snappy.NET.dll +C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\Crc32C.NET.dll +C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\MongoDB.Driver.xml +C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\System.Memory.xml +C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\System.IO.Pipelines.xml +C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\MongoDB.Driver.Core.xml +C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\MongoDB.Bson.xml +C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\DnsClient.xml +C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\Snappy.NET.xml +C:\Users\samuele.steamw\Documents\VisualStudioProject\CMS-SC\CMS-SC-Data\bin\Debug\Crc32C.NET.xml diff --git a/CMS_SC/CMS_SC.csproj b/CMS_SC/CMS_SC.csproj index 443dcc0..a4a253c 100644 --- a/CMS_SC/CMS_SC.csproj +++ b/CMS_SC/CMS_SC.csproj @@ -119,6 +119,9 @@ ..\packages\Microsoft.AspNet.ScriptManager.WebForms.5.0.0\lib\net45\Microsoft.ScriptManager.WebForms.dll True + + ..\packages\Microsoft.SqlServer.Types.11.0.2\lib\net20\Microsoft.SqlServer.Types.dll + ..\packages\Microsoft.Web.RedisSessionStateProvider.4.0.1\lib\net462\Microsoft.Web.RedisSessionStateProvider.dll @@ -198,6 +201,22 @@ + + SqlServerTypes\x64\msvcr100.dll + PreserveNewest + + + SqlServerTypes\x64\SqlServerSpatial110.dll + PreserveNewest + + + SqlServerTypes\x86\msvcr100.dll + PreserveNewest + + + SqlServerTypes\x86\SqlServerSpatial110.dll + PreserveNewest + @@ -457,6 +476,7 @@ + @@ -745,6 +765,7 @@ Site.Master + StatoDossiers.aspx ASPXCodeBehind diff --git a/CMS_SC/SqlServerTypes/Loader.cs b/CMS_SC/SqlServerTypes/Loader.cs new file mode 100644 index 0000000..0dc61f6 --- /dev/null +++ b/CMS_SC/SqlServerTypes/Loader.cs @@ -0,0 +1,45 @@ +using System; +using System.IO; +using System.Runtime.InteropServices; + +namespace SqlServerTypes +{ + /// + /// Utility methods related to CLR Types for SQL Server + /// + internal class Utilities + { + [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] + private static extern IntPtr LoadLibrary(string libname); + + /// + /// Loads the required native assemblies for the current architecture (x86 or x64) + /// + /// + /// Root path of the current application. Use Server.MapPath(".") for ASP.NET applications + /// and AppDomain.CurrentDomain.BaseDirectory for desktop applications. + /// + public static void LoadNativeAssemblies(string rootApplicationPath) + { + var nativeBinaryPath = IntPtr.Size > 4 + ? Path.Combine(rootApplicationPath, @"SqlServerTypes\x64\") + : Path.Combine(rootApplicationPath, @"SqlServerTypes\x86\"); + + LoadNativeAssembly(nativeBinaryPath, "msvcr100.dll"); + LoadNativeAssembly(nativeBinaryPath, "SqlServerSpatial110.dll"); + } + + private static void LoadNativeAssembly(string nativeBinaryPath, string assemblyName) + { + var path = Path.Combine(nativeBinaryPath, assemblyName); + var ptr = LoadLibrary(path); + if (ptr == IntPtr.Zero) + { + throw new Exception(string.Format( + "Error loading {0} (ErrorCode: {1})", + assemblyName, + Marshal.GetLastWin32Error())); + } + } + } +} \ No newline at end of file diff --git a/CMS_SC/SqlServerTypes/readme.htm b/CMS_SC/SqlServerTypes/readme.htm new file mode 100644 index 0000000..0f9eade --- /dev/null +++ b/CMS_SC/SqlServerTypes/readme.htm @@ -0,0 +1,39 @@ + + + + Microsoft.SqlServer.Types + + + +
+

Action required to load native assemblies

+

+ To deploy an application that uses spatial data types to a machine that does not have 'System CLR Types for SQL Server' installed you also need to deploy the native assembly SqlServerSpatial110.dll. Both x86 (32 bit) and x64 (64 bit) versions of this assembly have been added to your project under the SqlServerTypes\x86 and SqlServerTypes\x64 subdirectories. The native assembly msvcr100.dll is also included in case the C++ runtime is not installed. +

+

+ You need to add code to load the correct one of these assemblies at runtime (depending on the current architecture). +

+

ASP.NET applications

+

+ For ASP.NET applications, add the following line of code to the Application_Start method in Global.asax.cs: +

    SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
+

+

Desktop applications

+

+ For desktop applications, add the following line of code to run before any spatial operations are performed: +

    SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
+

+
+ + \ No newline at end of file diff --git a/CMS_SC/Web.config b/CMS_SC/Web.config index 4ee5a4f..dfb9be8 100644 --- a/CMS_SC/Web.config +++ b/CMS_SC/Web.config @@ -229,6 +229,14 @@ + + + + + + + +