Creating class library project from winform
I have a winform project (from a different person, I didn't build it), that uses a web reference. I want to create a new project - class library project - based on the winform project (without GUI).
I tried to copy some of the files but I can't copy this web reference, I don't even have a directory "Web References" in my new project. When I click on the web reference that I want, I see on the properties "Url Behaviour - Dynamic" and "Web reference" - a url in my computer that does not exist (but the old project works!).
When I enter to the web reference directory on my file explorer I can see files there but no dll so I can't add it to the new project..
What's I'm doing wrong?
- Change project options from Windows application to class library.
- Compile it and you get the dll.
- Create a new WinForms project and add this class library project as reference. (You might need to move some files from the class library to the WinForms project sometimes.)
Right click Project, and then Add Service Reference.
Add Web Reference is the old-style, deprecated ASP.NET webservices.
Add Service Reference is the new way of doing it, adding a WCF service reference.
See this MSDN page for more information: How to: Add, Update, or Remove a Service Reference
First of all, Web References do not work with dlls directly. A Web Reference is a reference to a web service, i.e. a service that exposes its service methods through a web interface. In order to communicate with a web service the http protocol is (usually) used just like with regular websites. You can read more about web services here: http://gdp.globus.org/gt4-tutorial/multiplehtml/ch01s02.html
How to add the web reference:
I am assuming you are using Visual Studio - I myself am using Visual Studio 2010, so if you have an older/newer version things might look slightly different.
Right click on your project and select "Add Service Reference". In this dialog, enter the address of the web service which you want to reference. Press Go and Visual Studio should try to connect to the service and after a while the service should show up in the Services list. Select the service and press ok.