Search code examples
vb.netwcfservicehost

WCF 'sub main' not found


I must be losing my mind...

After getting a test WCF hosted in a windows service, I'm trying for another one (practice, practice, practice).

I created a WCF service library, added one function. Then created a Windows Service, and added my WCF to the project. Did the rest of the stuff located here (http://joefreeman.co.uk/blog/2010/03/creating-a-setup-project-for-a-windows-wcf-service-with-visual-studio/)

Now I'm getting this "Sub Mian was not found in [WCF app]" error when I try to build the solution.

I didn't think WCF projects required a Sub Main as they are services and not applications. What am I doing wrong? I didn't have a sub main in my last project. Any ideas?


Solution

  • The WCF service itself doesn't need a Sub Main, but your Windows Service does.

    Compare against your previously built, working Windows Service.

    edit: using C#, when I create a new project using the Windows Service template, I get the following initial code in a Program.cs file (static void Main is your Sub Main). I'd be very surprised if you don't also have this in your Windows Service.

    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()