file-type

System.Runtime.Serialization.dll相关资源与工具下载

5星 · 超过95%的资源 | 下载需积分: 14 | 9.73MB | 更新于2025-09-12 | 63 浏览量 | 492 下载量 举报 收藏
download 立即下载
System.Runtime.Serialization.dll 是 .NET Framework 和 .NET Core 运行时中的一个核心动态链接库文件,主要用于实现对象的序列化和反序列化功能。该文件在 Windows 系统和各类 .NET 应用程序中扮演着至关重要的角色,尤其在数据持久化、网络通信、远程调用等场景中发挥着不可替代的作用。 ### 一、System.Runtime.Serialization.dll 的基本概念 System.Runtime.Serialization.dll 是 Microsoft .NET Framework 框架中的一个系统级程序集,位于 .NET 公共语言运行时(CLR)的类库中。它主要提供了用于序列化和反序列化对象的功能,使得程序可以将对象的状态转换为可存储或传输的格式(如 XML、JSON、二进制等),并能够在需要时恢复该对象的状态。 该程序集的核心命名空间是 `System.Runtime.Serialization`,其中包含了一系列用于序列化的类和接口,例如 `DataContractSerializer`、`XmlObjectSerializer`、`DataContractAttribute`、`DataMemberAttribute` 等。这些类和特性广泛应用于 WCF(Windows Communication Foundation)服务、ASP.NET Web API、.NET Remoting 等分布式应用程序中。 ### 二、System.Runtime.Serialization.dll 的功能与作用 1. **对象序列化与反序列化** 序列化是指将一个对象转换为字节流或特定格式(如 XML、JSON)的过程,以便于存储到磁盘或通过网络传输;反序列化则是将字节流还原为对象的过程。System.Runtime.Serialization.dll 提供了多种序列化机制,包括: - **数据协定序列化(Data Contract Serialization)**:基于 `DataContractSerializer`,用于 WCF 服务中的数据交换。 - **XML 序列化**:使用 `XmlSerializer` 将对象序列化为 XML 格式。 - **二进制序列化**:适用于本地存储或高性能场景,通过 `BinaryFormatter` 实现(不过在 .NET Core 中已被弃用)。 2. **支持多种数据格式** 该 DLL 支持将对象序列化为多种格式,包括 XML、JSON、SOAP 和二进制格式。其中,JSON 格式在现代 Web 开发中尤为重要,广泛用于前后端数据交互。 3. **跨平台兼容性** 在 .NET Core 和 .NET 5+ 中,System.Runtime.Serialization.dll 的部分功能被重构并集成到更通用的 System.Text.Json 和 System.Xml 序列化库中,但其核心序列化机制仍然保留,确保了与 .NET Framework 的兼容性和互操作性。 4. **WCF 通信中的关键角色** 在 WCF 服务中,服务契约和数据契约的定义、消息的序列化与反序列化都依赖于该程序集。没有 System.Runtime.Serialization.dll,WCF 服务将无法正常运行。 ### 三、System.Runtime.Serialization.dll 的依赖关系 System.Runtime.Serialization.dll 本身依赖于其他几个核心 .NET 程序集,例如: - **mscorlib.dll**:提供基本的数据类型、异常处理、集合类等基础功能。 - **System.Xml.dll**:支持 XML 格式的序列化与解析。 - **System.Runtime.dll**:提供 .NET 核心运行时的基本类和接口。 - **System.Collections.dll**:支持集合类的序列化操作。 此外,在某些特定的运行时环境中(如 UWP 或 .NET Native),System.Runtime.Serialization.dll 的部分功能可能受限或需要额外的配置才能使用。 ### 四、System.Runtime.Serialization.dll 的版本与兼容性 System.Runtime.Serialization.dll 随着 .NET Framework 的不同版本而有所变化。例如: - 在 .NET Framework 2.0 到 4.8 中,该 DLL 是一个独立的程序集。 - 在 .NET Core 和 .NET 5+ 中,部分功能被整合到共享的运行时库中,但仍保留了兼容性 API。 - 对于 .NET Standard 项目,System.Runtime.Serialization.Primitives 和 System.Xml.XmlSerializer 等 NuGet 包提供了跨平台支持。 因此,在开发过程中,开发者应根据目标平台选择合适的引用方式和版本,以确保程序的兼容性和稳定性。 ### 五、System.Runtime.Serialization.dll 的常见问题与解决方案 1. **缺少或损坏的 DLL 文件** 如果系统中缺少 System.Runtime.Serialization.dll 或该文件损坏,可能导致 .NET 应用程序无法启动,出现“找不到或无法加载类型”的错误。解决方法包括: - 重新安装 .NET Framework 或 .NET Runtime。 - 使用系统文件检查工具(如 sfc /scannow)修复系统文件。 - 从可信来源下载对应版本的 DLL 文件并替换。 2. **版本冲突** 多个应用程序使用不同版本的该 DLL 文件时,可能引发版本冲突。可通过配置应用程序的绑定重定向(bindingRedirect)来解决。 3. **权限问题** 在某些情况下,程序可能因为权限不足而无法加载该 DLL。此时应检查应用程序的运行权限,必要时以管理员身份运行。 ### 六、System.Runtime.Serialization.dll 的应用场景 1. **Web 服务开发** 在 WCF 服务、ASP.NET Web API、WPF 客户端中,System.Runtime.Serialization.dll 用于将对象转换为可传输的格式,便于跨网络通信。 2. **数据持久化** 序列化功能可用于将对象保存到数据库或文件系统中,例如保存用户配置、缓存数据等。 3. **远程过程调用(RPC)** 在 .NET Remoting 或 gRPC 等远程调用场景中,对象的序列化是实现跨进程通信的前提。 4. **日志记录与调试** 序列化可用于将复杂的对象结构以可读格式输出,便于调试和日志分析。 ### 七、压缩包内容分析 根据提供的压缩包子文件名称列表(DLL之家文件上传工具.exe、DLL之家.htm、X86、X64),可以推测该压缩包可能是一个 DLL 文件下载或修复工具包: - **DLL之家文件上传工具.exe**:可能是用于上传缺失的 DLL 文件至服务器的客户端程序。 - **DLL之家.htm**:极有可能是 HTML 格式的说明文档或主页,提供 DLL 文件的下载指引。 - **X86、X64**:这两个文件夹通常用于存放对应 32 位和 64 位系统的 DLL 文件版本,以适配不同架构的 Windows 系统。 这类压缩包通常出现在第三方 DLL 下载网站,用于帮助用户修复缺失的系统 DLL 文件。但需注意,从非官方渠道下载 DLL 文件可能存在安全风险,建议优先使用官方工具或重新安装 .NET Framework 来修复缺失的 DLL。 ### 八、总结 System.Runtime.Serialization.dll 是 .NET 平台上的一个核心程序集,为对象的序列化与反序列化提供了丰富的功能支持。无论是开发本地应用程序、Web 服务还是分布式系统,该 DLL 都发挥着不可替代的作用。开发者应充分理解其工作原理、适用场景及潜在问题,合理使用其功能,并注意版本兼容性与安全性问题。同时,对于普通用户而言,遇到该 DLL 文件缺失时应采取稳妥的方式进行修复,避免引入安全隐患。

