MDAC OLEDB 命令提示符 32 位问题

发布于 2024-10-06 05:41:40 字数 508 浏览 0 评论 0原文

几年前,我编写了一个 C#.NET 程序,该程序使用 Microsoft ACE 和 JET OLEDB 将 Excel 电子表格转换为 CSV 文件。最近我们升级到了 Windows Server 2008 x64 服务器。由于 JET 已被弃用,该方法不再有效。最初,Excel 2003 中的 .xls 文件是使用 JET 处理的,而 .xlsx Excel 2007 文件是使用 ACE 处理的。我更改了连接字符串以对两者使用 ACE。

我们现在可以通过命令提示符成功运行该程序。然而,当我们使用我们的自动化软件(它显然运行类似于“开始”->“运行”方法的程序)时,我们收到一条错误消息,指出未安装 Microsoft 数据访问组件。经过研究,它们似乎只适用于 32 位系统,并且不支持 Windows Server 2000 以上的任何系统。

有什么想法吗?我们安装了最新的 beta x64 ACE OLEDB 驱动程序。该程序手动运行良好。我还尝试使用 x86 目标平台编译该程序。我们还使用自动化软件使用的 Windows 帐户成功手动运行了程序。

A couple years ago I wrote a C#.NET program that used Microsoft ACE and JET OLEDB to convert Excel spreadsheets to CSV files. Recently we upgraded to a Windows Server 2008 x64 server. Since JET was deprecated that method no longer worked. Originally .xls files from Excel 2003 were handled with JET and .xlsx Excel 2007 files were handled with ACE. I changed the connection strings to use ACE for both.

We can now run the program successfully through a command prompt. However, when we use our automation software (which apparently runs the program similar to the Start->Run method), we get an error saying that the Microsoft Data Access Components are not installed. Upon researching these, it appears they only work on 32-bit systems and don't support anything above Windows Server 2000.

Any ideas? We have the newest beta x64 ACE OLEDB drivers installed. The program runs fine manually. I've also tried compiling the program with a target platform of x86. We also manually ran the program successfully using the windows account that the automation software uses.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最近可好 2024-10-13 05:41:40

在 64 位 Windows 上,进程定义位数:32 或 64。

如果您以 64 位模式启动程序,并且该程序执行 COM(OLEDB 基于 COM),它将仅查找 COM 64 位 DLL (事实上​​,它只是使用注册 64 位 COM 组件的注册表的 64 位端)。

如果您以 32 位模式启动一个程序,并且该程序执行 COM,则它将仅查找 COM 32 位 DLL。

现在,它可能取决于 C# 编译器的版本,但如今,大多数 C# 程序都配置为编译为“任何 Cpu”。这意味着它们将在 32 位操作系统上以 32 位运行,在 64 位操作系统上以 64 位运行,如果它们直接或间接使用 COM,这会使事情变得非常复杂(有时,您甚至不知道自己正在使用 COM!) 。

所以......总结一下:

1)确定进程的位数(使用任务管理器很容易,64位机器上的32位进程带有“*32”后缀)。

2)安装相应的COM OLEDB驱动程序。

如果 OLEDB 驱动程序在 64 位模式下不存在,则您必须重新编译 C# .EXE 或对其进行修补以强制使用 32 位模式。为此,您可以使用 CORFLAGS 工具。

On a 64-bit Windows, the process defines the bitness: 32 or 64.

If you start a program in 64-bit mode, and that program does COM (OLEDB is COM-based), it will look for COM 64 bits DLL only (in fact, it just uses the 64-bit side of the registry whe 64-bit COM components are registered).

If you start a program in 32-bit mode, and that program does COM, it will look for COM 32 bits DLL only.

Now, it can depend on the version of the C# compiler, but today, most C# program are configured to be compiled as "Any Cpu". It means they will run as 32 on a 32-bit OS and 64 on a 64-bit OS, which makes things quite complicated if they use COM directly or indirectly (sometimes, you don't even know you're using COM!).

So... to sum up:

1) determines the bitness of your process (easy with Task Manager, 32-bit processes on a 64-bit machine are suffixed with "*32").

2) install the corresponding COM OLEDB drivers.

If the OLEDB drivers do not exists in 64-bit mode, then you'll have to recompile your C# .EXE or patch it to force 32-bit mode. You can use the CORFLAGS tool for this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文