none
WCF Service Library Project not publish in x64 bit. RRS feed

  • Question

  • Hi,

    I am creating new WCF Service Library Project in Visual Studio 2015, and try to publish it in Release mode with Platform x64 bit. But publish is not succeeded. If I publish this project (WCF Service Library Project) in Visual Studio 2017 with same configuration (Release mode & Platform x64 bit) then it is successfully publish. Kindly help me to understand that why WCF Service Library Project is not publish in Visual Studio 2015 in Release mode with Platform x64 bit.

    Regard,

    Tamoor Afzal

    Thursday, December 27, 2018 8:02 AM

Answers

  • Hi Tahmoor.afzal,

    WCF service library project is typically hosted in a part of windows service project, or to build a wcf project together with other projects that contain configuration files, such as wcf service application project. when it is hosted in the windows service, we need to manually configure service through coding.

    public partial class Service1 : ServiceBase
        {
            Uri uri = new Uri("net.tcp://localhost:6200/myservice");
    
            internal static ServiceHost sh = null;
            public Service1()
            {
                InitializeComponent();
            }
    
            protected override void OnStart(string[] args)
            {
                if (sh != null)
                {
                    sh.Close();
                }
    
                NetTcpBinding binding = new NetTcpBinding();
                binding.Security.Mode = SecurityMode.Message;
    
                sh = new ServiceHost(typeof(MyService), uri);
                sh.AddServiceEndpoint(typeof(IService), new NetTcpBinding(), "");
                ServiceMetadataBehavior smb;
                smb = sh.Description.Behaviors.Find<ServiceMetadataBehavior>();
                if (smb == null)
                {
                    smb = new ServiceMetadataBehavior();
                    sh.Description.Behaviors.Add(smb);
                }
                Binding mexbinding = MetadataExchangeBindings.CreateMexTcpBinding();
                sh.AddServiceEndpoint(typeof(IMetadataExchange), mexbinding, "mex");
                sh.Open();
    
            }

    we seldom create a class library project, which is usually a way to organize the project structure. I suggest you start with wcf service application project templates, when you configure the endpoint, you can publish directly to IIS.

      <system.serviceModel>
        <services>
          <service name="WcfService1.Service1">
            <endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1"></endpoint>
          </service>
        </services>

    Best Regards
    Abraham

                    

    Monday, December 31, 2018 9:24 AM
    Moderator

All replies

  • Hi Tamoor Afzal,

    Welcome to the MSDN forum.

    Refer to the description, your issue is about the WCF development and since our forum is to discuss the VS IDE, I will help you move this thread to the appropriate forum for a better support, thank you for your understanding.

    Best regards,

    Sara


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, December 28, 2018 2:23 AM
  • Hi Tahmoor.afzal
    The WCF Service library project does not contain configuration and SVC file (hosting configuration) which is the main difference from WCF service application project templates. The App.config file is used as the default configuration when debugging with wcftestclient.exe. 
    Here is the official instruction.
    >>Visual Studio is configured to recognize the App.config file as the configuration file for the project when it is run using the WCF Service Host (WcfSvcHost.exe), which is the default configuration. If you host the service library in an executable, you have to move the configuration code to the configuration file of the executable, as configuration files for DLLs are not valid.
    https://docs.microsoft.com/en-us/dotnet/framework/wcf/wcf-vs-templates
    When publishing a library project, you need to explicitly comment out the system.servicemodel section.
    Feel free to let me know if there is anything I can help with.
    Best Regards
    Abraham
    Friday, December 28, 2018 9:19 AM
    Moderator
  • Hi Abraham,

    Thanks for your response, actually when I publish my WCF Service Library project in release mode with platform Any CPU then it is successfully publish, but when I change platform from Any CPU to x64 then it is not publish. Moreover I also remove the system.servicemodel section from app.config file but the issue is persist, project is not publish successfully in x64.

    Regards,

    Tamoor Azal

    Friday, December 28, 2018 10:20 AM
  • Hi Tahmoor.afzal,

    Could you build the WCF service library project successfully? On my side, when I change the platform to x64 and remove the configuration files, the project compiles and releases normally.

    What error message occurred during the compilation? Could you please share it with me?

    Best Regards

    Abraham

    Monday, December 31, 2018 2:12 AM
    Moderator
  • Hi Abraham,

    Once again thanks to provide understating, & when I remove app.config file from my WCF service library project and publish it in release mode with platform x64 then it is successfully published, but now how and where I can configure those settings that are in app.config file.

    Monday, December 31, 2018 6:28 AM
  • Hi Tahmoor.afzal,

    WCF service library project is typically hosted in a part of windows service project, or to build a wcf project together with other projects that contain configuration files, such as wcf service application project. when it is hosted in the windows service, we need to manually configure service through coding.

    public partial class Service1 : ServiceBase
        {
            Uri uri = new Uri("net.tcp://localhost:6200/myservice");
    
            internal static ServiceHost sh = null;
            public Service1()
            {
                InitializeComponent();
            }
    
            protected override void OnStart(string[] args)
            {
                if (sh != null)
                {
                    sh.Close();
                }
    
                NetTcpBinding binding = new NetTcpBinding();
                binding.Security.Mode = SecurityMode.Message;
    
                sh = new ServiceHost(typeof(MyService), uri);
                sh.AddServiceEndpoint(typeof(IService), new NetTcpBinding(), "");
                ServiceMetadataBehavior smb;
                smb = sh.Description.Behaviors.Find<ServiceMetadataBehavior>();
                if (smb == null)
                {
                    smb = new ServiceMetadataBehavior();
                    sh.Description.Behaviors.Add(smb);
                }
                Binding mexbinding = MetadataExchangeBindings.CreateMexTcpBinding();
                sh.AddServiceEndpoint(typeof(IMetadataExchange), mexbinding, "mex");
                sh.Open();
    
            }

    we seldom create a class library project, which is usually a way to organize the project structure. I suggest you start with wcf service application project templates, when you configure the endpoint, you can publish directly to IIS.

      <system.serviceModel>
        <services>
          <service name="WcfService1.Service1">
            <endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1"></endpoint>
          </service>
        </services>

    Best Regards
    Abraham

                    

    Monday, December 31, 2018 9:24 AM
    Moderator
  • Thank you very much for detail understanding.
    Monday, December 31, 2018 9:37 AM