开发者

C# dll running on 64-bit machine

开发者 https://www.devze.com 2023-02-18 10:08 出处:网络
I have created a C# dll to print PDFs with Acrobat.This is called from Microsoft Dynamics NAV.Wh开发者_JAVA百科en this is run on a 32-bit machine, it works with no problems.When we install it on a 64-

I have created a C# dll to print PDFs with Acrobat. This is called from Microsoft Dynamics NAV. Wh开发者_JAVA百科en this is run on a 32-bit machine, it works with no problems. When we install it on a 64-bit machine, we get the following error

Could not invoike the member PrintToPrinter. The OLE control or Automation server returned the following message: The requested memeber does not exist, or the call tried to set the value of a read-only property.

What can I do to get this to run on the 64-bit Windows 7 machine? I set it to target x86, I have also tried created installers for x86 and x64 but I keep getting the same error message.

Here is my code.

[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();
    }
}


You can set the process to run as a 32 bit process even on a 64 bit machine.

This will force it to use your 32 bit libraries.

Use CorFlags.exe and set /32bit+ flag (perhaps as a post-build step of your application).

0

精彩评论

暂无评论...
验证码 换一张
取 消