Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# System.Drawing.Printing:RPC服务器不可用_C#_Winapi_Printing_Controls_Rpc - Fatal编程技术网

C# System.Drawing.Printing:RPC服务器不可用

C# System.Drawing.Printing:RPC服务器不可用,c#,winapi,printing,controls,rpc,C#,Winapi,Printing,Controls,Rpc,我正在运行一些非常基本的打印代码:(使用.NET4.0,VS2012,Windows8) 它抛出了一个错误: System.ComponentModel.Win32Exception was unhandled HResult=-2147467259 Message=The RPC server is unavailable Source=System.Drawing ErrorCode=-2147467259 NativeErrorCode=1722 StackTrace:

我正在运行一些非常基本的打印代码:(使用.NET4.0,VS2012,Windows8)

它抛出了一个错误:

System.ComponentModel.Win32Exception was unhandled
HResult=-2147467259
Message=The RPC server is unavailable
  Source=System.Drawing
  ErrorCode=-2147467259
  NativeErrorCode=1722
  StackTrace:
   at System.Drawing.Printing.StandardPrintController.OnStartPrint(PrintDocument document, PrintEventArgs e)
   at System.Windows.Forms.PrintControllerWithStatusDialog.OnStartPrint(PrintDocument document, PrintEventArgs e)
   at System.Drawing.Printing.PrintController.Print(PrintDocument document)
   at System.Drawing.Printing.PrintDocument.Print()
   at FrogJump.Form1.PrintControl(Control control) in e:\Univ\S13\AI\FrogJump\FrogJump\Form1.cs:line 120
   at FrogJump.Form1.btnPrint_Click(Object sender, EventArgs e) in e:\Univ\S13\AI\FrogJump\FrogJump\Form1.cs:line 108
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at FrogJump.Program.Main() in e:\Univ\S13\AI\FrogJump\FrogJump\Program.cs:line 18
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
InnerException: 

这确实是一个很长的机会,但我认为您应该检查您是否正在打印到您认为要打印到的打印机……)


(检查您是否正在打印到正确的打印机,并且打印机已打开)

这确实是一个很难解决的问题-但我认为您应该检查您是否正在打印到您认为要打印到的打印机……)


(检查是否正在打印到正确的打印机,并且打印机已打开)

System.Drawing.printing和Windows printing api都不使用RPC。您需要首先签出打印机驱动程序。System.Drawing.Printing和Windows Printing api都不使用RPC。您需要先查看打印机驱动程序。实际上,您的评论很有帮助!!错误突然消失了!“默认打印机”当时未连接到我的电脑。。。。仍然不知道为什么会发生错误,但现在,至少问题消失了。:)谢谢说实话,这“真的”不是一个很长的机会……)您正在尝试打印,在这种情况下,只有您的打印机驱动程序试图将命令发送到服务器(打印机),这可能不可用。。“Message=RPC服务器不可用”对于我来说,重新启动后台打印程序服务解决了问题+1-这个答案是解决此类问题的良好起点。在我的例子中,我试图从运行在未连接到域的VM上的.NET应用程序进行打印,因此我猜我没有通过试图打印到的服务器的身份验证。使用windows资源管理器访问上述服务器时,提示我输入凭据,一旦缓存,.NET应用程序就可以进行打印。这是一条毫无帮助的错误消息!实际上你的评论很有帮助!!错误突然消失了!“默认打印机”当时未连接到我的电脑。。。。仍然不知道为什么会发生错误,但现在,至少问题消失了。:)谢谢说实话,这“真的”不是一个很长的机会……)您正在尝试打印,在这种情况下,只有您的打印机驱动程序试图将命令发送到服务器(打印机),这可能不可用。。“Message=RPC服务器不可用”对于我来说,重新启动后台打印程序服务解决了问题+1-这个答案是解决此类问题的良好起点。在我的例子中,我试图从运行在未连接到域的VM上的.NET应用程序进行打印,因此我猜我没有通过试图打印到的服务器的身份验证。使用windows资源管理器访问上述服务器时,提示我输入凭据,一旦缓存,.NET应用程序就可以进行打印。这是一条毫无帮助的错误消息!
System.ComponentModel.Win32Exception was unhandled
HResult=-2147467259
Message=The RPC server is unavailable
  Source=System.Drawing
  ErrorCode=-2147467259
  NativeErrorCode=1722
  StackTrace:
   at System.Drawing.Printing.StandardPrintController.OnStartPrint(PrintDocument document, PrintEventArgs e)
   at System.Windows.Forms.PrintControllerWithStatusDialog.OnStartPrint(PrintDocument document, PrintEventArgs e)
   at System.Drawing.Printing.PrintController.Print(PrintDocument document)
   at System.Drawing.Printing.PrintDocument.Print()
   at FrogJump.Form1.PrintControl(Control control) in e:\Univ\S13\AI\FrogJump\FrogJump\Form1.cs:line 120
   at FrogJump.Form1.btnPrint_Click(Object sender, EventArgs e) in e:\Univ\S13\AI\FrogJump\FrogJump\Form1.cs:line 108
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at FrogJump.Program.Main() in e:\Univ\S13\AI\FrogJump\FrogJump\Program.cs:line 18
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
InnerException: