Microsoft.mshtml.dll

shdxiang 2010-02-25 12:53:37
我引用的DLL是C:\Program Files\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll的,装了vs2005才有的。但是另一台机子我只装了.net frame 2.0,他没有这个DLL。
我把Microsoft.mshtml.dll拷贝到exe程序的同一目录下面,还是有问题。
涉及到的代码如下:


private void ListenIE()
{
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();
mshtml.IHTMLDocument2 htmlDoc;

String filename = null;
String str = null;

try
{
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
if (filename.Equals("iexplore"))
{
//Console.WriteLine(ie.LocationURL);
htmlDoc = ie.Document as mshtml.IHTMLDocument2;
//System.Threading.Thread.Sleep(3000);
IntPtr activeHwnd = GetForegroundWindow();
//Console.WriteLine("activeHwnd====" + activeHwnd);
WriteLog("--------------");
if (htmlDoc != null)
{
if (ie.HWND == activeHwnd.ToInt32())
{
ie.Refresh();
}
try
{
str = htmlDoc.body.innerHTML;

//Console.WriteLine("=========>" + str);
if(str.Contains("HTTP 错误 404 - 文件或目录未找到"))
{
timeIE.Enabled = false;
timeIE.Stop();
System.Threading.Thread.Sleep(3000);
CloseIE();
WriteLog("HTTP 错误 404");
//CloseWindow(activeHwnd);
//errorInforToUrl();

}
if (str.Contains("HTTP Status 500 "))
{
timeIE.Enabled = false;
timeIE.Stop();
System.Threading.Thread.Sleep(3000);
CloseIE();
WriteLog("HTTP Status 500");
//CloseWindow(activeHwnd);
//errorInforToUrl();

}
if (str.Contains("找不到服务器或 DNS 错误"))
{

System.Threading.Thread.Sleep(3000);
CloseIE();
//CloseWindow(activeHwnd);
timeIE.Enabled = false;
timeIE.Stop();
WriteLog("找不到服务器或 DNS 错误");
//errorInforToUrl();

}
if (str == null) //白屏
{
timeIE.Enabled = false;
timeIE.Stop();
System.Threading.Thread.Sleep(3000);
CloseIE();
WriteLog("str == null");
//errorInforToUrl();

}
}
catch(Exception e) //白屏异常
{
//Console.WriteLine("e=============" + e.ToString());
WriteLog("异常=" + e.ToString());
timeIE.Enabled = false;
timeIE.Stop();
System.Threading.Thread.Sleep(5000);
CloseIE();
WriteLog("白屏异常");
//CloseWindow(activeHwnd);
//sendErrorInfor("termid=" + termid + "&errmsg=" + e.ToString());
//errorInforToUrl();
}
}
}
}
}
catch(Exception e)
{
WriteLog("异常="+e.ToString());
}
}

...全文
1093 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
shdxiang 2010-02-27
  • 打赏
  • 举报
回复
注册成功了 谢谢 大家
但又遇到新问题了 重开个贴 欢迎大家捧场啦
xingyuebuyu 2010-02-25
  • 打赏
  • 举报
回复
C:\Windows\Microsoft.NET\Framework\v2.0.50727\regasm "C:\Program Files\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll" /regfile:myref.reg

要加全路径的
shdxiang 2010-02-25
  • 打赏
  • 举报
回复
regasm "C:\Program Files\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll" /regfile:myref.reg

那我怎么注册不了啊?
xingyuebuyu 2010-02-25
  • 打赏
  • 举报
回复
C:\Windows\Microsoft.NET\Framework\v2.0.50727
目录下就有啊,你全盘搜索下就好了.
shdxiang 2010-02-25
  • 打赏
  • 举报
回复
是指哪个SDK?谢谢了啊 搞好久了 没有搞定 唉~~~~~~~~~~~~~~~
xingyuebuyu 2010-02-25
  • 打赏
  • 举报
回复
regasm.exe 是要装SDK后才会有的一个工具,如果没有就从网上下个下来吧
shdxiang 2010-02-25
  • 打赏
  • 举报
回复
引用 12 楼 xingyuebuyu 的回复:
regasm "C:\Program Files\Microsoft.NET\Primary Interop Assemblies\M
icrosoft.mshtml.dll" /regfile:myref.reg

先这样生成一个注册表,然后到其它电脑再导入注册表。


我在运行里输入,提示错误 “windows 找不到 regasm”
wuyq11 2010-02-25
  • 打赏
  • 举报
回复
wuyq11 2010-02-25
  • 打赏
  • 举报
回复
tlbimp mshtml.tlb /out:mshtml.dll
将项目中引用的 Microsoft.mshtmal.dll 替换为 mshtml.dll
再打包时这个 dll 就可以被添加到安装项目中
yyz985 2010-02-25
  • 打赏
  • 举报
回复
选择引用,打开属性,复制到输出目录
xingyuebuyu 2010-02-25
  • 打赏
  • 举报
回复
regasm "C:\Program Files\Microsoft.NET\Primary Interop Assemblies\M
icrosoft.mshtml.dll" /regfile:myref.reg

先这样生成一个注册表,然后到其它电脑再导入注册表。
shdxiang 2010-02-25
  • 打赏
  • 举报
回复
引用 8 楼 lzsh0622 的回复:
文件在:
C:\Program Files\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll
引用MSHTML时选用primary Interop Assembly中文件

安装包中,设置自动注册.

引用MSHTML时选用primary Interop Assembly中文件?不明白啊
安装包中,设置自动注册?在哪设置啊
shdxiang 2010-02-25
  • 打赏
  • 举报
回复
Regasm Microsoft.mshtml.dll

要安装Regasm.exe程序吧 我试了下不行啊
xingyuebuyu 2010-02-25
  • 打赏
  • 举报
回复
Regasm Microsoft.mshtml.dll
lzsh0622 2010-02-25
  • 打赏
  • 举报
回复
文件在:
C:\Program Files\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll
引用MSHTML时选用primary Interop Assembly中文件

安装包中,设置自动注册.
shdxiang 2010-02-25
  • 打赏
  • 举报
回复
引用 5 楼 xingyuebuyu 的回复:
http://blog.csdn.net/zb219/archive/2008/05/23/2474435.aspx

拷贝到其它电脑,要注册Microsoft.mshtml.dll


REGsvr Microsoft.mshtml.dll

就好了吗?
shdxiang 2010-02-25
  • 打赏
  • 举报
回复
我打包是这样的啊 还是不行啊
xingyuebuyu 2010-02-25
  • 打赏
  • 举报
回复
http://blog.csdn.net/zb219/archive/2008/05/23/2474435.aspx

拷贝到其它电脑,要注册Microsoft.mshtml.dll
Justin-Liu 2010-02-25
  • 打赏
  • 举报
回复
拷贝它就行了 打包打一起 你工程输出目录的该文件
lfzucc 2010-02-25
  • 打赏
  • 举报
回复
要先添加引用,要先添加引用。
加载更多回复(2)

110,549

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