当前位置: 首页  >  SqlServer  >  SQLSERVER一些公用DLL的作用解释

SQLSERVER一些公用DLL的作用解释 TOP

如果你的SQLSERVER安装在C盘的话,下面的路径就是相应SQLSERVER版本的公用DLL的存放路径

SQL2005

C:\Program Files\Microsoft SQL Server\90\SDK\Assemblies\

SQL2008

C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\

SQL2012

C:\Program Files\Microsoft SQL Server\110\SDK\Assemblies\

 

 

可以看到随着SQLSERVER版本的升级,这些公用DLL变得越来越多了,因为SQLSERVER的功能越来越多了

 

 


这些DLL有什么用??

这些DLL是供SQLSERVER调用的,因为这些公用DLL在SQLSERVER的很多组件中都有用到,所以SQLSERVER就把这些

DLL放到X:\Program Files\Microsoft SQL Server\X\SDK\Assemblies\文件夹下以供其他SQLSERVER组件调用

例如SSIS、SSAS、数据库引擎还有其他的工具

其实从文件夹路径名我们就可以知道这些DLL的作用:SDK\Assemblies\

大家不知道SDK的含义可以百度一下,不过可能大家比较赖,我就贴出来吧

SDK(Software Development Kit, 即软件开发工具包 )一般是一些被软件工程师用于为特定的软件包、软件框架、硬件平台、操作系统等

建立应用软件的开发工具的集合。

资深程序员一定知道SDK的作用,他就是某个软件提供给我们程序员用来开发的一些接口或者API

 

本人觉得X:\Program Files\Microsoft SQL Server\X\SDK\Assemblies\文件夹下面的这些DLL不只是提供给SQLSERVER调用的

我们也可以调用这些DLL来开发SQLSERVER数据库的一些相关软件和工具

 

例子一:

园子里的胡勇大侠就用了下面的两个DLL来做出了:   (喷血分享)利用.NET生成数据库表的创建脚本,类似SqlServer编写表的CREATE语句

Microsoft.SqlServer.ConnectionInfo.dll

Microsoft.SqlServer.Management.Sdk.Sfc.dll

例子二:

又例如这个帖子:用c#做了个,sqlServer2005里面那个事件监控器一样的程序,启动问题请帮看看

用Microsoft.SqlServer.ConnectionInfo.dll这个DLL做一个类似于SQL TRACE的工具出来,用来实时查看执行的脚本以及其他信息

例子三:

SQLDoc Sharp(SQLSERVER数据库文档生成工具)

这个工具在codeproject上可以下载:http://www.codeproject.com/Articles/35790/SQLDoc-Sharp

用到了下面的DLL

Microsoft.SqlServer.ConnectionInfo.dll

Microsoft.SqlServer.Management.Sdk.Sfc.dll

Microsoft.SqlServer.Smo.dll

Microsoft.SqlServer.SmoExtended.dll

Microsoft.SqlServer.SqlEnum.dll

 


公用DLL用什么语言编写?

我们可以发现上面的三个例子中的工具都是用.NET编写的工具,包括SQLDoc Sharp都是用.NET编写的winfrom软件

我们用ILSpy这个软件反编译一下各个SQLSERVER版本的下DLL

将DLL全部拖入去ILSpy里面

SQL2005

SQL2008

SQL2012

 

 

SQL2008里面有两个DLL是不能够反编译的,分别是Redist_TSqlLanguageService.dllRedist_DACFramework.dll

SQL2012里面只有一个DLL是不能够反编译的,是Redist_TSqlLanguageService.dll

 

不能被反编译的DLL有可能是用C或者C++编写的

我估计这些不能反编译的dll不会提供API功能给用户,只是给SQLSERVER调用的,而且这些DLL对于SQLSERVER的性能有至关重要的作用

所以用C或者C++编写

 

从上面反编译这些DLL的情况来看,SQLSERVER里面有很大一部分组件或者代码都是用.NET来编写的

除了一些关键功能或者涉及到性能相关的功能组件用C或者C++编写

这里从另一个侧面也可以看出微软对.NET的重用,从SQLSERVER2005开始大量用.NET来编写一些组件代码

 

从上面三个例子中也可以看出为什麽他们首选.NET来编写这些工具,因为这些公用DLL本来就是.NET DLL(可托管代码)


简单介绍DLL

限于本人的能力有限,本人就只简单介绍比较熟悉的DLL,其他不熟悉的大家可以查MSDN或者百度

我这里会给出一些DLL的资料和查百度、MSDN时候的结果

我这里只介绍SQLSERVER2012的,因为SQLSERVER2012比较齐全,但是某些功能在不同的SQLSERVER版本里会有变化

例如上面第二个例子里:用c#做了个,sqlServer2005里面那个事件监控器一样的程序,启动问题请帮看看

里面说到了TMO这个类在SQL2005版本的SDK里面和SQL2008版本的SDK里面有变化,导致运行时出错

使用Trace Management Object监测和诊断SQL Server(一)

在SQL Server 2005里TMO对象被实现在了Microsoft.SqlServer.ConnectionInfo.dll里,

在SQL Server 2008里TMO对象则被移到了Microsoft.SqlServer.ConnectionInfoExtended.dll里,

但仍然在Microsoft.SqlServer.Management.Trace命名空间里。

 

类似上面的有变化的API我就不说了,大家开发的时候一定要查清楚MSDN和百度,不要搞错,因为这些SDK的文档比较少

大部分都是E文的,开发起来会比较头痛

 

废话不说了,开始~

 

Microsoft.AnalysisServices.DLL

Microsoft.DataWarehouse.Interfaces.DLL

SSAS,数据仓库相关的接口

Kpi 类:http://technet.microsoft.com/zh-cn/library/microsoft.analysisservices.kpi.aspx

http://technet.microsoft.com/zh-cn/magazine/microsoft.datawarehouse.interfaces.idesignertoolwindowservice.gettoolwindow.aspx

 

Microsoft.ExceptionMessageBox.DLL

SQLSERVER中的各种异常对话框都调用这个DLL

http://technet.microsoft.com/zh-cn/library/microsoft.sqlserver.messagebox.exceptionmessagebox.showcheckbox.aspx

http://social.msdn.microsoft.com/Forums/sqlserver/en-US/138794c0-228f-4d8e-91d8-6ffb704f828c/microsoftexceptionmessageboxdll?forum=sqltools

 

Microsoft.ReportingServices.Interfaces.DLL

SSRS的相关的接口

http://support.microsoft.com/kb/873267/zh-cn

Microsoft.SqlServer.Smo.DLL

Microsoft.SqlServer.SmoExtended.DLL

Microsoft.SqlServer.Management.Sdk.Sfc.DLL

Microsoft.SqlServer.ConnectionInfo.DLL

Microsoft.SqlServer.ConnectionInfoExtended.DLL

SMO:SQLSERVER管理对象

监控SQLSERVER或者连接SQLSERVER用到

提供SMO对象功能,是SqlServer Management Ojbects的简称,由SQL2005提供的管理对象

只要SQL Server Management Studio能实现的东西,用smo都能实现,因为SQL Server Management Studio就是用smo开发的。

如果你有足够的实力,完全可以开发一个可以藐视SQL Server Management Studio的工具,比如加入智能感知的功能

 

为了支持 SQL Server 的管理,Integration Services 提供了可以遍历 SQL 管理对象 (SMO) 的对象的枚举器。

例如,包可使用 SMO 枚举器对某个 SQL Server 安装中的 Jobs 集合中的每个作业执行相同的管理功能。

 

http://support.microsoft.com/kb/956026/zh-cn

http://support.microsoft.com/kb/922214/zh-cn

http://blogs.msdn.com/b/sqlcrd/archive/2009/01/14/trace-management-object-sql-server.aspx

http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.aspx

 

Microsoft.SqlServer.Dts.Design.DLL

Microsoft.SqlServer.DTSPipelineWrap.DLL

Microsoft.SQLServer.DTSRuntimeWrap.DLL

Microsoft.SQLServer.ManagedDTS.DLL

Data Transformation Services (DTS) 数据传输服务相关的DLL

http://bbs.csdn.net/topics/200087190

http://social.msdn.microsoft.com/Forums/sqlserver/zh-CN/916a39c4-c35a-4ba1-8f7a-dde4aadb1675/assembilies-microsoftsqlserverdtspipelinewrap?forum=sqlintegrationservices

http://social.msdn.microsoft.com/Forums/zh-CN/10a94835-8913-40c6-82f5-1d4da37da730/microsoftsqlservermanageddtsdll-not-working?forum=sqlintegrationservices 

 

Microsoft.SqlServer.Management.RegisteredServers.DLL

注册服务器需要用到的DLL

http://connect.microsoft.com/SQLServer/feedback/details/369377/microsoft-sqlserver-management-registeredservers-dll-missing

http://social.msdn.microsoft.com/Forums/sqlserver/zh-CN/7fa941bd-68d3-4ae2-9673-8ab4f7cb2602/microsoftsqlservermanagementregisteredserversdll?forum=sqlsmoanddmo

 

Microsoft.SqlServer.Management.Utility.DLL