相关推荐

filetype

有关调用实时(JIT)调试而不是此对话框的详细信息, 请参见此消息的结尾。 ************** 异常文本 ************** System.Data.SqlClient.SqlException (0x80131904): 用户 'sa' 登录失败。该用户与可信 SQL Server 连接无关联。 在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager) 在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) 在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) 在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) 在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) 在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) 在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) 在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) 在 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) 在 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) 在 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) 在 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) 在 System.Data.SqlClient.SqlConnection.Open() 在 RemoteServiceClient.Form_MyComSettting..ctor() 在 RemoteServiceClient.Form_RTCClient.button_COMSETTING_Click(Object sender, EventArgs e) 在 System.Windows.Forms.Control.OnClick(EventArgs e) 在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.Label.WndProc(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) ClientConnectionId:034ac75c-0fc7-4bd0-baf9-921e50542fa1 Error Number:18452,State:1,Class:14 ************** 已加载的程序集 ************** mscorlib 程序集版本:4.0.0.0 Win32 版本:4.8.9310.0 built by: NET481REL1LAST_C 基本代码:file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll ---------------------------------------- RemoteServiceClient 程序集版本:1.0.0.0 Win32 版本:1.0.0.0 基本代码:file:///C:/Users/%E6%9D%8E%E5%87%AF%E5%8D%8E/Desktop/%E7%BB%B4%E6%8A%A4%E5%AE%A2%E6%88%B7%E7%AB%AF2025.6.3/RemoteServiceClient.exe ---------------------------------------- System.Windows.Forms 程序集版本:4.0.0.0 Win32 版本:4.8.9251.0 built by: NET481REL1LAST_C 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll ---------------------------------------- System 程序集版本:4.0.0.0 Win32 版本:4.8.9310.0 built by: NET481REL1LAST_C 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll ---------------------------------------- System.Drawing 程序集版本:4.0.0.0 Win32 版本:4.8.9037.0 built by: NET481REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll ---------------------------------------- System.Core 程序集版本:4.0.0.0 Win32 版本:4.8.9297.0 built by: NET481REL1LAST_C 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll ---------------------------------------- System.Configuration 程序集版本:4.0.0.0 Win32 版本:4.8.9037.0 built by: NET481REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll ---------------------------------------- System.Xml 程序集版本:4.0.0.0 Win32 版本:4.8.9037.0 built by: NET481REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll ---------------------------------------- Microsoft.GeneratedCode 程序集版本:1.0.0.0 Win32 版本:4.8.9037.0 built by: NET481REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll ---------------------------------------- System.Runtime.Serialization 程序集版本:4.0.0.0 Win32 版本:4.8.9241.0 built by: NET481REL1LAST_C 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Serialization/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll ---------------------------------------- Newtonsoft.Json 程序集版本:13.0.0.0 Win32 版本:13.0.3.27908 基本代码:file:///C:/Users/%E6%9D%8E%E5%87%AF%E5%8D%8E/Desktop/%E7%BB%B4%E6%8A%A4%E5%AE%A2%E6%88%B7%E7%AB%AF2025.6.3/Newtonsoft.Json.DLL ---------------------------------------- System.ServiceModel 程序集版本:4.0.0.0 Win32 版本:4.8.9241.0 built by: NET481REL1LAST_C 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.ServiceModel/v4.0_4.0.0.0__b77a5c561934e089/System.ServiceModel.dll ---------------------------------------- System.Web.Extensions 程序集版本:4.0.0.0 Win32 版本:4.8.9282.0 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Web.Extensions/v4.0_4.0.0.0__31bf3856ad364e35/System.Web.Extensions.dll ---------------------------------------- System.Data 程序集版本:4.0.0.0 Win32 版本:4.8.9214.0 built by: NET481REL1LAST_B 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll ---------------------------------------- System.Web 程序集版本:4.0.0.0 Win32 版本:4.8.9282.0 built by: NET481REL1LAST_C 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Web/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Web.dll ---------------------------------------- Microsoft.SqlServer.Smo 程序集版本:17.100.0.0 Win32 版本:17.100.61.0 基本代码:file:///C:/Users/%E6%9D%8E%E5%87%AF%E5%8D%8E/Desktop/%E7%BB%B4%E6%8A%A4%E5%AE%A2%E6%88%B7%E7%AB%AF2025.6.3/Microsoft.SqlServer.Smo.DLL ---------------------------------------- Microsoft.SqlServer.Management.Sdk.Sfc 程序集版本:17.100.0.0 Win32 版本:17.100.61.0 基本代码:file:///C:/Users/%E6%9D%8E%E5%87%AF%E5%8D%8E/Desktop/%E7%BB%B4%E6%8A%A4%E5%AE%A2%E6%88%B7%E7%AB%AF2025.6.3/Microsoft.SqlServer.Management.Sdk.Sfc.DLL ---------------------------------------- Microsoft.SqlServer.ConnectionInfo 程序集版本:17.100.0.0 Win32 版本:17.100.61.0 基本代码:file:///C:/Users/%E6%9D%8E%E5%87%AF%E5%8D%8E/Desktop/%E7%BB%B4%E6%8A%A4%E5%AE%A2%E6%88%B7%E7%AB%AF2025.6.3/Microsoft.SqlServer.ConnectionInfo.DLL ---------------------------------------- Microsoft.SqlServer.SqlEnum 程序集版本:17.100.0.0 Win32 版本:17.100.61.0 基本代码:file:///C:/Users/%E6%9D%8E%E5%87%AF%E5%8D%8E/Desktop/%E7%BB%B4%E6%8A%A4%E5%AE%A2%E6%88%B7%E7%AB%AF2025.6.3/Microsoft.SqlServer.SqlEnum.DLL ---------------------------------------- Microsoft.Data.SqlClient 程序集版本:5.0.0.0 Win32 版本:5.16.24240.05 基本代码:file:///C:/Users/%E6%9D%8E%E5%87%AF%E5%8D%8E/Desktop/%E7%BB%B4%E6%8A%A4%E5%AE%A2%E6%88%B7%E7%AB%AF2025.6.3/Microsoft.Data.SqlClient.DLL ---------------------------------------- System.Transactions 程序集版本:4.0.0.0 Win32 版本:4.8.9037.0 built by: NET481REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll ---------------------------------------- Microsoft.SqlServer.SqlClrProvider 程序集版本:17.100.0.0 Win32 版本:17.100.61.0 基本代码:file:///C:/Users/%E6%9D%8E%E5%87%AF%E5%8D%8E/Desktop/%E7%BB%B4%E6%8A%A4%E5%AE%A2%E6%88%B7%E7%AB%AF2025.6.3/Microsoft.SqlServer.SqlClrProvider.DLL ---------------------------------------- System.Runtime.InteropServices.RuntimeInformation 程序集版本:4.0.0.0 Win32 版本:4.8.9037.0 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.InteropServices.RuntimeInformation/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Runtime.InteropServices.RuntimeInformation.dll ---------------------------------------- System.Memory 程序集版本:4.0.1.1 Win32 版本:4.6.28619.01 基本代码:file:///C:/Users/%E6%9D%8E%E5%87%AF%E5%8D%8E/Desktop/%E7%BB%B4%E6%8A%A4%E5%AE%A2%E6%88%B7%E7%AB%AF2025.6.3/System.Memory.DLL ---------------------------------------- System.Runtime.CompilerServices.Unsafe 程序集版本:6.0.0.0 Win32 版本:6.0.21.52210 基本代码:file:///C:/Users/%E6%9D%8E%E5%87%AF%E5%8D%8E/Desktop/%E7%BB%B4%E6%8A%A4%E5%AE%A2%E6%88%B7%E7%AB%AF2025.6.3/System.Runtime.CompilerServices.Unsafe.DLL ---------------------------------------- System.Data.resources 程序集版本:4.0.0.0 Win32 版本:4.8.9037.0 built by: NET481REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Data.resources/v4.0_4.0.0.0_zh-Hans_b77a5c561934e089/System.Data.resources.dll ---------------------------------------- System.EnterpriseServices 程序集版本:4.0.0.0 Win32 版本:4.8.9037.0 built by: NET481REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll ---------------------------------------- mscorlib.resources 程序集版本:4.0.0.0 Win32 版本:4.8.9037.0 built by: NET481REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_zh-Hans_b77a5c561934e089/mscorlib.resources.dll ---------------------------------------- System.Windows.Forms.resources 程序集版本:4.0.0.0 Win32 版本:4.8.9037.0 built by: NET481REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_zh-Hans_b77a5c561934e089/System.Windows.Forms.resources.dll ---------------------------------------- ************** JIT 调试 ************** 要启用实时(JIT)调试, 该应用程序或计算机的 .config 文件(machine.config)的 system.windows.forms 节中必须设置 jitDebugging 值。 编译应用程序时还必须启用 调试。 例如: <configuration> <system.windows.forms jitDebugging="true" /> </configuration> 启用 JIT 调试后,任何未经处理的异常 都将被发送到在此计算机上注册的 JIT 调试程序, 而不是由此对话框处理。客户端出现上述问题无法运行如何处理

