.NET Framework 4 客户端配置文件 +系统.Web.dll?
我目前正在开发 .NET 4 Client Profile 的应用程序,因为该版本将通过 Windows 更新出现在大多数家庭计算机上。
但是,我无法添加对 System.Web.dll
的引用,因为该版本中不存在它 - 我该怎么办?
将 System.Web.dll 与我的应用程序一起部署是一个好主意,还是不起作用?我确实需要 HTTP 连接等,所以我无法修改我的应用程序作为解决方法。将我的应用程序定位到 .NET 4(无客户端配置文件)可能是一种可能性,还是在仅具有客户端配置文件的计算机上不起作用?
I'm currently developing an application for .NET 4 Client Profile, as this is the version that will be present on most home computers through Windows Update.
However, I cannot add a reference to System.Web.dll
as it does not exist in this version - what should I do?
Is it a good idea to deploy System.Web.dll along with my application, or won't that work? I really need HTTP connections and all, so I cannot modify my application as a workaround. Is targeting my application to .NET 4 (no client profile) perhaps a possibility or will that just not work on computers with only the Client Profile?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
事实并非如此。默认情况下,.NET 4(无论是否为客户端配置文件)当前不存在于任何 Windows 10 之前的安装中。例如,Windows 7 附带 .NET 3.5 SP1,而不是 .NET 4.0。可能有 Windows 更新,但它是可选的。
因此,您不妨以完整的 .NET 4 框架为目标。
可以找到操作系统和 .NET Framework 版本之间的链接 这里。复选标记表示该版本是开箱即用的,加号表示可以安装。
另请注意,4.5、4.6 和 4.6.1 都是就地更新,这意味着具有其中任何一个的系统也被视为具有 4.0。
Not really. .NET 4 (client profile or not) currently isn't present on any pre-Windows 10 installation by default. For example, Windows 7 comes with .NET 3.5 SP1, not .NET 4.0. There may be a windows update, but it is optional.
Therefore, you might as well target the full .NET 4 framework.
The link between operating systems and .NET framework versions can be found here. The checkmarks indicate that a version is available out of the box, plus sign means it can be installed.
Also note that 4.5, 4.6 and 4.6.1 are all in-place updates, meaning that a system with any of those is also considered to have 4.0.
如果您的目标是 .NET 4.0 而不是 .NET 4.0 客户端配置文件,则应将其添加为 先决条件。这将允许在您安装应用程序时安装它。
如果您运行 .NET 4.0 Client Profile,您仍然可以使用套接字,它们位于
System.Net
中。当满足以下条件时,您仅需要System.Web
:If you are targeting .NET 4.0 and not .NET 4.0 Client Profile you should add that as a prerequisite. This will allow it to be installed when you install your application.
You can still use Sockets if you run .NET 4.0 Client Profile, they are located in
System.Net
. You only wantSystem.Web
when the following applies:如果您只想使用 HttpWebRequest,它可以在 .Net 4 的客户端配置文件中找到。
这是一个您可以尝试的示例,只需使用 .Net 4 客户端配置文件创建一个新的控制台应用程序并将其粘贴到 Program.cs 中...
您在评论之一中询问了 HttpCookieCollection。 HttpWebRequest 似乎使用 CookieContainer 来存储 cookie。
If you are just wanting to use the HttpWebRequest, it is available in the client profile for .Net 4.
Here's an example that you can try, just create a new console app using the .Net 4 Client Profile and paste this into Program.cs...
You asked about HttpCookieCollection in one of your comments. It seems that HttpWebRequest uses a CookieContainer to store the cookies.
即使您将 System.Web.dll 的副本部署到客户端也无法解决问题。问题是:您无法从为 .NET 4 客户端配置文件编译的程序集链接到为 .NET 4 配置文件(不是客户端)编译的程序集。唯一的解决方案是将您的程序集定位到非客户配置文件。
有关 .NET Framework 客户端配置文件的 MSDN 页面。
Even if you deploy the copy of the
System.Web.dll
to the client that won't solve the problem. And the problem is: you can't link to the assemblies compiled for .NET 4 profile (not client) from the assembly that compiled for .NET 4 Client profile. The only solution is to target your assembly to the not client profile.The MSDN Page about .NET Framework Client Profile.