You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity 2021.3.5 LTS中能否使用System.Data.OleDb.OleDbConnection()?

解决Unity中System.Data.OleDb PlatformNotSupportedException的问题

问题原因

你使用的是NuGet包中lib/netstandard2.0目录下的System.Data.OleDb.dll,这个文件仅包含跨平台抽象层代码,没有Windows x64平台的原生实现逻辑,导致运行时触发PlatformNotSupportedException。

修复步骤

  • 解压下载的System.Data.OleDb v6.0 NuGet包,找到以下两个文件:
    1. runtimes/win-x64/lib/netstandard2.0/System.Data.OleDb.dll
    2. runtimes/win-x64/native/System.Data.OleDb.Native.dll
  • 在Unity项目的Assets目录下创建Plugins/Windows/x86_64路径(不存在则手动新建),将上述两个文件放入该目录
  • 选中这两个DLL文件,在Unity Inspector面板中配置:
    • Platform:设置为Windows
    • CPU:设置为x86_64
    • 勾选Include in Build,同时取消其他平台的包含选项
  • (可选)将Project Settings > Player > Api Compatibility Level切换为.NET 4.x,该级别对传统.NET库的兼容性更好

额外注意事项

  • 切勿直接使用lib/netstandard2.0下的独立DLL,必须搭配对应平台的原生实现文件
  • 修改配置后建议清理Unity的Library目录并重启编辑器,避免缓存的旧文件导致异常
  • 确保你的Windows系统已安装对应版本的OLE DB驱动(如Access驱动等,根据你的数据源需求)

内容的提问来源于stack exchange,提问作者므..

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 15:45:33