本文介绍了如何部署SQL Server Compact Edition 4.0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 如何部署 Microsoft SQL Server Compact 4.0 ? SQL Server Compact Edition(目前在4.0版)是:但是如何实际部署? Microsoft表示可以成为 )中,并支持xcopy部署。 Microsoft还表示不能 部署在应用程序文件夹( bad ),并且不支持xcopy部署。 有些人有使用简单的xcopy部署的示例,但是它们不会完成部署所需的详细信息 问题是,除非注册,否则不能使用ADO OLEdb提供程序。注册OLEdb提供程序必须以管理员身份完成。这意味着SQL Server Compact版本将失败,而不是管理员的用户。 SQL Server Compact 4.0附带一个 redist_enu.txt file:但它没有提供有关如何重新分发SQL Server Compact 4.0的任何信息。 随机地围绕未记录的程序文件文件夹,我发现7个DLL: C:\程序文件\ Microsoft SQL Server精简版\v4.0 \ sqlceoledb40.dll sqlceqp40.dll sqlcese40.dll sqlceca40.dll sqlcecompact40.dll sqlceer40EN.dll sqlceme40.dll 注意:还有一些子文件夹具有更多的dll 我尝试将这7个DLL复制到一个文件夹,并尝试打开 ADO连接,使用连接字符串: Provider = Microsoft.SQLSERVER.CE.OLEDB.4.0; Data Source =store.sdf 但它失败了 0x80004005未指定的错误 我试着拂过小部件,但它耸了耸肩。 解决方案我创建了解决方案。 SQL Server Compact Edition由7 dlls: sqlceme40.dll 未记录的本机,平面API库.net System.Data.SqlServerCe.dll 程序集是围绕这个DLL的包装器) sqlceca40。 dll 实现引擎的COM DLL,复制,错误和其他几个COM对象 sqlceoledb40.dll 实现一个OLEdb提供程序用于SSCE的COM DLL (允许使用ADO) sqlcese40.dll 未知 sqlceqp40.dll 未知 sqlcecompact40.dll 未知 sqlceer40en.dll 未知 尝试简单地发送这些DLL的问题是其中两个是 COM 对象。 COM对象dll需要注册,例如: > regsvr32 sqlceca40.dll > regsvr32 sqlceoledb40.dll 问题是注册COM对象需要管理权限(使用全球解决方案来解决本地问题)。这意味着您的用户将 必须安装您的应用程序(您不想要) 要求您的用户具有管理权限(您不希望这样做) 免注册COM 。 首先,您将声明您的应用程序在SQL上具有 依赖 Server Compact Edition 4.0。您可以通过创建汇编清单来执行此操作: < assembly xmlns =urn:schemas-microsoft-com:asm.v1manifestVersion =1.0> < assemblyIdentity version =1.0.0.0 processorArchitecture =X86 name =client type =win32 / > < description> Hyperion Pro< / description> <! - 我们有依赖于SQL Server CE 4.0 - > <依赖关系> < dependentAssembly> < assemblyIdentity type =win32 name =Microsoft.SQLSERVER.CE.4.0 version =4.0.0.0processorArchitecture =x86 /> < / dependentAssembly> < / dependency> <! - 我们是Windows Vista上的高dpi识别 - > < asmv3:application xmlns:asmv3 =urn:schemas-microsoft-com:asm.v3> < asmv3:windowsSettings xmlns =http://schemas.microsoft.com/SMI/2005/WindowsSettings> < dpiAware> true< / dpiAware> < / asmv3:windowsSettings> < / asmv3:application> <! - 我们在Windows 7上设计和测试 - > < compatibility xmlns =urn:schemas-microsoft-com:compatibility.v1> < application> <! - 下面的ID表示Windows 7的应用程序支持 - > < supportedOS Id ={35138b9a-5d96-4fbd-8e2d-a2440225f93a}/> <! - 下面的ID表示Windows Vista的应用程序支持 - > <! - supportedOS Id ={e2011457-1546-43c5-a5fe-008deee3d3f0}/ - > < / application> < / compatibility> <! - 禁用文件和注册表虚拟化 - > < trustInfo xmlns =urn:schemas-microsoft-com:asm.v2> < security> < requestedPrivileges> < requestedExecutionLevel level =asInvokeruiAccess =false/> < / requestedPrivileges> < / security> < / trustInfo> < / assembly> 您可以将这个文件放在您的可执行文件( Hyperion.exe.manifest ),或者您可以将其作为 RT_MANIFEST 资源构建到您的应用程序中。 请注意,我们有一个依赖关系作为程序集名为 Microsoft.SQLSERVER.CE.4.0 。我们先通过创建一个目录来创建此程序集:部署应用程序时,您将将所有构成此程序集的7个DLL放入此 Microsoft.SQLSERVER.CE.4.0 子文件夹,以及一个特殊的 .manifest 文件: C:\ | ---用户 | --- Ian | - -AppData | ---本地 | --- Hyperion Pro | Hyperion.exe | Hyperion.exe.manifest | ---- Microsoft.SQLSERVER.CE.4.0 sqlceme40.dll sqlceca40.dll sqlceoledb40.dll sqlcese40.dll sqlceqp40.dll sqlcecompact40.dll sqlceer40en.dll Microsoft.SQLSERVER.CE.4.0.manifest 换句话说,应用程序文件夹包含您的应用程序,以及 Microsoft.SQLSERVER.CE.4.0 文件夹: 目录C:\Users\Ian\AppData\Local\Hyperion Pro 05/29/2012 09:23 AM 1,899,008 Hyperion.exe 05/28/2012 01:46 PM 1,587 Hyperion.exe.manifest 05/29/2012 09:27 AM< DIR> Microsoft.SQLSERVER.CE.4.0 2文件1,900,675字节 1目录20,851,503,104字节免费 下一部分任务是定义 Microsoft.SQLSERVER.CE.4.0.manifest 文件。免注册COM允许清单文件声明所有的COM对象及其clsid的。这花了很多逆向工程。但SQL Server Compact Edition 4.0的汇编清单是: Microsoft.SQLSERVER.CE.4.0.manifest : <?xml version =1.0encoding =UTF-8standalone =yes?> < assembly xmlns =urn:schemas-microsoft-com:asm.v1manifestVersion =1.0> < assemblyIdentity type =win32 name =Microsoft.SQLSERVER.CE.4.0 processorArchitecture =x86 version = 4.0.0.0/> <! - OLEDB提供者 - > < file name =sqlceoledb40.dll> < comClass description =适用于Windows的Microsoft SQL Server Compact OLE DB提供程序 clsid ={2006C53A-C915-41EA-BAA9-9EAB3A1FBF97} threadingModel = progid =Microsoft.SQLSERVER.CE.OLEDB.4.0/> < / file> <! - 原始平面引擎库 - > < file name =sqlceme40.dll/> <! - 引擎和复制COM对象 - > < file name =sqlceca40.dll> < comClass description =Active SSCE引擎对象 clsid ={68D45319-3702-4837-9F8E-DA6845D82482} threadingModel =Both progid = SSCE.Engine.4.0/> < comClass description =SSCE错误对象 clsid ={36228F21-B5C7-4054-8DC2-47D3E236E8B5} threadingModel =Both progid =SSCE .Error.4.0/> < comClass description =SSCE Param Object clsid ={0B3A7B75-A9B0-4580-9AA5-1A7DA47AD1CB} threadingModel =Both progid =SSCE .Param.4.0/> < comClass description =Active SSCE复制对象 clsid ={11D5B2D4-26A4-44F5-A48B-0FAC3A919ED8} threadingModel =Both progid = SSCE.Replication.4.0/> < comClass description =Active SSCE远程数据访问对象 clsid ={58BC9AD6-BF11-40B3-9AB1-E3F2ED784C08} threadingModel =Both progid =SSCE.RemoteDataAccess.4.0/> < typelib tlbid ={CE4AACFA-3CFD-4028-B2D9-F272314F07C8} version =4.0 helpdir =/> < / file> < comInterfaceExternalProxyStub name =ISSCEEngine iid ={10EC3E45-0870-4D7B-9A2D-F4F81B6B7FA2} proxyStubClsid32 ={00020424-0000 -0000-C000-000000000046} baseInterface ={00000000-0000-0000-C000-000000000046} tlbid ={CE4AACFA-3CFD-4028-B2D9-F272314F07C8}/> < comInterfaceExternalProxyStub name =ISSCEError iid ={31155A3B-871D-407F-9F73-DEBFAC7EFBE3} proxyStubClsid32 ={00020424-0000 -0000-C000-000000000046} baseInterface ={00000000-0000-0000-C000-000000000046} tlbid ={CE4AACFA-3CFD-4028-B2D9-F272314F07C8}/> < comInterfaceExternalProxyStub name =ISSCERDA iid ={4F04F79D-1FF1-4DCD-802B-3D51B9356C14} proxyStubClsid32 ={00020424-0000 -0000-C000-000000000046} baseInterface ={00000000-0000-0000-C000-000000000046} tlbid ={CE4AACFA-3CFD-4028-B2D9-F272314F07C8}/> < comInterfaceExternalProxyStub name =ISSCEParams iid ={A78AFF90-049C-41EC-B1D8-665968AAC4A6} proxyStubClsid32 ={00020424-0000 -0000-C000-000000000046} baseInterface ={00000000-0000-0000-C000-000000000046} tlbid ={CE4AACFA-3CFD-4028-B2D9-F272314F07C8}/> < comInterfaceExternalProxyStub 名称=ISSCEParam iid ={A9876C60-2667-44E5-89DB-E9A46ED392C0} proxyStubClsid32 ={00020424-0000 -0000-C000-000000000046} baseInterface ={00000000-0000-0000-C000-000000000046} tlbid ={CE4AACFA-3CFD-4028-B2D9-F272314F07C8}/> < comInterfaceExternalProxyStub name =ISSCEErrors iid ={C40143CA-E9F9-4FF4-B8B4-CC02C064FC1B} proxyStubClsid32 ={00020424-0000 -0000-C000-000000000046} baseInterface ={00000000-0000-0000-C000-000000000046} tlbid ={CE4AACFA-3CFD-4028-B2D9-F272314F07C8}/> < comInterfaceExternalProxyStub name =ISSCEMerge iid ={C6EB397F-D585-428D-A4F4-454A1842CB47} proxyStubClsid32 ={00020424-0000 -0000-C000-000000000046} baseInterface ={00000000-0000-0000-C000-000000000046} tlbid ={CE4AACFA-3CFD-4028-B2D9-F272314F07C8}/> < file name =sqlceqp40.dll/> < file name =sqlcese40.dll/> < file name =sqlcecompact40.dll/> < file name =sqlceer40EN.dll/> < / assembly> 最后一个理由是,以同样的方式,我们对一个名为 Microsoft.SQLSERVER.CE.4.0 ,SQL Server Compact Edition 4.0依次依赖于一个名为的程序集Microsoft.VC90.CRT 。幸运的是,您安装的SQLCE附带了此程序集的副本: | ---- Microsoft .VC90.CRT | Microsoft.VC90.CRT.manifest | msvcr90.dll 这意味着最终的目录结构是: C:\ | ---用户 | --- Ian | - -AppData | ---本地 | --- Hyperion Pro | Hyperion.exe | Hyperion.exe.manifest | ---- Microsoft.SQLSERVER.CE.4.0 | Microsoft.SQLSERVER.CE.4.0.manifest | sqlceme40.dll | sqlceca40.dll | sqlceoledb40.dll | sqlcese40.dll | sqlceqp40.dll | sqlcecompact40.dll | sqlceer40en.dll | --- Microsoft.VC90.CRT | Microsoft.VC90.CRT.manifest | msvcr90.dll How do i deploy Microsoft SQL Server Compact 4.0?SQL Server Compact Edition (currently at version 4.0) is:But how do you actually deploy it?Microsoft says it can be deployed within the application folder (good) and supports xcopy deployment.Microsoft also says it cannot be deployed within the application folder (bad), and does not support xcopy deployment.some people have examples of it using simple xcopy deployment, but they don't go into the details required to complete the deploymentThe problem is that you cannot use the ADO OLEdb provider unless it is registered. Registering an OLEdb provider has to be done as an administrator. That means that SQL Server Compact edition will fail with users who are not an administrator.SQL Server Compact 4.0 comes with a redist_enu.txt file:but it doesn't give any information about how to redistribute SQL Server Compact 4.0.Randomly spellunking around the undocumented Program Files folder i found 7 dlls:C:\Program Files\Microsoft SQL Server Compact Edition\v4.0\ sqlceoledb40.dll sqlceqp40.dll sqlcese40.dll sqlceca40.dll sqlcecompact40.dll sqlceer40EN.dll sqlceme40.dllNote: There are also some child folders with more dllsi tried copying these 7 dll's to a folder, and tried to open an ADO Connection using the connection string:Provider=Microsoft.SQLSERVER.CE.OLEDB.4.0;Data Source="store.sdf"but it fails with 0x80004005 Unspecified errori tried frobbing the widget, but it grobbed the frobber. 解决方案 i've created the solution.SQL Server Compact Edition is comprised of 7 dlls:sqlceme40.dll The undocumented, native, flat API library (The .net System.Data.SqlServerCe.dll assembly is a wrapper around this dll)sqlceca40.dll A COM dll that implements Engine, Replication, Error and a few other COM objectssqlceoledb40.dll A COM dll that implements an OLEdb provider for SSCE (allowing the use of ADO)sqlcese40.dll unknownsqlceqp40.dll unknownsqlcecompact40.dll unknownsqlceer40en.dll unknownThe problem with trying to simply ship these dlls is that two of them are COM objects. COM object dll's need to be registered, e.g.:>regsvr32 sqlceca40.dll>regsvr32 sqlceoledb40.dllThe problem is that registering a COM object requires administrative privileges (using a global solution to solve a local problem). This means that your users wouldhave to install your application (which you don't want to do)requires your users to have administrative permissions (which you don't want to do)Fortunately, starting in 2001 with Windows XP, Microsoft solved this COMmon problem: Registration-Free COM.First, you will declare that your application has a "dependancy" on SQL Server Compact Edition 4.0. You do this by authoring an assembly manifest:<?xml version="1.0" encoding="UTF-8" standalone="yes"?><assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="client" type="win32" /> <description>Hyperion Pro</description> <!-- We have a dependancy on SQL Server CE 4.0 --> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.SQLSERVER.CE.4.0" version="4.0.0.0" processorArchitecture="x86" /> </dependentAssembly> </dependency> <!-- We are high-dpi aware on Windows Vista --> <asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> <dpiAware>true</dpiAware> </asmv3:windowsSettings> </asmv3:application> <!-- We were designed and tested on Windows 7 --> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> <!--The ID below indicates application support for Windows 7 --> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> <!--The ID below indicates application support for Windows Vista --> <!--supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/--> </application> </compatibility> <!-- Disable file and registry virtualization --> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <security> <requestedPrivileges> <requestedExecutionLevel level="asInvoker" uiAccess="false"/> </requestedPrivileges> </security> </trustInfo></assembly>You can place this file beside your executable (as Hyperion.exe.manifest), or you can build it into your application as an RT_MANIFEST resource.Notice that we have a dependancy against as assembly called Microsoft.SQLSERVER.CE.4.0. We create this assembly first by creating a directory called:When you deploy your application, you will place all 7 dll's that comprise this "assembly" into this Microsoft.SQLSERVER.CE.4.0 subfolder, along with a special .manifest file:C:\|---Users |---Ian |---AppData |---Local |---Hyperion Pro | Hyperion.exe | Hyperion.exe.manifest |----Microsoft.SQLSERVER.CE.4.0 sqlceme40.dll sqlceca40.dll sqlceoledb40.dll sqlcese40.dll sqlceqp40.dll sqlcecompact40.dll sqlceer40en.dll Microsoft.SQLSERVER.CE.4.0.manifestIn other words, the application folder contains your application, and the Microsoft.SQLSERVER.CE.4.0 folder: Directory of C:\Users\Ian\AppData\Local\Hyperion Pro05/29/2012 09:23 AM 1,899,008 Hyperion.exe05/28/2012 01:46 PM 1,587 Hyperion.exe.manifest05/29/2012 09:27 AM <DIR> Microsoft.SQLSERVER.CE.4.0 2 File(s) 1,900,675 bytes 1 Dir(s) 20,851,503,104 bytes freeThe next part of your task is to define the Microsoft.SQLSERVER.CE.4.0.manifest file. Registration-free COM allows a manifest file to declare all the COM objects and their clsid's. This took a lot of reverse engineering. But the assembly manifest for SQL Server Compact Edition 4.0 is:Microsoft.SQLSERVER.CE.4.0.manifest:<?xml version="1.0" encoding="UTF-8" standalone="yes"?><assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"><assemblyIdentity type="win32" name="Microsoft.SQLSERVER.CE.4.0" processorArchitecture="x86" version="4.0.0.0" /><!-- OLEDB Provider --><file name = "sqlceoledb40.dll"> <comClass description = "Microsoft SQL Server Compact OLE DB Provider for Windows" clsid="{2006C53A-C915-41EA-BAA9-9EAB3A1FBF97}" threadingModel = "Both" progid = "Microsoft.SQLSERVER.CE.OLEDB.4.0" /></file><!-- Native flat engine library --><file name="sqlceme40.dll" /><!-- Engine and Replication COM object --><file name="sqlceca40.dll"> <comClass description="Active SSCE Engine Object" clsid="{68D45319-3702-4837-9F8E-DA6845D82482}" threadingModel="Both" progid="SSCE.Engine.4.0" /> <comClass description="SSCE Error Object" clsid="{36228F21-B5C7-4054-8DC2-47D3E236E8B5}" threadingModel="Both" progid="SSCE.Error.4.0" /> <comClass description="SSCE Param Object" clsid="{0B3A7B75-A9B0-4580-9AA5-1A7DA47AD1CB}" threadingModel="Both" progid="SSCE.Param.4.0" /> <comClass description="Active SSCE Replication Object" clsid="{11D5B2D4-26A4-44F5-A48B-0FAC3A919ED8}" threadingModel="Both" progid="SSCE.Replication.4.0" /> <comClass description="Active SSCE remote data access Object" clsid="{58BC9AD6-BF11-40B3-9AB1-E3F2ED784C08}" threadingModel="Both" progid="SSCE.RemoteDataAccess.4.0" /> <typelib tlbid="{CE4AACFA-3CFD-4028-B2D9-F272314F07C8}" version="4.0" helpdir=""/></file><comInterfaceExternalProxyStub name="ISSCEEngine" iid="{10EC3E45-0870-4D7B-9A2D-F4F81B6B7FA2}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid = "{CE4AACFA-3CFD-4028-B2D9-F272314F07C8}" /><comInterfaceExternalProxyStub name="ISSCEError" iid="{31155A3B-871D-407F-9F73-DEBFAC7EFBE3}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid = "{CE4AACFA-3CFD-4028-B2D9-F272314F07C8}" /><comInterfaceExternalProxyStub name="ISSCERDA" iid="{4F04F79D-1FF1-4DCD-802B-3D51B9356C14}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid = "{CE4AACFA-3CFD-4028-B2D9-F272314F07C8}" /><comInterfaceExternalProxyStub name="ISSCEParams" iid="{A78AFF90-049C-41EC-B1D8-665968AAC4A6}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid = "{CE4AACFA-3CFD-4028-B2D9-F272314F07C8}" /><comInterfaceExternalProxyStub name="ISSCEParam" iid="{A9876C60-2667-44E5-89DB-E9A46ED392C0}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid = "{CE4AACFA-3CFD-4028-B2D9-F272314F07C8}" /><comInterfaceExternalProxyStub name="ISSCEErrors" iid="{C40143CA-E9F9-4FF4-B8B4-CC02C064FC1B}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid = "{CE4AACFA-3CFD-4028-B2D9-F272314F07C8}" /><comInterfaceExternalProxyStub name="ISSCEMerge" iid="{C6EB397F-D585-428D-A4F4-454A1842CB47}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid = "{CE4AACFA-3CFD-4028-B2D9-F272314F07C8}" /><file name="sqlceqp40.dll" /><file name="sqlcese40.dll" /><file name="sqlcecompact40.dll" /><file name="sqlceer40EN.dll" /></assembly>The a final gotcha is that, in the same way we have a dependancy on an assembly called Microsoft.SQLSERVER.CE.4.0, SQL Server Compact Edition 4.0 in turn has a dependancy on an assembly called Microsoft.VC90.CRT. Fortunately your install of SQLCE ships with a copy of this assembly:|----Microsoft.VC90.CRT | Microsoft.VC90.CRT.manifest | msvcr90.dllThis means the final directory structure is:C:\|---Users |---Ian |---AppData |---Local |---Hyperion Pro | Hyperion.exe | Hyperion.exe.manifest |----Microsoft.SQLSERVER.CE.4.0 | Microsoft.SQLSERVER.CE.4.0.manifest | sqlceme40.dll | sqlceca40.dll | sqlceoledb40.dll | sqlcese40.dll | sqlceqp40.dll | sqlcecompact40.dll | sqlceer40en.dll |---Microsoft.VC90.CRT | Microsoft.VC90.CRT.manifest | msvcr90.dll 这篇关于如何部署SQL Server Compact Edition 4.0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-01 01:22