最近做一个winform项目,在里面用了webbrowser控件进行html文档打印,遇到了标题所示问题。根据查到的一些资料,在调试》异常》查找中输入“System.Runtime.InteropServices.COMException”,勾选查找到的项目后的复选框。重新调试程序,终于爆出了真正的问题:试图吊销一个未注册的拖放目标 (异常来自 HRESULT:0x80040100 (DRAGDROP_E_NOTREGISTERED))。

查看原来的代码:

 browser.DocumentText = text;
browser.Print();

该段代码做如下修改后问题解决:

 browser.DocumentText = "";    // 不加这一句,Document对象可能为null,导致下一句代码出错
browser.Document.Write(text);
browser.Print();

“System.Runtime.InteropServices.COMException”类型的第一次机会异常在 System.Windows.Forms.dll 中发生的更多相关文章

  1. “System.Runtime.InteropServices.COMException”类型的第一次机会异常在 ESRI.ArcGIS.Version.dll 中发生

    “System.Runtime.InteropServices.COMException”类型的第一次机会异常在 ESRI.ArcGIS.Version.dll 中发生 其他信息: The speci ...

  2. System.AccessViolationException”类型的第一次机会异常在 System.Data.dll 中发生 其他信息: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。

    管理员cmd中运行  netsh winsock reset

  3. System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800AC472

    更新至服务器后运行出错: System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800AC472 解决方法 注册 ...

  4. System.Runtime.InteropServices.COMException (0x800706BA) 解决方法

    提示“操作失败:无法获取MAC地址.”错误的解决方法. .NET 获取 MAC地址可能会遇到   System.Runtime.InteropServices.COMException (0x8007 ...

  5. Visual Studio 2008 – ASP.NET “System.Runtime.InteropServices.COMException”

    The Issue When openning an existing ASP.NET project for the first time in Visual Studio 2008 it retu ...

  6. VS2008,System.Runtime.InteropServices.COMException (0x800401F3): Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))

    在VS2008环境中编译调试运行不报错,但在发布的exe文件运行就报错 System.Runtime.InteropServices.COMException (0x800401F3): Invali ...

  7. System.Runtime.InteropServices.COMException (0x800A03EC): 无法访问文件

    使用Microsoft.Office.Interop.Excel 操作 今天在服务器部署,操作程序csv文件转xsl文件的时候,遇到一下问题: System.Runtime.InteropServic ...

  8. System.Runtime.InteropServices.COMException 检索COM类工厂中CLSID{xxxxxxxxx}的组件时失败解决方法

    iis7.5中设定应用程序池中<进程模型>中<标识>为localSystem 提示:System.Runtime.InteropServices.COMException: 命 ...

  9. excel System.Runtime.InteropServices.COMException (0x80010105): 服务器出现意外情况。 (异常来自 HRESULT:0x80010105 (RPC_E

    System.Runtime.InteropServices.COMException (0x80010105): 服务器出现意外情况. (异常来自 HRESULT:0x80010105 (RPC_E ...

随机推荐

  1. 给出一个十六进制的数0xFF 0x80 (只有2“位”) 将其转换成有符号的一字节的十进制整数

    #include <stdio.h>#include<iostream>#include <stdlib.h>#include<string.h>usi ...

  2. springmvc将处理后的数据通过get方法传给页面时,可能会出现乱码。下面对于get请求中文参数出现乱码提出解决办法。

    对于get请求中文参数出现乱码解决办法有两个: 1.修改tomcat配置文件(tomcat--->conf--->server.xml)添加编码与工程编码一致,如下: <Connec ...

  3. 教你用PS修复老照片

    原图素材虽然很旧,不过人物部分并没有怎么损坏,只是有一些色块和杂色.修复的工程相对来说也少很多.只需要给人物磨好皮,然后把暗调和高光部分调出来即可.原图     一.打开原图素材,按Ctrl + J ...

  4. [Groovy] List和Map用法搜集

    http://chenfeng0104.iteye.com/blog/609075 http://www.cnblogs.com/muzi1994/p/5169928.html https://zhi ...

  5. Task构造

    //原文:http://www.tuicool.com/articles/IveiQbQ 创建并且初始化Task 使用lambda表达式创建Task Task.Factory.StartNew(() ...

  6. 设计模式之java源码-工厂方法模式

    工厂方法模式 8.1 女娲造人的故事 东汉<风俗通>记录了一则神话故事:“开天辟辟,未有人民,女娲搏,黄土作人……”,讲述的内容就是大家非常熟悉的女娲造人的故事.开天辟地之初,大地上并没有 ...

  7. javascript的一些札记

    1. 原来放在不同js文件里面的$(document).ready(function(){})都会执行到. 2. $(window).scroll(function(){})  窗口滚动事件. 3.  ...

  8. Python 的stat 模块

    #!/usr/bin/env python#-*- encoding:UTF-8 -*- import os,time,stat fileStats = os.stat ( 'test.txt' )  ...

  9. Field '***********' doesn't have a default value

    今天做配置文件一直报这个错误: 原因是主键是integer类型,没有设置自增模式,所以会出现这个问题,是表的结构问题.更改用navicat

  10. DIV+CSS 中的 overflow:hidden

    overflow:hidden这个CSS样式是大家常用到的CSS样式,但是大多数人对这个样式的理解仅仅局限于隐藏溢出,而对于清除浮动这个含义不是很了解. 一提到清除浮动,我们就会想到另外一个CSS样式 ...