filetype

那如是這則錯誤訊息呢?  如需叫用 Just-In-Time (JIT) 偵錯的詳細資料, 請參閱本訊息結尾處 (而非這個對話方塊) 的資訊。 ************** 例外狀況文字 ************** System.OutOfMemoryException: 陣列維度超出支援的範圍。 於 System.Collections.Generic.List`1.set_Capacity(Int32 value) 於 System.Collections.Generic.List`1.EnsureCapacity(Int32 min) 於 System.Collections.Generic.List`1.Add(T item) 於 AssetStudioGUI.Studio.BuildAssetData() 於 C:\projects\assetstudio\AssetStudioGUI\Studio.cs: 行 216 於 System.Threading.Tasks.Task`1.InnerInvoke() 於 System.Threading.Tasks.Task.Execute() --- 先前擲回例外狀況之位置中的堆疊追蹤結尾 --- 於 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 於 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 於 AssetStudioGUI.AssetStudioGUIForm.<BuildAssetStructures>d__55.MoveNext() 於 C:\projects\assetstudio\AssetStudioGUI\AssetStudioGUIForm.cs: 行 209 --- 先前擲回例外狀況之位置中的堆疊追蹤結尾 --- 於 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() ************** 已載入的組件 ************** mscorlib 組件版本: 4.0.0.0 Win32 版本: 4.8.4772.0 built by: NET48REL1LAST_C 程式碼庫: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll ---------------------------------------- AssetStudioGUI 組件版本: 0.16.47.0 Win32 版本: 0.16.47 程式碼庫: file:///C:/Users/daniiellyu/Desktop/Work/Downloads/AssetStudio.net472.v0.16.47/AssetStudioGUI.exe ---------------------------------------- System.Windows.Forms 組件版本: 4.0.0.0 Win32 版本: 4.8.4734.0 built by: NET48REL1LAST_C 程式碼庫: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll ---------------------------------------- System 組件版本: 4.0.0.0 Win32 版本: 4.8.4767.0 built by: NET48REL1LAST_C 程式碼庫: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll ---------------------------------------- System.Drawing 組件版本: 4.0.0.0 Win32 版本: 4.8.4390.0 built by: NET48REL1LAST_C 程式碼庫: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll ---------------------------------------- AssetStudioUtility 組件版本: 0.16.47.0 Win32 版本: 0.16.47 程式碼庫: file:///C:/Users/daniiellyu/Desktop/Work/Downloads/AssetStudio.net472.v0.16.47/AssetStudioUtility.DLL ---------------------------------------- OpenTK 組件版本: 3.1.0.0 Win32 版本: 3.1.0 程式碼庫: file:///C:/Users/daniiellyu/Desktop/Work/Downloads/AssetStudio.net472.v0.16.47/OpenTK.DLL ---------------------------------------- AssetStudio 組件版本: 0.16.47.0 Win32 版本: 0.16.47 程式碼庫: file:///C:/Users/daniiellyu/Desktop/Work/Downloads/AssetStudio.net472.v0.16.47/AssetStudio.DLL ---------------------------------------- System.Core 組件版本: 4.0.0.0 Win32 版本: 4.8.4762.0 built by: NET48REL1LAST_B 程式碼庫: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll ---------------------------------------- Mono.Cecil 組件版本: 0.11.3.0 Win32 版本: 0.11.3.0 程式碼庫: file:///C:/Users/daniiellyu/Desktop/Work/Downloads/AssetStudio.net472.v0.16.47/Mono.Cecil.DLL ---------------------------------------- System.Configuration 組件版本: 4.0.0.0 Win32 版本: 4.8.4190.0 built by: NET48REL1LAST_B 程式碼庫: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll ---------------------------------------- System.Xml 組件版本: 4.0.0.0 Win32 版本: 4.8.4084.0 built by: NET48REL1 程式碼庫: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll ---------------------------------------- OpenTK.GLControl 組件版本: 3.1.0.0 Win32 版本: 3.1.0 程式碼庫: file:///C:/Users/daniiellyu/Desktop/Work/Downloads/AssetStudio.net472.v0.16.47/OpenTK.GLControl.DLL ---------------------------------------- mscorlib.resources 組件版本: 4.0.0.0 Win32 版本: 4.8.4084.0 built by: NET48REL1 程式碼庫: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_zh-Hant_b77a5c561934e089/mscorlib.resources.dll ---------------------------------------- AssetStudio.PInvoke 組件版本: 0.16.47.0 Win32 版本: 0.16.47 程式碼庫: file:///C:/Users/daniiellyu/Desktop/Work/Downloads/AssetStudio.net472.v0.16.47/AssetStudio.PInvoke.DLL ---------------------------------------- Accessibility 組件版本: 4.0.0.0 Win32 版本: 4.8.4084.0 built by: NET48REL1 程式碼庫: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll ---------------------------------------- System.Memory 組件版本: 4.0.1.1 Win32 版本: 4.6.28619.01 程式碼庫: file:///C:/Users/daniiellyu/Desktop/Work/Downloads/AssetStudio.net472.v0.16.47/System.Memory.DLL ---------------------------------------- System.Runtime.CompilerServices.Unsafe 組件版本: 4.0.6.0 Win32 版本: 4.700.19.56404 程式碼庫: file:///C:/Users/daniiellyu/Desktop/Work/Downloads/AssetStudio.net472.v0.16.47/System.Runtime.CompilerServices.Unsafe.DLL ---------------------------------------- System.Runtime 組件版本: 4.0.0.0 Win32 版本: 4.8.4084.0 程式碼庫: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Runtime/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Runtime.dll ---------------------------------------- SixLabors.ImageSharp 組件版本: 1.0.0.0 Win32 版本: 1.0.3.0 程式碼庫: file:///C:/Users/daniiellyu/Desktop/Work/Downloads/AssetStudio.net472.v0.16.47/SixLabors.ImageSharp.DLL ---------------------------------------- System.Numerics 組件版本: 4.0.0.0 Win32 版本: 4.8.4084.0 built by: NET48REL1 程式碼庫: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll ---------------------------------------- System.Buffers 組件版本: 4.0.3.0 Win32 版本: 4.6.28619.01 程式碼庫: file:///C:/Users/daniiellyu/Desktop/Work/Downloads/AssetStudio.net472.v0.16.47/System.Buffers.DLL ---------------------------------------- Texture2DDecoderWrapper 組件版本: 0.16.47.0 Win32 版本: 0.16.47 程式碼庫: file:///C:/Users/daniiellyu/Desktop/Work/Downloads/AssetStudio.net472.v0.16.47/Texture2DDecoderWrapper.DLL ---------------------------------------- K4os.Compression.LZ4 組件版本: 1.1.11.0 Win32 版本: 1.1.11 程式碼庫: file:///C:/Users/daniiellyu/Desktop/Work/Downloads/AssetStudio.net472.v0.16.47/K4os.Compression.LZ4.DLL ---------------------------------------- SixLabors.ImageSharp.Drawing 組件版本: 1.0.0.0 Win32 版本: 1.0.0.0 程式碼庫: file:///C:/Users/daniiellyu/Desktop/Work/Downloads/AssetStudio.net472.v0.16.47/SixLabors.ImageSharp.Drawing.DLL ---------------------------------------- System.Windows.Forms.resources 組件版本: 4.0.0.0 Win32 版本: 4.8.4084.0 built by: NET48REL1 程式碼庫: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_zh-Hant_b77a5c561934e089/System.Windows.Forms.resources.dll ---------------------------------------- SixLabors.Fonts 組件版本: 1.0.0.0 Win32 版本: 1.0.0.0 程式碼庫: file:///C:/Users/daniiellyu/Desktop/Work/Downloads/AssetStudio.net472.v0.16.47/SixLabors.Fonts.DLL ---------------------------------------- netstandard 組件版本: 2.0.0.0 Win32 版本: 4.8.4084.0 程式碼庫: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/netstandard/v4.0_2.0.0.0__cc7b13ffcd2ddd51/netstandard.dll ---------------------------------------- System.Numerics.Vectors 組件版本: 4.1.4.0 Win32 版本: 4.6.26515.06 程式碼庫: file:///C:/Users/daniiellyu/Desktop/Work/Downloads/AssetStudio.net472.v0.16.47/System.Numerics.Vectors.DLL ---------------------------------------- Newtonsoft.Json 組件版本: 13.0.0.0 Win32 版本: 13.0.1.25517 程式碼庫: file:///C:/Users/daniiellyu/Desktop/Work/Downloads/AssetStudio.net472.v0.16.47/Newtonsoft.Json.DLL ---------------------------------------- System.Runtime.Serialization 組件版本: 4.0.0.0 Win32 版本: 4.8.4724.0 built by: NET48REL1LAST_C 程式碼庫: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Serialization/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll ---------------------------------------- System.Data 組件版本: 4.0.0.0 Win32 版本: 4.8.4690.0 built by: NET48REL1LAST_B 程式碼庫: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_64/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll ---------------------------------------- ************** JIT 偵錯 ************** 若要啟用 Just-In-Time (JIT) 偵錯功能,則必須在 此應用程式或電腦的 .config 檔案中,設定 system.windows.forms 區段內的 jitDebugging 值。 且該應用程式也必須在啟用偵錯的狀態下進行 編譯。 例如: <configuration> <system.windows.forms jitDebugging="true" /> </configuration> 當 JIT 偵錯功能啟用後,會將所有未處理的例外狀況 傳送給電腦上已註冊的 JIT 偵錯工具進行處 理,而不是使用這個對話方塊來處理。

filetype

有关调用实时(JIT)调试而不是此对话框的详细信息, 请参见此消息的结尾。 ************** 异常文本 ************** System.InvalidOperationException: DragDrop 注册失败。 ---> System.Threading.ThreadStateException: 在可以调用 OLE 之前,必须将当前线程设置为单线程单元(STA)模式。请确保您的 Main 函数带有 STAThreadAttribute 标记。 在 System.Windows.Forms.Control.SetAcceptDrops(Boolean accept) --- 内部异常堆栈跟踪的结尾 --- 在 System.Windows.Forms.Control.SetAcceptDrops(Boolean accept) 在 System.Windows.Forms.Control.OnHandleCreated(EventArgs e) 在 System.Windows.Forms.TreeView.OnHandleCreated(EventArgs e) 在 System.Windows.Forms.Control.WmCreate(Message& m) 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.TreeView.WndProc(Message& m) 在 Cognex.VisionPro.Implementation.Internal.CogTreeViewBase.CogPaintedTreeView.DefaultWndProc(Message& m) 在 Cognex.VisionPro.Implementation.Internal.CogTreeViewBase.TreeView_WndProcRunning(Object sender, Message& msg, Boolean& cancel) 在 Cognex.VisionPro.Implementation.Internal.CogTreeViewBase.CogPaintedTreeView.OnWndProcRunning(Message& msg, Boolean& cancel) 在 Cognex.VisionPro.Implementation.Internal.CogTreeViewBase.CogPaintedTreeView.WndProc(Message& m) 在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) ************** 已加载的程序集 ************** mscorlib 程序集版本:4.0.0.0 Win32 版本:4.8.9195.0 built by: NET481REL1LAST_B 基本代码:file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll ---------------------------------------- Vision-撕胶带 程序集版本:1.0.0.0 Win32 版本:1.0.0.0 基本代码:file:///D:/soft/Debug/Vision-%E6%92%95%E8%83%B6%E5%B8%A6.exe ---------------------------------------- System.Windows.Forms 程序集版本:4.0.0.0 Win32 版本:4.8.9195.0 built by: NET481REL1LAST_B 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll ---------------------------------------- System 程序集版本:4.0.0.0 Win32 版本:4.8.9195.0 built by: NET481REL1LAST_B 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll ---------------------------------------- System.Drawing 程序集版本:4.0.0.0 Win32 版本:4.8.9037.0 built by: NET481REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll ---------------------------------------- System.Configuration 程序集版本:4.0.0.0 Win32 版本:4.8.9037.0 built by: NET481REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll ---------------------------------------- System.Core 程序集版本:4.0.0.0 Win32 版本:4.8.9195.0 built by: NET481REL1LAST_B 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll ---------------------------------------- System.Xml 程序集版本:4.0.0.0 Win32 版本:4.8.9037.0 built by: NET481REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll ---------------------------------------- Cognex.VisionPro.Controls 程序集版本:53.2.0.0 Win32 版本:53.2.0.0 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_64/Cognex.VisionPro.Controls/v4.0_53.2.0.0__ef0f902af9dee505/Cognex.VisionPro.Controls.dll ---------------------------------------- Cognex.VisionPro.Display.Controls 程序集版本:53.2.0.0 Win32 版本:53.2.0.0 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_64/Cognex.VisionPro.Display.Controls/v4.0_53.2.0.0__ef0f902af9dee505/Cognex.VisionPro.Display.Controls.dll ---------------------------------------- Cognex.VisionPro.Core 程序集版本:53.2.0.0 Win32 版本: 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_64/Cognex.VisionPro.Core/v4.0_53.2.0.0__ef0f902af9dee505/Cognex.VisionPro.Core.dll ---------------------------------------- mscorlib.resources 程序集版本:4.0.0.0 Win32 版本:4.8.4084.0 built by: NET48REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_zh-Hans_b77a5c561934e089/mscorlib.resources.dll ---------------------------------------- System.Windows.Forms.resources 程序集版本:4.0.0.0 Win32 版本:4.8.4084.0 built by: NET48REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_zh-Hans_b77a5c561934e089/System.Windows.Forms.resources.dll ---------------------------------------- Cognex.VisionPro 程序集版本:53.2.0.0 Win32 版本:53.2.0.0 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_64/Cognex.VisionPro/v4.0_53.2.0.0__ef0f902af9dee505/Cognex.VisionPro.dll ---------------------------------------- Cognex.VisionPro.Interop.Core 程序集版本:53.2.0.0 Win32 版本: 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Cognex.VisionPro.Interop.Core/v4.0_53.2.0.0__ef0f902af9dee505/Cognex.VisionPro.Interop.Core.dll ---------------------------------------- Cognex.VisionPro.Display.Controls.resources 程序集版本:53.2.0.0 Win32 版本:53.2.0.0 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Cognex.VisionPro.Display.Controls.resources/v4.0_53.2.0.0_zh-Hans_ef0f902af9dee505/Cognex.VisionPro.Display.Controls.resources.dll ---------------------------------------- Cognex.VisionPro.Interop.DisplayCtl 程序集版本:53.2.0.0 Win32 版本:53.2.0.0 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Cognex.VisionPro.Interop.DisplayCtl/v4.0_53.2.0.0__ef0f902af9dee505/Cognex.VisionPro.Interop.DisplayCtl.dll ---------------------------------------- Serilog 程序集版本:2.0.0.0 Win32 版本:2.12.0.0 基本代码:file:///D:/soft/Debug/Serilog.DLL ---------------------------------------- Serilog.Sinks.Console 程序集版本:4.0.1.0 Win32 版本:4.0.1.0 基本代码:file:///D:/soft/Debug/Serilog.Sinks.Console.DLL ---------------------------------------- Serilog.Sinks.File 程序集版本:5.0.0.0 Win32 版本:5.0.0.0 基本代码:file:///D:/soft/Debug/Serilog.Sinks.File.DLL ---------------------------------------- MvCamCtrl.Net 程序集版本:0.0.0.0 Win32 版本:0.0.0.0 基本代码:file:///D:/soft/Debug/MvCamCtrl.Net.DLL ---------------------------------------- Cognex.VisionPro.ToolGroup 程序集版本:53.2.0.0 Win32 版本:53.2.0.0 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_64/Cognex.VisionPro.ToolGroup/v4.0_53.2.0.0__ef0f902af9dee505/Cognex.VisionPro.ToolGroup.dll ---------------------------------------- System.Runtime.Serialization.Formatters.Soap 程序集版本:4.0.0.0 Win32 版本:4.8.9037.0 built by: NET481REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Serialization.Formatters.Soap/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Runtime.Serialization.Formatters.Soap.dll ---------------------------------------- Cognex.VisionPro.PMAlign 程序集版本:53.2.0.0 Win32 版本: 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_64/Cognex.VisionPro.PMAlign/v4.0_53.2.0.0__ef0f902af9dee505/Cognex.VisionPro.PMAlign.dll ---------------------------------------- Cognex.VisionPro.CalibFix 程序集版本:53.2.0.0 Win32 版本: 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_64/Cognex.VisionPro.CalibFix/v4.0_53.2.0.0__ef0f902af9dee505/Cognex.VisionPro.CalibFix.dll ---------------------------------------- Cognex.VisionPro.Blob 程序集版本:53.2.0.0 Win32 版本: 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_64/Cognex.VisionPro.Blob/v4.0_53.2.0.0__ef0f902af9dee505/Cognex.VisionPro.Blob.dll ---------------------------------------- Cognex.VisionPro.QuickBuild.Core 程序集版本:53.2.0.0 Win32 版本:53.2.0.0 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_64/Cognex.VisionPro.QuickBuild.Core/v4.0_53.2.0.0__ef0f902af9dee505/Cognex.VisionPro.QuickBuild.Core.dll ---------------------------------------- cowsi2ha 程序集版本:0.0.0.0 Win32 版本:4.8.9195.0 built by: NET481REL1LAST_B 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll ---------------------------------------- System.resources 程序集版本:4.0.0.0 Win32 版本:4.8.4084.0 built by: NET48REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.resources/v4.0_4.0.0.0_zh-Hans_b77a5c561934e089/System.resources.dll ---------------------------------------- Accessibility 程序集版本:4.0.0.0 Win32 版本:4.8.9037.0 built by: NET481REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll ---------------------------------------- Cognex.VisionPro.resources 程序集版本:53.2.0.0 Win32 版本:53.2.0.0 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Cognex.VisionPro.resources/v4.0_53.2.0.0_zh-Hans_ef0f902af9dee505/Cognex.VisionPro.resources.dll ---------------------------------------- Cognex.VisionPro.CorePlus 程序集版本:53.2.0.0 Win32 版本: 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_64/Cognex.VisionPro.CorePlus/v4.0_53.2.0.0__ef0f902af9dee505/Cognex.VisionPro.CorePlus.dll ---------------------------------------- Cognex.VisionPro.ImageFile 程序集版本:53.2.0.0 Win32 版本: 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_64/Cognex.VisionPro.ImageFile/v4.0_53.2.0.0__ef0f902af9dee505/Cognex.VisionPro.ImageFile.dll ---------------------------------------- Cognex.VisionPro.ToolGroup.Controls 程序集版本:53.2.0.0 Win32 版本:53.2.0.0 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_64/Cognex.VisionPro.ToolGroup.Controls/v4.0_53.2.0.0__ef0f902af9dee505/Cognex.VisionPro.ToolGroup.Controls.dll ---------------------------------------- Cognex.VisionPro.Controls.resources 程序集版本:53.2.0.0 Win32 版本:53.2.0.0 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Cognex.VisionPro.Controls.resources/v4.0_53.2.0.0_zh-Hans_ef0f902af9dee505/Cognex.VisionPro.Controls.resources.dll ---------------------------------------- Cognex.VisionPro.ToolGroup.Controls.resources 程序集版本:53.2.0.0 Win32 版本:53.2.0.0 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Cognex.VisionPro.ToolGroup.Controls.resources/v4.0_53.2.0.0_zh-Hans_ef0f902af9dee505/Cognex.VisionPro.ToolGroup.Controls.resources.dll ---------------------------------------- Microsoft.GeneratedCode 程序集版本:1.0.0.0 Win32 版本:4.8.9037.0 built by: NET481REL1 基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll ---------------------------------------- ************** JIT 调试 ************** 要启用实时(JIT)调试, 该应用程序或计算机的 .config 文件(machine.config)的 system.windows.forms 节中必须设置 jitDebugging 值。 编译应用程序时还必须启用 调试。 例如: <configuration> <system.windows.forms jitDebugging="true" /> </configuration> 启用 JIT 调试后,任何未经处理的异常 都将被发送到在此计算机上注册的 JIT 调试程序, 而不是由此对话框处理。

