简体   繁体   English

将 System.windows.Forms 引用添加到 asp.net 网站

[英]Adding System.windows.Forms reference into asp.net website

I have a asp.net application where i use System.Windows.Forms namespace reference to use web browser control.the application runs fine on local system but after hosting it shows error.我有一个 asp.net 应用程序,我使用 System.Windows.Forms 命名空间引用来使用 Web 浏览器控件。该应用程序在本地系统上运行良好,但托管后显示错误。 How do i embed the dll for to use in the web application.我如何嵌入 dll 以在 Web 应用程序中使用。

Answering a 3 1/2 year old question is pretty weird...回答一个 3 1/2 岁的问题很奇怪......

I. In your web.config, add a reference to Windows.Forms I. 在你的 web.config 中,添加对 Windows.Forms 的引用

<system.web>
  <compilation>
    <assemblies>
      <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    </assemblies>
  </compilation>
<system.web>

This only works if the referenced DLL is in the GAC.这仅在引用的 DLL 位于 GAC 中时才有效。 If it is not:如果不是:

  1. Create a /Bin folder in your website root.在您的网站根目录中创建一个/Bin文件夹。
  2. Copy your DLL there.在那里复制你的 DLL。
  3. Do not add a reference in web.config.不要添加在web.config中的参考。

II.二、 In your module/class, import Windows.Forms (VB: Imports / C#: using)在您的模块/类中,导入 Windows.Forms (VB: Imports / C#: using)

Imports System.Windows.Forms

You can now use the web browser control.您现在可以使用 Web 浏览器控件。 It's a bit tricky, though.不过,这有点棘手。

Possible uses include: generating screenshots, AJAX crawling (#! >> _escaped_fragment_) etc可能的用途包括:生成截图、AJAX 爬取(#!>> _escaped_fragment_)等

System.Windows.Forms contains classes for displaying things on the computer that the code is running on. System.Windows.Forms包含用于在运行代码的计算机上显示内容的类。 When you are testing on your PC, it works because you run the browser on the same machine as your development server.当您在 PC 上进行测试时,它可以工作,因为您在与开发服务器相同的机器上运行浏览器。

When running on a real server, anything in System.Windows.Forms would be displayed on the server - not on the user's PC.在真实服务器上运行时, System.Windows.Forms任何内容都将显示在服务器上 - 而不是用户的 PC 上。 (Besides it would be displayed on a hidden desktop in the server's service session). (此外,它将显示在服务器服务会话中的隐藏桌面上)。

You shouldn't mix webforms and windows forms.你不应该混合 webforms 和 windows 窗体。 Whatever you want to do - there is another way that works, that doesn't involve winforms.无论你想做什么 - 还有另一种工作方式,不涉及 winforms。

Don't use System.Windows.Forms in webb applications不要在 webb 应用程序中使用System.Windows.Forms

As previously mentioned, you cannot use WinForms controls with ASP.NET.如前所述,您不能将 WinForms 控件与 ASP.NET 一起使用。

Use an iframe to show whatever page you're trying to display in the webbrowser control: http://www.w3schools.com/tags/tag_iframe.asp使用 iframe 显示您尝试在 webbrowser 控件中显示的任何页面: http : //www.w3schools.com/tags/tag_iframe.asp

yes, you can do it,just copy the是的,你可以做到,只需复制

system.window.form系统窗体

dll into your web Bin Folder everything will work fine. dll 到您的 web Bin 文件夹,一切都会正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM