views:

778

answers:

5

I heard from a friend that asp.net relies on/uses a Windows forms class. I tried to figure out which class that might be.

The only class I found was System.Web.UI.WebControls.FontInfo
with the property public string[] Names
that has an Attribute Editor("System.Windows.Forms.Design.StringArrayEditor--snip")

Is there a reference to the Windows.Forms.dll from System.Web.dll?

+1  A: 

There is no reference, and not System.Windows.Forms either.

The StringArrayEditor is a UITypeEditor in the System.Design assembly. This does not get loaded unless used except at design time, when it will be 'lazy-loaded'.

leppie
+1  A: 

First of all, I am not sure such an existence.

But Namespace or classname doesn't necessary mean you need a reference to Windows.Forms.dll. You can define "System.Windows.Forms.Design.StringArrayEditor" in an assembly outside Windows.Forms.dll.

J.W.
You are right, didn't pay attention on that...
Peter Gfader
A: 

Add me to the list of skeptics. But more importantly, it doesn't matter. The way the .Net framework is set up for linking adding or removing a dependance on any of the core assemblies that ship with the framework won't really impact performance in any meaningful way.

Joel Coehoorn
My concern is more deployment: I want deploy the smallest core assemblies needed as possible
Peter Gfader
Same deal: you don't deploy individual .Net assemblies. You deploy the framework: all or nothing.
Joel Coehoorn
Unless of course you're using something like mono and eschewing the normal deployment scenarios.
Joel Coehoorn
But MS is going in the direction to deploy the smallest assemblies that you need, see 3.5 SP1 Client Profile.... Silverlight ...
Peter Gfader
+1  A: 

If you look at the System.Web assembly in the handy Reflector tool, you will see that there is indeed a reference from System.Web to System.Windows.Forms. However, if you use one of the plugins for Reflector that will export the reverse engineered code to files (e.g. FileGenerator), and then search through that, there is no actual use of System.Windows.Forms. Since the .Net runtime will only load assemblies when they are actually needed, the WinForms assembly should never actually be loaded through any usage of System.Web.

Cheetah
+2  A: 

I think there is a reference from System.Web, Version 2.0.0.0 to System.Windows.Forms.

Check out System.Web.Compilation.ResXBuildProvider.GetResourceReader(Stream) in Reflector.
On line one: ResXResourceReader reader = new ResXResourceReader(inputStream); ResXResourceReader is from System.Windows.Forms, Version 2.0.0.0

I was curious because I noticed System.Windows.Forms in the loaded modules window in Visual Studio.

ildasm System.web.dll /out =System.Web.il let me quickly search for System.Windows.Forms references. I couldn’t quickly figure out a way to do it from reflector.

David Silva Smith
+1 well spotted!!
Peter Gfader