filetype
filetype

using MySql.Data.MySqlClient; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace DataSyncManager { public partial class SyncDataForm : Form { //数据库连接配置 private static string sourceDb = "server=157.116.13.18;user=root;password=kill;database=dc"; //源数据库 private static string targetDb = "server=157.116.13.67;user=root;password=Mysql@3237;database=dw_ods"; //目标数据库 //需压同步的表 private static string tableName = "comment"; private static string table2 = "dafu"; public SyncDataForm() { InitializeComponent(); } private void DynsBtn_Click(object sender, EventArgs e) { try { SyncTable(sourceDb, targetDb, tableName); Console.WriteLine($"表 {tableName} 同步成功"); } catch (Exception ex) { Console.WriteLine($"同步失败: {ex.Message}"); } } public static void SyncTable(string sourceConnStr, string targetConnStr, string tableName) { // 获取源表结构 string createTableSql = GetTableSchema(sourceConnStr, tableName); using (var targetConn = new MySqlConnection(targetConnStr)) { targetConn.Open(); // 检查目标表是否存在 if (!TableExists(targetConn, tableName)) { // 创建目标表 using (var cmd = new MySqlCommand(createTableSql, targetConn)) { cmd.ExecuteNonQuery(); } } else { // 检查表结构一致性 if (!ValidateTableSchema(targetConn, tableName, createTableSql)) { throw new Exception("目标表结构不一致,需要手动处理"); } } // 同步数据 SyncData(sourceConnStr, targetConnStr, tableName); } } //检查表是否存在 private static bool TableExists(MySqlConnection conn, string tableName) { string sql = $"SELECT COUNT(*) FROM information_schema.tables " + $"WHERE table_schema = DATABASE() AND table_name = '{tableName}'"; using (var cmd = new MySqlCommand(sql, conn)) { return Convert.ToInt32(cmd.ExecuteScalar()) > 0; } } //获取表结构 private static string GetTableSchema(string connStr, string tableName) { //using (var conn = new MySqlConnection(connStr)) //{ // conn.Open(); // string sql = $"SHOW CREATE TABLE {tableName}"; // using (var cmd = new MySqlCommand(sql, conn)) // using (var reader = cmd.ExecuteReader()) // { // if (reader.Read()) // { // return reader.GetString(1); // } // } //} var mysql4 = new MySql4Connector(); dynamic conn4 = mysql4.CreateConnection(connStr); conn4.Open(); string sql = $"SHOW CREATE TABLE {tableName}"; using (var cmd = new MySqlCommand(sql, conn4)) using (var reader = cmd.ExecuteReader()) { if (reader.Read()) { return reader.GetString(1); } } throw new Exception("获取表结构失败"); } // private static bool ValidateTableSchema(MySqlConnection conn, string tableName, string sourceSchema) { string targetSchema = GetTableSchema(conn.ConnectionString, tableName); return StandardizeSql(sourceSchema) == StandardizeSql(targetSchema); } private static string StandardizeSql(string sql) { // 移除MySQL自动生成的额外信息 return sql.Split(new[] { "/*!" }, StringSplitOptions.None)[0] .Replace("\n", "") .Replace(" ", "") .Replace("`", "") .ToLower(); } //同步数据 private static void SyncData(string sourceConnStr, string targetConnStr, string tableName) { // 获取表结构以确定列名 var columns = GetTableColumns(sourceConnStr, tableName); string columnsList = string.Join(", ", columns); string paramList = string.Join(", ", columns.Select(c => $"@{c}")); string updateSet = string.Join(", ", columns.Select(c => $"{c} = @{c}")); using (var sourceConn = new MySqlConnection(sourceConnStr)) using (var targetConn = new MySqlConnection(targetConnStr)) { sourceConn.Open(); targetConn.Open(); // 批量读取源数据 string selectSql = $"SELECT {columnsList} FROM {tableName}"; using (var sourceCmd = new MySqlCommand(selectSql, sourceConn)) using (var reader = sourceCmd.ExecuteReader()) { while (reader.Read()) { // 使用REPLACE INTO实现插入/更新 string mergeSql = $"REPLACE INTO {tableName} ({columnsList}) VALUES ({paramList})"; using (var targetCmd = new MySqlCommand(mergeSql, targetConn)) { foreach (var column in columns) { targetCmd.Parameters.AddWithValue($"@{column}", reader[column]); } targetCmd.ExecuteNonQuery(); } } } } } //获取列名 private static List<string> GetTableColumns(string connStr, string tableName) { var columns = new List<string>(); using (var conn = new MySqlConnection(connStr)) { conn.Open(); string sql = $"SELECT COLUMN_NAME FROM information_schema.columns " + $"WHERE table_schema = DATABASE() AND table_name = '{tableName}'"; using (var cmd = new MySqlCommand(sql, conn)) using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { columns.Add(reader.GetString(0)); } } } return columns; } public class MySql4Connector { private static readonly Assembly _oldAssembly = Assembly.LoadFrom(@"Lib\V4\MySql.Data.dll"); public dynamic CreateConnection(string connStr) { Type connType = _oldAssembly.GetType("MySql.Data.MySqlClient.MySqlConnection"); dynamic conn = Activator.CreateInstance(connType); conn.ConnectionString = connStr + ";old syntax=true;Protocol=Socket;SslMode=None"; return conn; } } } }

wenHJJ
  • 粉丝: 0
上传资源 快速赚钱