gpt4 book ai didi

在 64 位机器上运行的 C# dll

转载 作者:太空宇宙 更新时间:2023-11-03 14:21:11 25 4
gpt4 key购买 nike

我创建了一个 C# dll 来使用 Acrobat 打印 PDF。这是从 Microsoft Dynamics NAV 调用的。当它在 32 位机器上运行时,它没有问题。当我们在64位机器上安装时,出现如下错误

无法调用成员 PrintToPrinter。 OLE 控件或自动化服务器返回以下消息:请求的成员不存在,或者调用试图设置只读属性的值。

我该怎么做才能让它在 64 位 Windows 7 机器上运行?我将它设置为目标 x86,我也尝试过为 x86 和 x64 创建安装程序,但我不断收到相同的错误消息。

这是我的代码。

[ComVisible(true), ClassInterface(ClassInterfaceType.AutoDual)]
public class CCB_PDFPrinting
{
public void PrintToPrinter(string FileName, string PrinterName)
{
Process proc = new Process();
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.StartInfo.FileName = @"Acrobat.exe";
proc.StartInfo.Arguments = "/n /t " + FileName + " \"" + PrinterName + "\"";
proc.Start();
proc.WaitForExit(1000);
proc.CloseMainWindow();
proc.Close();
}
}

最佳答案

即使在 64 位 机器上,您也可以将进程设置为作为 32 位 进程运行。

这将强制它使用您的 32 位库。

使用 CorFlags.exe 并设置 /32bit+ 标志(可能作为应用程序的构建后步骤)。

关于在 64 位机器上运行的 C# dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5332166/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com