0

I started a C# project as type "WCF Service Library".

In order to include the WCF service within a GUI application, I added windows Forms within this project (not solution) using the Add button on the project. I then changed the project output type to "Windows Application".

The exe is getting generated in the bin directory however When I click Start in Debug the control is not going to void Main(). But WCF service is getting hosted.

How do I make the control go to main when I click start?

Looks like they both (WCF Service/exe) has to be stated separately (although working fine)

Edit: Reason for having them in a single project is, it is simple for the Service to access data from the Application. Application processes the data and Service send/receives data to the outside world.

In this project, EXE (application) has to be started manually and it works fine. WCF service starts when I click Debug and it works fine.

So the question is, how to start them together?

kpmd
  • 11
  • 3
  • 2
    What is your original problem you need to solve? Why do you want both a "WCF Service Library" and plain executable application in the same executable program? To me that sounds like you have misinterpreted the requirements, or have a flawed design. – Some programmer dude Nov 23 '22 at 11:46
  • Also please take some time to read [the help pages](http://stackoverflow.com/help), take the SO [tour], read [ask], as well as [this question checklist](https://codeblog.jonskeet.uk/2012/11/24/stack-overflow-question-checklist/). Then [edit] your question to improve it, like creating a good title that summarizes your problem or question in one sentence. – Some programmer dude Nov 23 '22 at 11:49
  • a *service* as the name suggests is something you can call, or more precise you can request it do something. An *executable* is - well - a standalone application. A service therefor shouldn't be an exe in itself, but instead be *called* from one (usually this is your IIS-server). – MakePeaceGreatAgain Nov 23 '22 at 11:57
  • Sounds like the real question is "Where's Main in a WinForms application"? Main is there and getting called even if it's hidden. If you configured a specific form to be the entry point, VS will generate the code that initializes and starts that form – Panagiotis Kanavos Nov 23 '22 at 11:59
  • You mean that your individual methods can be called, but if you put them together with the main method, they won't work? – Jiayao Nov 24 '22 at 06:02

1 Answers1

1

In order to solve this issue, I had to redesign how the solution was structured.

  1. Created first project to have the WCF service. This only has the interface and data contracts needed for the WCF service and not the implementation.
  2. Created second project with WinForms GUI application. This has in/out from/to user.
  3. I added the implementation of the WCF service in WinForms GUI application project (point 2) so that the WCF service implementation can access the user data and vice-versa.
  4. GUI Application project (exe) will refer the WCF service project (DLL).
kpmd
  • 11
  • 3