views:

134

answers:

2

I have a web service that I'd like to include as a project reference inside a windows forms application. (The application will be running on non-networked hardware.) I could simply copy the *.vb files I need into my forms project, but I'd rather not fork the code base.

It wasn't hard to include the ASP project in the windows forms solution. However, I can't figure out how to reference it in my forms code. Is this even possible?

+1  A: 

Assuming that you're not trying to call the web service, and just share the implementation details, you could move the common code into an assembly shared by the two projects, or even just link the code files into your second project rather than copying them there.

To add linked files:

  1. Right click on your project
  2. Select Add -> Existing Item...
  3. Select the file(s) you want to add
  4. Click the little arrow on the edge of the Add button, and select "Add As Link"
Simon Steele
+1  A: 

You'll have to include the project and then set up a development instance of the web service.

You can then add a Web Reference to your development instance of the service in your forms app. Make sure you use a dynamic reference to the web service (should store the URL of the service in the app.config file). That'll give you the ability to change the URL later.

Once you're ready to deploy your solution, you can install the web service on the production hardware...and then set up the web service to run in IIS (just for localhost) and update the ap.config of your Forms app to match the service's local URL.

Justin Niessner
I thought about that, but it's so ugly! Thanks for the suggestion though
Jeff
It is ugly, but if you want to use your Web Service as a service...it's what I think you're stuck with. I'd question why you need to utilize the web service as a web service if there's no network connectivity. Any chance you could take away the service layer and just compile the business logic down into a DLL and reference that DLL in your WinForms app?
Justin Niessner