Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i have developed one c# class library. and i convert it as dll and attach it with one web application and one windows forms application.Some functionality should work only in web application.so i want to check the dll is currently working with web based application or not.how can i check that?
Posted
Comments
Sushil Mate 29-Jul-13 2:20am    
cant you create two dll.. one web compatible another windows?
John Sathish Tamilarasu 29-Jul-13 8:25am    
No i cant. i can hold only one...!

You don't check for it. The functionality should be consistent no matter what type the caller is. Your DLL should NOT be doing ANYTHING AT ALL that has anything to do with the UI of an application. It should be handling data ONLY.
 
Share this answer
 
Comments
onelopez 29-Jul-13 19:05pm    
Sometimes, depending on the size of the project, it does make sense to abstract common UI components into a stand-alone DLL, in which case it would make sense to know what kind of UI you are servicing.

I do have some common UI components in an external DLL that I use between my Winforms and ASP.NET Mvc, the DLL has some basic behavior that both projects can inherit and implement their own way of doing things.
Dave Kreskowiak 29-Jul-13 20:27pm    
I never do that. If I've got stuff that needs to be done "UI-specifically" it doesn't go in a .DLL like this. It may be done as a shim between the two because of the specific nature of the UI requirements, but I don't bundle specific (UI) code with data (UI-agnostic) code in the same .DLL, ever.

The reason is fairly straight forward. What if I need to change something in by Desktop application code, but not the web code? It's easier to replace one .DLL than it is to tear out and replace in multiple places, possibly breaking code that already worked for the web side.
you could try and store the information off the Web.config file, then attempt to read from it. If it fails, you know it has to be on Winforms/WPF. If it succeeds, then you know it has to be running from a web application. This can be as simple as a boolean flag.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900