请求的Windows运行时类型'PrintService.PDFPrinting'未注册

本文关键字:PDFPrinting 注册 PrintService 类型 请求 Windows 运行时 | 更新日期: 2023-09-27 18:04:51

我正在尝试为UWP应用程序开发一个代理的WinRT静默PDF打印服务。

我已经遵循了如何创建代理WinRT组件的所有步骤。但是当我在UWP应用程序上调用该服务时,我得到以下错误:

请求的Windows运行时类型为"PrintService"。PDFPrinting则不然注册。

代理组件类:

public sealed class PDFPrinting
{
    public Boolean PrintPDFs(string pdfFileName)
    {
        try
        {
            Process proc = new Process();
            proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            proc.StartInfo.Verb = "print";
            //Define location of adobe reader/command line
            //switches to launch adobe in "print" mode
            proc.StartInfo.FileName =
              @"C:'Program Files (x86)'Adobe'Acrobat Reader DC'Reader'AcroRd32.exe";
            proc.StartInfo.Arguments = String.Format(@"/p /h {0}", pdfFileName);
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.CreateNoWindow = true;
            proc.Start();
            proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            if (proc.HasExited == false)
            {
                proc.WaitForExit(10000);
            }
            proc.EnableRaisingEvents = true;
            proc.Close();
            return true;
        }
        catch
        {
            return false;
        }
    }
}

我怎么称呼它:

var path = @"C:'Users'...'mydocument.pdf";
var service = new PrintService.PDFPrinting();
service.PrintPDFs(path);
我extenssion

:

<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
  <Path>clrhost.dll</Path>
  <ActivatableClass ActivatableClassId="PrintService.PDFPrinting" ThreadingModel="MTA">
    <ActivatableClassAttribute Name="DesktopApplicationPath" Type="string" Value="C:'Development'MyApp" />
  </ActivatableClass>
</InProcessServer>
</Extension>

请求的Windows运行时类型'PrintService.PDFPrinting'未注册

我找到了解决方案,我的值路径在UWP包。Appxmanifest扩展名错误

我引用

:

<ActivatableClassAttribute Name="DesktopApplicationPath" Type="string" Value="C:'Development'MyApp" />

代替:

<ActivatableClassAttribute Name="DesktopApplicationPath" Type="string" Value="C:'Development'MyApp'MyApp'Debug" />

这是所有相关的支持文件和代理/存根dll所在的位置。详情请点击