Microsoft.SqlServer.Management.UtilityEnum.DLL

Utility:实用工具类代表一个控制点(UCP)定义的SQL服务器来管理一个或多个的远程SQLSERVER实例的方法和属性

UtilityEnum:该microsoft.sqlserver.management.utility命名空间包含展现SQLSERVER实用工具对象的类

http://msdn.microsoft.com/zh-cn/library/ee242093(v=sql.110).aspx

http://technet.microsoft.com/zh-cn/magazine/microsoft.sqlserver.management.utility(SQL.105).aspx

Microsoft.SqlServer.Management.XEvent.DLL

Microsoft.SqlServer.Management.XEventEnum.DLL

扩展事件相关的DLL

XEvent:在SQLSERVER客户端组件和服务器端组件里创建和使用SQLSERVER扩展事件通过通用对象模型

扩展事件基础设施支持SQL服务器事件数据的相关性

在某些情况下,基础设施也可以用于从数据看应用程序和操作系统里获取相关数据
http://msdn.microsoft.com/zh-cn/library/microsoft.sqlserver.management.xevent.aspx

 

Microsoft.SqlServer.OlapEnum.DLL

olap系统相关的DLL

Microsoft.SqlServer.Rmo.DLL

Microsoft.SqlServer.Replication.DLL

与复制相关的DLL

RMO:复制管理对象

http://social.msdn.microsoft.com/Forums/sqlserver/zh-CN/fd02b8ad-db40-4785-993f-1adfd00d5a0e/sql-server-2008-r2-replication-management-objects-sqlrmomsi-?forum=sqlreplication

http://social.msdn.microsoft.com/Forums/sqlserver/en-US/07a89afe-50ba-4133-bfa5-e5f9a7a03bcb/rmo-replication-between-sql-server-2005-amd-sql-server-2005-express?forum=sqlreplication

Microsoft.SqlServer.Replication.dll 引发的IIS异常

http://social.msdn.microsoft.com/Forums/zh-CN/ff657b77-8a6e-4602-9903-9c4fca11e3b5/microsoftsqlserverreplicationdll-not-found?forum=sqlreplication

 

 

Microsoft.SqlServer.ServiceBrokerEnum.DLL

ServiceBroker相关技术的DLL

http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.broker.servicebroker.aspx

Microsoft.SqlServer.SqlWmiManagement.DLL

Microsoft.SqlServer.WmiEnum.DLL

与WMI(Windows Management Instrumentation,Windows 管理规范)相关的DLL

http://support.microsoft.com/kb/967199

打开【SQL Server 配置管理器】提示:无法连接到 WMI 提供程序。您没有权限或者该服务器无法访问。

请注意,您只能使用 SQL Server 配置管理器来管理 SQL Server 2005 服务器。

如何在SQL Server 中添加WMI alert

Microsoft.SqlServer.SString.DLL

SecureString这个类里面有很多字符串相关的C#函数

http://social.msdn.microsoft.com/Forums/sqlserver/zh-CN/22131a3d-f63b-42dc-a211-fdef785886ae/sql-server-2008-management-studio-error-when-connecting-to-server-method-not-found-int32

这个类里面的代码

类:SqlSecureString

  1 using System;
  2 using System.Data.SqlTypes;
  3 using System.Globalization;
  4 using System.Runtime.InteropServices;
  5 using System.Security;
  6 using System.Security.Cryptography;
  7 using System.Security.Permissions;
  8 using System.Text;
  9 using System.Xml;
 10 using System.Xml.Schema;
 11 using System.Xml.Serialization;
 12 namespace Microsoft.SqlServer.Common
 13 {
 14     public sealed class SqlSecureString : ICloneable, IComparable, IComparable<SqlSecureString>, IDisposable, IXmlSerializable
 15     {
 16         private SecureString data;
 17         private int length;
 18         private static SqlSecureString empty;
 19         private static byte[] additionalEntropy;
 20         public char this[int index]
 21         {
 22             get
 23             {
 24                 return this.ToString()[index];
 25             }
 26         }
 27         public static SqlSecureString Empty
 28         {
 29             get
 30             {
 31                 return SqlSecureString.empty;
 32             }
 33         }
 34         public int Length
 35         {
 36             get
 37             {
 38                 return this.length;
 39             }
 40         }
 41         static SqlSecureString()
 42         {
 43             SqlSecureString.additionalEntropy = new byte[]
 44             {
 45                 2, 
 46                 0, 
 47                 0, 
 48                 8, 
 49                 0, 
 50                 4
 51             };
 52             SqlSecureString.empty = new SqlSecureString();
 53         }
 54         public SqlSecureString()
 55         {
 56             this.data = new SecureString();
 57             this.length = 0;
 58         }
 59         public SqlSecureString(string str)
 60         {
 61             if (str == null)
 62             {
 63                 throw new ArgumentNullException();
 64             }
 65             this.data = new SecureString();
 66             this.length = 0;
 67             char[] array = str.ToCharArray();
 68             for (int i = 0; i < array.Length; i++)
 69             {
 70                 char c = array[i];
 71                 this.data.AppendChar(c);
 72                 this.length++;
 73             }
 74         }
 75         public SqlSecureString(SecureString secureString)
 76         {
 77             if (secureString == null)
 78             {
 79                 throw new ArgumentNullException();
 80             }
 81             this.data = secureString.Copy();
 82             this.length = secureString.Length;
 83         }
 84         public SqlSecureString(IntPtr bstr, int length)
 85         {
 86             if (bstr == IntPtr.Zero)
 87             {
 88                 throw new ArgumentNullException();
 89             }
 90             string text = Marshal.PtrToStringAuto(bstr, length);
 91             this.data = new SecureString();
 92             this.length = 0;
 93             char[] array = text.ToCharArray();
 94             for (int i = 0; i < array.Length; i++)
 95             {
 96                 char c = array[i];
 97                 this.data.AppendChar(c);
 98                 this.length++;
 99             }
100         }
101         public void Dispose()
102         {
103             if (this.data != null && this != SqlSecureString.empty)
104             {
105                 this.data.Dispose();
106                 this.data = null;
107             }
108         }
109         public object Clone()
110         {
111             return this.Copy();
112         }
113         public static int Compare(SqlSecureString strA, SqlSecureString strB)
114         {
115             return string.Compare((string)strA, (string)strB);
116         }
117         public static int Compare(SqlSecureString strA, SqlSecureString strB, bool ignoreCase)
118         {
119             return string.Compare((string)strA, (string)strB, ignoreCase);
120         }
121         public static int Compare(SqlSecureString strA, SqlSecureString strB, StringComparison comparisonType)
122         {
123             return string.Compare((string)strA, (string)strB, comparisonType);
124         }
125         public static int Compare(SqlSecureString strA, SqlSecureString strB, bool ignoreCase, CultureInfo cultureInfo)
126         {
127             return string.Compare((string)strA, (string)strB, ignoreCase, cultureInfo);
128         }
129         public static int Compare(SqlSecureString strA, int indexA, SqlSecureString strB, int indexB, int length)
130         {
131             return string.Compare((string)strA, indexA, (string)strB, indexB, length);
132         }
133         public static int Compare(SqlSecureString strA, int indexA, SqlSecureString strB, int indexB, int length, bool ignoreCase)
134         {
135             return string.Compare((string)strA, indexA, (string)strB, indexB, length, ignoreCase);
136         }
137         public static int Compare(SqlSecureString strA, int indexA, SqlSecureString strB, int indexB, int length, StringComparison comparisonType)
138         {
139             return string.Compare((string)strA, indexA, (string)strB, indexB, length, comparisonType);
140         }
141         public static int Compare(SqlSecureString strA, int indexA, SqlSecureString strB, int indexB, int length, bool ignoreCase, CultureInfo cultureInfo)
142         {
143             return string.Compare((string)strA, indexA, (string)strB, indexB, length, ignoreCase, cultureInfo);
144         }
145         public static int CompareOrdinal(SqlSecureString strA, SqlSecureString strB)
146         {
147             return string.CompareOrdinal((string)strA, (string)strB);
148         }
149         public static int CompareOrdinal(SqlSecureString strA, int indexA, SqlSecureString strB, int indexB, int length)
150         {
151             return string.CompareOrdinal((string)strA, indexA, (string)strB, indexB, length);
152         }
153         public int CompareTo(object obj)
154         {
155             int result = 1;
156             if (obj != null)
157             {
158                 result = this.ToString().CompareTo(obj.ToString());
159             }
160             return result;
161         }
162         public int CompareTo(SqlSecureString other)
163         {
164             int result = 1;
165             if (other != null)
166             {
167                 result = this.ToString().CompareTo(other.ToString());
168             }
169             return result;
170         }
171         public static SqlSecureString Concat(object obj)
172         {
173             SqlSecureString result;
174             if (obj != null)
175             {
176                 result = new SqlSecureString(obj.ToString());
177             }
178             else
179             {
180                 result = new SqlSecureString();
181             }
182             return result;
183         }
184         public static SqlSecureString Concat(params object[] args)
185         {
186             return new SqlSecureString(string.Concat(args));
187         }
188         public bool Contains(string value)
189         {
190             if (value == null)
191             {
192                 throw new ArgumentNullException();
193             }
194             return this.ToString().Contains(value);
195         }
196         public bool Contains(SqlSecureString value)
197         {
198             if (value == null)
199             {
200                 throw new ArgumentNullException();
201             }
202             return this.ToString().Contains(value.ToString());
203         }
204         public SqlSecureString Copy()
205         {
206             return new SqlSecureString(this.data);
207         }
208         public bool EndsWith(SqlSecureString value)
209         {
210             if (value == null)
211             {
212                 throw new ArgumentNullException();
213             }
214             return this.ToString().EndsWith(value.ToString());
215         }
216         public bool EndsWith(SqlSecureString value, bool ignoreCase, CultureInfo cultureInfo)
217         {
218             if (value == null)
219             {
220                 throw new ArgumentNullException();
221             }
222             return this.ToString().EndsWith(value.ToString(), ignoreCase, cultureInfo);
223         }
224         public override bool Equals(object obj)
225         {
226             bool result = false;
227             if (obj != null)
228             {
229                 result = this.ToString().Equals(obj);
230             }
231             return result;
232         }
233         public bool Equals(SqlSecureString other)
234         {
235             return this == other;
236         }
237         public static bool Equals(SqlSecureString strA, SqlSecureString strB)
238         {
239             return strA == strB;
240         }
241         public bool Equals(SqlSecureString other, StringComparison comparisonType)
242         {
243             return this.ToString().Equals((string)other, comparisonType);
244         }
245         public static bool Equals(SqlSecureString strA, SqlSecureString strB, StringComparison comparisonType)
246         {
247             return string.Equals((string)strA, (string)strB, comparisonType);
248         }
249         public static SqlSecureString Format(string format, params object[] arguments)
250         {
251             return new SqlSecureString(string.Format(format, arguments));
252         }
253         public static SqlSecureString Format(IFormatProvider formatProvider, string format, params object[] arguments)
254         {
255             return new SqlSecureString(string.Format(formatProvider, format, arguments));
256         }
257         public override int GetHashCode()
258         {
259             return this.ToString().GetHashCode();
260         }
261         public int IndexOf(char value)
262         {
263             return this.ToString().IndexOf(value);
264         }
265         public int IndexOf(string value)
266         {
267             return this.ToString().IndexOf(value);
268         }
269         public int IndexOf(char value, int startIndex)
270         {
271             return this.ToString().IndexOf(value, startIndex);
272         }
273         public int IndexOf(string value, int startIndex)
274         {
275             return this.ToString().IndexOf(value, startIndex);
276         }
277         public int IndexOf(char value, int startIndex, int count)
278         {
279             return this.ToString().IndexOf(value, startIndex, count);
280         }
281         public int IndexOf(string value, int startIndex, int count)
282         {
283             return this.ToString().IndexOf(value, startIndex, count);
284         }
285         public int IndexOfAny(char[] anyOf)
286         {
287             return this.ToString().IndexOfAny(anyOf);
288         }
289         public int IndexOfAny(char[] anyOf, int startIndex)
290         {
291             return this.ToString().IndexOfAny(anyOf, startIndex);
292         }
293         public int IndexOfAny(char[] anyOf, int startIndex, int count)
294         {
295             return this.ToString().IndexOfAny(anyOf, startIndex, count);
296         }
297         public SqlSecureString Insert(int startIndex, SqlSecureString value)
298         {
299             if (value == null)
300             {
301                 throw new ArgumentNullException();
302             }
303             return new SqlSecureString(this.ToString().Insert(startIndex, value.ToString()));
304         }
305         public SqlSecureString Insert(int startIndex, string value)
306         {
307             if (value == null)
308             {
309                 throw new ArgumentNullException();
310             }
311             return new SqlSecureString(this.ToString().Insert(startIndex, value));
312         }
313         public static SqlSecureString Join(object separator, object[] value)
314         {
315             return SqlSecureString.Join(separator, value, 0, value.Length);
316         }
317         public static SqlSecureString Join(object separator, object[] value, int startIndex, int count)
318         {
319             if (value == null)
320             {
321                 throw new ArgumentNullException();
322             }
323             if (startIndex < 0 || value.Length < startIndex + count)
324             {
325                 throw new ArgumentOutOfRangeException();
326             }
327             StringBuilder stringBuilder = new StringBuilder();
328             if (0 < count)
329             {
330                 string text = (separator != null) ? separator.ToString() : string.Empty;
331                 bool flag = text.Length != 0;
332                 int num = startIndex;
333                 if (value[num] != null)
334                 {
335                     stringBuilder.Append(value[num].ToString());
336                 }
337                 num++;
338                 while (num - startIndex < count)
339                 {
340                     if (value[num] != null)
341                     {
342                         if (flag)
343                         {
344                             stringBuilder.Append(text);
345                         }
346                         stringBuilder.Append(value[num].ToString());
347                     }
348                     num++;
349                 }
350             }
351             return new SqlSecureString(stringBuilder.ToString());
352         }
353         public int LastIndexOf(char value)
354         {
355             return this.ToString().LastIndexOf(value);
356         }
357         public int LastIndexOf(string value)
358         {
359             return this.ToString().LastIndexOf(value);
360         }
361         public int LastIndexOf(char value, int startIndex)
362         {
363             return this.ToString().LastIndexOf(value, startIndex);
364         }
365         public int LastIndexOf(string value, int startIndex)
366         {
367             return this.ToString().LastIndexOf(value, startIndex);
368         }
369         public int LastIndexOf(char value, int startIndex, int count)
370         {
371             return this.ToString().LastIndexOf(value, startIndex, count);
372         }
373         public int LastIndexOf(string value, int startIndex, int count)
374         {
375             return this.ToString().LastIndexOf(value, startIndex, count);
376         }
377         public int LastIndexOfAny(char[] anyOf)
378         {
379             return this.ToString().LastIndexOfAny(anyOf);
380         }
381         public int LastIndexOfAny(char[] anyOf, int startIndex)
382         {
383             return this.ToString().LastIndexOfAny(anyOf, startIndex);
384         }
385         public int LastIndexOfAny(char[] anyOf, int startIndex, int count)
386         {
387             return this.ToString().LastIndexOfAny(anyOf, startIndex, count);
388         }
389         public static bool operator ==(SqlSecureString strA, SqlSecureString strB)
390         {
391             bool result = false;
392             bool flag = strA == null;
393             bool flag2 = strB == null;
394             if (flag && flag2)
395             {
396                 result = true;
397             }
398             else
399             {
400                 if (!flag && !flag2)
401                 {
402                     result = (0 == string.CompareOrdinal(strA.ToString(), strB.ToString()));
403                 }
404             }
405             return result;
406         }
407         public static bool operator ==(SqlSecureString strA, object strB)
408         {
409             bool result = false;
410             bool flag = strA == null;
411             bool flag2 = strB == null;
412             if (flag && flag2)
413             {
414                 result = true;
415             }
416             else
417             {
418                 if (!flag && !flag2)
419                 {
420                     result = (0 == string.CompareOrdinal(strA.ToString(), strB.ToString()));
421                 }
422             }
423             return result;
424         }
425         public static bool operator ==(object strA, SqlSecureString strB)
426         {
427             bool result = false;
428             bool flag = strA == null;
429             bool flag2 = strB == null;
430             if (flag && flag2)
431             {
432                 result = true;
433             }
434             else
435             {
436                 if (!flag && !flag2)
437                 {
438                     result = (0 == string.CompareOrdinal(strA.ToString(), strB.ToString()));
439                 }
440             }
441             return result;
442         }
443         public static bool operator !=(SqlSecureString strA, SqlSecureString strB)
444         {
445             return !(strA == strB);
446         }
447         public static bool operator !=(SqlSecureString strA, object strB)
448         {
449             return !(strA == strB);
450         }
451         public static bool operator !=(object strA, SqlSecureString strB)
452         {
453             return !(strA == strB);
454         }
455         public static SqlSecureString operator +(SqlSecureString strA, SqlSecureString strB)
456         {
457             return SqlSecureString.Concat(new object[]
458             {
459                 strA, 
460                 strB
461             });
462         }
463         public SqlSecureString PadLeft(int totalWidth)
464         {
465             return new SqlSecureString(this.ToString().PadLeft(totalWidth));
466         }
467         public SqlSecureString PadLeft(int totalWidth, char paddingChar)
468         {
469             return new SqlSecureString(this.ToString().PadLeft(totalWidth, paddingChar));
470         }
471         public SqlSecureString PadRight(int totalWidth)
472         {
473             return new SqlSecureString(this.ToString().PadRight(totalWidth));
474         }
475         public SqlSecureString PadRight(int totalWidth, char paddingChar)
476         {
477             return new SqlSecureString(this.ToString().PadRight(totalWidth, paddingChar));
478         }
479         public SqlSecureString Remove(int startIndex)
480         {
481             return new SqlSecureString(this.ToString().Remove(startIndex));
482         }
483         public SqlSecureString Remove(int startIndex, int count)
484         {
485             return new SqlSecureString(this.ToString().Remove(startIndex, count));
486         }
487         public SqlSecureString Replace(char oldChar, char newChar)
488         {
489             return new SqlSecureString(this.ToString().Replace(oldChar, newChar));
490         }
491         public SqlSecureString Replace(SqlSecureString oldValue, SqlSecureString newValue)
492         {
493             return new SqlSecureString(this.ToString().Replace(oldValue.ToString(), newValue.ToString()));
494         }
495         public SqlSecureString[] Split(char[] separator)
496         {
497             return SqlSecureString.StringArrayToSqlSecureStringArray(this.ToString().Split(separator));
498         }
499         public SqlSecureString[] Split(char[] separator, int count)
500         {
501             return SqlSecureString.StringArrayToSqlSecureStringArray(this.ToString().Split(separator, count));
502         }
503         public SqlSecureString[] Split(char[] separator, StringSplitOptions options)
504         {
505             return SqlSecureString.StringArrayToSqlSecureStringArray(this.ToString().Split(separator, options));
506         }
507         public SqlSecureString[] Split(char[] separator, int count, StringSplitOptions options)
508         {
509             return SqlSecureString.StringArrayToSqlSecureStringArray(this.ToString().Split(separator, count, options));
510         }
511         public SqlSecureString[] Split(string[] separator, StringSplitOptions options)
512         {
513             return SqlSecureString.StringArrayToSqlSecureStringArray(this.ToString().Split(separator, options));
514         }
515         public SqlSecureString[] Split(string[] separator, int count, StringSplitOptions options)
516         {
517             return SqlSecureString.StringArrayToSqlSecureStringArray(this.ToString().Split(separator, count, options));
518         }
519         public bool StartsWith(SqlSecureString value)
520         {
521             if (value == null)
522             {
523                 throw new ArgumentNullException();
524             }
525             return this.ToString().StartsWith(value.ToString());
526         }
527         public bool StartsWith(SqlSecureString value, bool ignoreCase, CultureInfo culture)
528         {
529             if (value == null)
530             {
531                 throw new ArgumentNullException();
532             }
533             return this.ToString().StartsWith(value.ToString(), ignoreCase, culture);
534         }
535         public static SqlSecureString[] StringArrayToSqlSecureStringArray(string[] array)
536         {
537             SqlSecureString[] array2 = null;
538             if (array != null)
539             {
540                 array2 = new SqlSecureString[array.Length];
541                 for (int i = 0; i < array.Length; i++)
542                 {
543                     if (array[i] != null)
544                     {
545                         array2[i] = new SqlSecureString(array[i]);
546                     }
547                     else
548                     {
549                         array2[i] = null;
550                     }
551                 }
552             }
553             return array2;
554         }
555         public SqlSecureString Substring(int startIndex)
556         {
557             return new SqlSecureString(this.ToString().Substring(startIndex));
558         }
559         public SqlSecureString Substring(int startIndex, int length)
560         {
561             return new SqlSecureString(this.ToString().Substring(startIndex, length));
562         }
563         public IntPtr ToBstr()
564         {
565             return Marshal.SecureStringToBSTR(this.data);
566         }
567         public SqlSecureString ToLower()
568         {
569             return new SqlSecureString(this.ToString().ToLower());
570         }
571         public SqlSecureString ToLower(CultureInfo culture)
572         {
573             return new SqlSecureString(this.ToString().ToLower(culture));
574         }
575         public SqlSecureString ToLowerInvariant()
576         {
577             return new SqlSecureString(this.ToString().ToLowerInvariant());
578         }
579         public SecureString ToSecureString()
580         {
581             return this.data.Copy();
582         }
583         public override string ToString()
584         {
585             string result = string.Empty;
586             if (this.Length != 0)
587             {
588                 new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert();
589                 IntPtr intPtr = Marshal.SecureStringToBSTR(this.data);
590                 result = Marshal.PtrToStringBSTR(intPtr);
591                 Marshal.ZeroFreeBSTR(intPtr);
592             }
593             return result;
594         }
595         public SqlSecureString ToUpper()
596         {
597             return new SqlSecureString(this.ToString().ToUpper());
598         }
599         public SqlSecureString ToUpper(CultureInfo culture)
600         {
601             return new SqlSecureString(this.ToString().ToUpper(culture));
602         }
603         public SqlSecureString ToUpperInvariant()
604         {
605             return new SqlSecureString(this.ToString().ToUpperInvariant());
606         }
607         public SqlSecureString Trim()
608         {
609             return new SqlSecureString(this.ToString().Trim());
610         }
611         public SqlSecureString Trim(char[] trimChars)
612         {
613             return new SqlSecureString(this.ToString().Trim(trimChars));
614         }
615         public SqlSecureString TrimEnd(char[] trimChars)
616         {
617             return new SqlSecureString(this.ToString().TrimEnd(trimChars));
618         }
619         public SqlSecureString TrimStart(char[] trimChars)
620         {
621             return new SqlSecureString(this.ToString().TrimStart(trimChars));
622         }
623         public static explicit operator string(SqlSecureString sqlSecureString)
624         {
625             string result = null;
626             if (sqlSecureString != null)
627             {
628                 result = sqlSecureString.ToString();
629             }
630             return result;
631         }
632         public static implicit operator SqlSecureString(string str)
633         {
634             SqlSecureString result = null;
635             if (str != null)
636             {
637                 result = new SqlSecureString(str);
638             }
639             return result;
640         }
641         public static implicit operator SecureString(SqlSecureString sqlSecureString)
642         {
643             SecureString result = null;
644             if (sqlSecureString != null)
645             {
646                 result = sqlSecureString.data.Copy();
647             }
648             return result;
649         }
650         public static implicit operator SqlSecureString(SecureString secureString)
651         {
652             SqlSecureString result = null;
653             if (secureString != null)
654             {
655                 result = new SqlSecureString(secureString);
656             }
657             return result;
658         }
659         public static explicit operator SqlString(SqlSecureString sqlSecureString)
660         {
661             SqlString result = null;
662             if (sqlSecureString != null)
663             {
664                 result = new SqlString(sqlSecureString.ToString());
665             }
666             return result;
667         }
668         public static implicit operator SqlSecureString(SqlString str)
669         {
670             SqlSecureString result = null;
671             if (!str.IsNull)
672             {
673                 result = new SqlSecureString(str.ToString());
674             }
675             return result;
676         }
677         public void WriteXml(XmlWriter writer)
678         {
679             byte[] array = ProtectedData.Protect(Encoding.Unicode.GetBytes(this.ToString()), SqlSecureString.additionalEntropy, DataProtectionScope.CurrentUser);
680             writer.WriteBase64(array, 0, array.Length);
681             writer.Flush();
682         }
683         public void ReadXml(XmlReader reader)
684         {
685             reader.Read();
686             string s = reader.ReadContentAsString();
687             byte[] array = ProtectedData.Unprotect(Convert.FromBase64String(s), SqlSecureString.additionalEntropy, DataProtectionScope.CurrentUser);
688             this.data = new SecureString();
689             this.length = 0;
690             char[] chars = Encoding.Unicode.GetChars(array);
691             for (int i = 0; i < chars.Length; i++)
692             {
693                 char c = chars[i];
694                 this.data.AppendChar(c);
695                 this.length++;
696             }
697             for (int j = 0; j < array.Length; j++)
698             {
699                 array[j] = 0;
700             }
701             reader.ReadEndElement();
702         }
703         public XmlSchema GetSchema()
704         {
705             return null;
706         }
707     }
708 }
View Code

