简体   繁体   中英

How to make Installer using WCF

I have one console application.The application calls WCF on server. The application runs perfectly in Visual Studio 2008.

error: 在此处输入图像描述

在此处输入图像描述

I used an installer project in Visual Studio. I make an installer give primary output to the Application. It cannot connect to WCF on server.

What steps are necessary to make an installer which has an console (Application)exe, which in turn uses WCF.

My Scope Initialization starts from 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

     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 . You should host the WCF service inside a windows service and add the primary output of the windows service to the installer project.

  1. create a WCF.

  2. create a windows service and host the WCF inside it (call the WCF from windows service).

  3. Create a setup project (installer project).

  4. Add the primary output of the windows service to the installer project.

see this link to see the hosting details...

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

See this blog. It will help you with the implementation of windows service...

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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