Referencing both System.Web and System.Windows.Forms
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 refe开发者_StackOverflow中文版rence Web or WinForms-specific classes.
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.
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.
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.
There's nothing wrong with referencing. It's how you use the references that matter.
精彩评论