Microsoft.SqlServer.Types.DLL

处理SQLSERVER数据类型相关的DLL

Microsoft.SqlServer.Types 命名空间包含了处理层级和特别数据类型的类,例如  geometry 和 geographic数据类型

请教如何应用Microsoft.SqlServer.Types 命名空间

Microsoft.SqlServer.Types 命名空间


 


总结

SQLSERVER里面有很多管理对象,例如SMO、RMO、TMO、AMO

TMO:TRACE跟踪管理对象

AMO:分析管理对象

大家在开发的时候都可以调用这些管理对象提供的API来开发相应的数据库功能

不过遗憾的是,本人还没有找到SQLSERVER里面究竟有多少这些管理对象

每个对象的功能,没有详细的文档,网上的资料也很少

 

相关文章:

用c#做了个,sqlServer2005里面那个事件监控器一样的程序,启动问题请帮看看

SQLSERVER数据库管理员的专用连接DAC

SQLSERVER2005的安装目录结构(下)

 

补充一下:

大家在X:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn路径下可以看到SQLSERVER的一些功能组件DLL

一些不是很重要功能组件例如数据库邮件(DatabaseMailengine.DLL)就是使用.NET来编写的

而一些重要功能组件例如批解释器(batchparser90.DLL)就使用非.NET语言编写,所以这些组件你用ILSpy是反编译不出来的

其实大家有空也可以研究一下这些DLL

例如 DBGHELP.DLL这个DLL应该是用来产生DUMP文件内存转储文件的,并且不能反编译

 

有空研究一下SQLSERVER这些用.NET写的代码你会有收获的~

Views:1867   Posted at:2013-12-02
收藏 推荐 打印 | 录入:Admin | 阅读:0