将 res:// 协议与 System.Windows.Forms.WebBrowser 结合使用

发布于 2024-12-11 01:13:59 字数 190 浏览 4 评论 0原文

我正在尝试使用位于 dll 中的资源(html 文件)。使用 WinForms WebBrowser 时,当我导航到该文件时,没有任何反应,而使用包含的 AxSHDocVw.dll 和 SHDocVw.dll 以及 AxWebBrowser 时,它可以工作。 WinForms WebBrowser 控件是否受到某种限制或其他什么?我可以让它运行 res:// 吗?

I'm trying to use a resource (html file) located in a dll. With WinForms WebBrowser, when I navigate to the file, nothing happens, while with included AxSHDocVw.dll and SHDocVw.dll and AxWebBrowser, it works. Is the WinForms WebBrowser control somehow restricted or something? Can I make it to run res://?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风吹短裙飘 2024-12-18 01:13:59

请参阅我的帖子:https://stackoverflow.com/a/15672462/1413201

基本要点是代码文件中有两种类型的资源。您需要包含 C 样式资源脚本才能使用 res 协议。导航错误可能已在 WebBrowser 控件中关闭,因此您不会看到错误。

您可以使用 IE 的 res 协议来测试资源是否确实在文件中,并使用 C 风格的资源编辑器来进行双重检查。

See my post here: https://stackoverflow.com/a/15672462/1413201.

The basic gist is there are two types of resources in code files. You need to include a C style resource script to use the res protocol. Navigation errors are probably turned off in the WebBrowser control and therefore you don't see an error.

You can use the res protocol with IE to test if the resource is actually in the file and a C style resource editor just to double double check.

我不在是我 2024-12-18 01:13:59

我的假设是,出于安全原因,WinForms 的 WebBrowser 控件不处理 res:// 链接。这将使某人很容易访问您可能不希望访问的 DLL 中包含的资源。

如果您想自己实现该功能,那么我建议您查看 Assembly 类及其使用。将 res:/// 解析到 DLL 路径、加载程序集、搜索给定资源并将其返回给 WebBrowser 控件应该不难。

What I would assume, is that for security reasons, WinForms' WebBrowser control doesn't handle res:// links. It would make it very easy for someone to access resources which are contained within your DLLs which you may not want accessed.

If you want to implement the functionality yourself, then I'd recommend looking at the Assembly class and its use. It shouldn't be hard to parse a res:/// into your DLL path, load the assembly, search for the given resource and return that for the WebBrowser control.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文