跳到主要内容

Use System Printing

想要在asp.net core站点中使用PrintServer,发现怎么也无法引用

如下代码

尝试nuget,也没有相应的库

解决办法双击项目,进入项目文件编辑

加入如下引用即可

另外,会提示最好加入window标识,即

参考:

https://stackoverflow.com/questions/60398101/getting-the-access-to-the-system-printing-namespace-in-net-core-console-applica

System.Printing.PrintQueue printQueue = null;
PrintServer server = new PrintServer(printerName);
<ItemGroup>
<FrameworkReference Include="Microsoft.WindowsDesktop.App.WPF" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>

</PropertyGroup>
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>

</PropertyGroup>