在本地主机中加载站点时,c#bho中的函数未公开
我使用c#创建了一个示例bho,并根据本文公开了1个函数 bho成功注册到IE9,我可以在网络托管的站点上访问javascript中公开的函数 我使用我的本地服务器创建了一个测试页面,我的bho功能现在还没有定义 我尝试将url从localhost更改为ip地址,但仍然没有效果 下面是我的代码。如果有人能检查我的代码是否有问题,那就太好了 谢谢 银行控股公司在本地主机中加载站点时,c#bho中的函数未公开,c#,bho,C#,Bho,我使用c#创建了一个示例bho,并根据本文公开了1个函数 bho成功注册到IE9,我可以在网络托管的站点上访问javascript中公开的函数 我使用我的本地服务器创建了一个测试页面,我的bho功能现在还没有定义 我尝试将url从localhost更改为ip地址,但仍然没有效果 下面是我的代码。如果有人能检查我的代码是否有问题,那就太好了 谢谢 银行控股公司 IObjectWithSite.cs IExtension.cs 我已经找到了解决问题的方法。。。只需更改onDocument
IObjectWithSite.cs
IExtension.cs
我已经找到了解决问题的方法。。。只需更改onDocumentComplete函数中的某些部分
解决方案
更改以下代码:
致:
public void OnDocumentComplete(object pDisp, ref object URL) {
document = (HTMLDocument)webBrowser.Document;
dynamic window = webBrowser.Document.parentWindow;
IExpando windowEx = (IExpando)window;
PropertyInfo p = windowEx.AddProperty("sEnhancer");
p.SetValue(windowEx, this);
}
解决方案基于此帖子可能是安全配置问题。比较区域“intranet”和区域“local intranet”的设置@mauell谢谢你的提醒。。。我试着比较“互联网”区域和“内联网”区域。。他们有相同的设置。。。我还尝试了启用/禁用EPM。。。但仍然没有效果
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
namespace MySampleBHO
{
[
ComVisible(true),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352")
]
public interface IObjectWithSite
{
[PreserveSig]
int SetSite([MarshalAs(UnmanagedType.IUnknown)]object site);
[PreserveSig]
int GetSite(ref Guid guid, out IntPtr ppvSite);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
namespace MySampleBHO
{
[
ComVisible(true),
InterfaceType(ComInterfaceType.InterfaceIsDual),
Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352")
]
public interface IExtension
{
String goEnhance(String ImageId, int Width, int Height);
}
}
public void OnDocumentComplete(object pDisp, ref object URL) {
document = (HTMLDocument)webBrowser.Document;
dynamic window = webBrowser.Document.parentWindow;
IExpando windowEx = (IExpando)window;
windowEx.AddProperty("sEnhancer");
window.sEnhancer = this;
}
public void OnDocumentComplete(object pDisp, ref object URL) {
document = (HTMLDocument)webBrowser.Document;
dynamic window = webBrowser.Document.parentWindow;
IExpando windowEx = (IExpando)window;
PropertyInfo p = windowEx.AddProperty("sEnhancer");
p.SetValue(windowEx, this);
}