views:

53

answers:

4

What exactly is wrong with referencing both System.Web and System.Windows.Forms in my class library?

For example, library could contain some code which needs to reference Web or WinForms-specific classes.

+1  A: 

If you need a class within any of those namespaces, there is nothing wrong on referencing related assemblies.

You have to be carefully adding very specific presentation logic on your model layer, that's the only red flag I see.

Claudio Redi
+2  A: 

Well, if you do this, you will have overhead if you use that library and the danger, that Web code uses the Forms lib and vice versa. I would split it in 3 Parts - a common one and one Web and one Forms part, so you only have to use the common and the part you need. By that, you guarantee that you only use the libs you are supposed to.

Femaref
A: 

There's nothing wrong with it, especially if you have to interoperate with web services.

One thing that I will say is this. If you're using System.Web for System.Web.Caching, use System.Runtime.Caching instead, if you're targeting .NET 4.0.

Dave Markle
A: 

There's nothing wrong with referencing. It's how you use the references that matter.

SiN