.NET Framework 4 Client Profile + System.Web.dll?
Asked Answered
L

4

9

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?

Lightyear answered 12/2, 2011 at 23:6 Comment(1)
Do not deploy System.Web.dll as a standalone file with your project. Require the user to install the full .NET Framework. Include this in your installer and no one will care.Experientialism
S
7

NET 4 Client Profile, as this is the version that will be present on most home computers through Windows Update

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.

Secundas answered 12/2, 2011 at 23:18 Comment(1)
You see it under "Optional updates". And that is afaik 4.0 client profile.Catima
C
3

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 want System.Web when the following applies:

The System.Web namespace supplies classes and interfaces that enable browser-server communication. This namespace includes the HttpRequest class, which provides extensive information about the current HTTP request; the HttpResponse class, which manages HTTP output to the client; and the HttpServerUtility class, which provides access to server-side utilities and processes. System.Web also includes classes for cookie manipulation, file transfer, exception information, and output cache control.

Catima answered 12/2, 2011 at 23:8 Comment(2)
I get an error stating that the type HttpCookieCollection cannot be found - even after adding System.Net.dll. Anyway, is it a possibility to deploy System.Web.dll along ith my application?Lightyear
It might have other dependencies as well. Change the target framework to .NET 4.0 ( full ) instead of Client Profile.Catima
A
3

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...

using System;
using System.IO;
using System.Net;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            var request = WebRequest.Create("http://google.com");
            var response = request.GetResponse();
            using (var s = response.GetResponseStream())
            using( var sr = new StreamReader(s))
            {
                Console.Write(sr.ReadToEnd());
            }

            Console.ReadKey();
        }
    }
}

You asked about HttpCookieCollection in one of your comments. It seems that HttpWebRequest uses a CookieContainer to store the cookies.

Adhibit answered 22/9, 2011 at 16:43 Comment(0)
M
2

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.

Milden answered 12/2, 2011 at 23:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.