简体   繁体   English

如何使用 WCF 制作安装程序

[英]How to make Installer using WCF

I have one console application.The application calls WCF on server.我有一个控制台应用程序。该应用程序在服务器上调用 WCF。 The application runs perfectly in Visual Studio 2008.该应用程序在 Visual Studio 2008 中完美运行。

error:错误: 在此处输入图像描述

在此处输入图像描述

I used an installer project in Visual Studio.我在 Visual Studio 中使用了一个安装程序项目。 I make an installer give primary output to the Application.我让安装程序将主要 output 提供给应用程序。 It cannot connect to WCF on server.它无法连接到服务器上的 WCF。

What steps are necessary to make an installer which has an console (Application)exe, which in turn uses WCF.制作具有控制台(应用程序)exe 的安装程序需要哪些步骤,该程序又使用 WCF。

My Scope Initialization starts from initScopeInfo.我的 Scope 初始化从 initScopeInfo 开始。

   private void initScopeInfo()
       {
        DBSyncProxy.SqlSyncProviderProxy client = null;            
        ScopeConfigHandler scopeHandler = null;
        try
        {

    //Providing the Config file name('db_config_new.xml') stored in static variable.    
            DBSyncXMLUtil.setXPathDocument(DBSyncConstants.DB_SYNC_CONFIG_FILE_NAME);

            //DBSyncXMLUtil.setXPathDocument(filepath);
            string endpoint = DBSyncXMLUtil.getSystemParameter(DBSyncXMLUtil.getDocumnetRoot(), "ServiceURL");

In setXpathDocument在 setXpathDocument 中

     public static void setXPathDocument(string uri)
      {
public static XPathDocument doc = null;

        doc = new XPathDocument(uri);
    }
     public static string getSystemParameter(XPathNavigator docroot, string key)
    {
        string value = null;
        try
        {
            string xpath = DBSyncConstants.XPATH_SYSTEM_PARAMETER;
            xpath += "[@key='" + key + "']";

            Console.WriteLine("DBSyncXMLUtil :: getParameter() :: XPATH =="+xpath);

    Probably  Error on below mentioned line

            XPathNavigator node = getDocumnetRoot(doc).SelectSingleNode(xpath);
            if (node != null)
                value = node.Value;
            else
                Console.WriteLine("Invalid XPATH");
        }
        catch (Exception ex)
        {
            Console.WriteLine("DBSyncXMLUtil :: getSystemParameter() :: Exception ==" + ex.ToString());
        }
        return value;
    }

Actually you cannot directly create an installer project by adding primary output from a WCF service .实际上,您不能通过从 WCF 服务添加主 output 来直接创建安装程序项目 You should host the WCF service inside a windows service and add the primary output of the windows service to the installer project.应该在 windows 服务内托管 WCF 服务,并将 Z0F4137ED1502B8B504C2 项目安装程序的主 output 添加到服务output 到服务ZZ22 项目安装程序。

  1. create a WCF.创建一个 WCF。

  2. create a windows service and host the WCF inside it (call the WCF from windows service).创建一个 windows 服务并在其中托管 WCF(从 Z0F4137ED1502B5045D608 服务调用 WCF)。

  3. Create a setup project (installer project).创建一个安装项目(安装程序项目)。

  4. Add the primary output of the windows service to the installer project.将 windows 服务的主 output 添加到安装程序项目。

see this link to see the hosting details...查看此链接以查看托管详细信息...

http://msdn.microsoft.com/en-us/library/ms733069.aspx http://msdn.microsoft.com/en-us/library/ms733069.aspx

See this blog.看到这个博客。 It will help you with the implementation of windows service...它将帮助您实现 windows 服务...

http://joefreeman.co.uk/blog/2010/03/creating-a-setup-project-for-a-windows-wcf-service-with-visual-studio/ http://joefreeman.co.uk/blog/2010/03/creating-a-setup-project-for-a-windows-wcf-service-with-visual-studio/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM