forked from laochiangx/Common.Utility
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
131 changed files
with
1,509 additions
and
71,336 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file modified
BIN
+216 KB
(110%)
Utility基础类大全/.vs/Common.Utility/v16/Server/sqlite3/storage.ide
Binary file not shown.
Binary file modified
BIN
+3.71 MB
(1600%)
Utility基础类大全/.vs/Common.Utility/v16/Server/sqlite3/storage.ide-wal
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace SqlServerTypes | ||
{ | ||
/// <summary> | ||
/// Utility methods related to CLR Types for SQL Server | ||
/// </summary> | ||
public class Utilities | ||
{ | ||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] | ||
private static extern IntPtr LoadLibrary(string libname); | ||
|
||
/// <summary> | ||
/// Loads the required native assemblies for the current architecture (x86 or x64) | ||
/// </summary> | ||
/// <param name="rootApplicationPath"> | ||
/// Root path of the current application. Use Server.MapPath(".") for ASP.NET applications | ||
/// and AppDomain.CurrentDomain.BaseDirectory for desktop applications. | ||
/// </param> | ||
public static void LoadNativeAssemblies(string rootApplicationPath) | ||
{ | ||
var nativeBinaryPath = IntPtr.Size > 4 | ||
? Path.Combine(rootApplicationPath, @"SqlServerTypes\x64\") | ||
: Path.Combine(rootApplicationPath, @"SqlServerTypes\x86\"); | ||
|
||
LoadNativeAssembly(nativeBinaryPath, "msvcr120.dll"); | ||
LoadNativeAssembly(nativeBinaryPath, "SqlServerSpatial140.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())); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<html lang="en-US"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Microsoft.SqlServer.Types</title> | ||
<style> | ||
body { | ||
background: #fff; | ||
color: #505050; | ||
margin: 20px; | ||
} | ||
|
||
#main { | ||
background: #efefef; | ||
padding: 5px 30px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="main"> | ||
<h1>Action required to load native assemblies</h1> | ||
<p> | ||
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 SqlServerSpatial140.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 msvcr120.dll is also included in case the C++ runtime is not installed. | ||
</p> | ||
<p> | ||
You need to add code to load the correct one of these assemblies at runtime (depending on the current architecture). | ||
</p> | ||
<h2>ASP.NET Web Sites</h2> | ||
<p> | ||
For ASP.NET Web Sites, add the following block of code to the code behind file of the Web Form where you have added Report Viewer Control: | ||
<pre> | ||
Default.aspx.cs: | ||
|
||
public partial class _Default : System.Web.UI.Page | ||
{ | ||
static bool _isSqlTypesLoaded = false; | ||
|
||
public _Default() | ||
{ | ||
if (!_isSqlTypesLoaded) | ||
{ | ||
SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~")); | ||
_isSqlTypesLoaded = true; | ||
} | ||
|
||
} | ||
} | ||
</pre> | ||
</p> | ||
<h2>ASP.NET Web Applications</h2> | ||
<p> | ||
For ASP.NET Web Applications, add the following line of code to the Application_Start method in Global.asax.cs: | ||
<pre> SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));</pre> | ||
</p> | ||
<h2>Desktop Applications</h2> | ||
<p> | ||
For desktop applications, add the following line of code to run before any spatial operations are performed: | ||
<pre> SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);</pre> | ||
</p> | ||
</div> | ||
</body> | ||
</html> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.