在服务器上部署时,Windows服务中托管的WCF服务抛出异常

时间:2013-08-29 07:33:21

标签: wcf windows-services .net-4.5

我有一个我在Windows服务中托管的WCF服务库。这两个项目都使用.NET Framework 4.5。我已将WCF服务配置复制到Windows服务“app.config”中。作为参考,Windows服务项目中的配置看起来是:

<?xml version="1.0" encoding="utf-8" ?> <configuration>   <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />   </startup>   <connectionStrings>
    <add name="SmartDataExchangerContext" connectionString="Data Source=(local)\SQLExpress; Initial Catalog=SmartDataExchanger; Integrated Security=True;" providerName="System.Data.SqlClient" />   </connectionStrings>   <!-- When deploying the service library project, the content of the config file must be added to the host's    app.config file. System.Configuration does not support config files for libraries. -->   <system.serviceModel>
    <services>
      <service name="SmartDataExchangerService.SchoolService">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/Design_Time_Addresses/SmartDataExchangerService/SchoolService/" />
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address="" binding="basicHttpBinding" contract="SmartDataExchangerService.ISchoolService">
          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="127.0.0.1" />
          </identity>
        </endpoint>
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
      <service name="SmartDataExchangerService.UserService">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/Design_Time_Addresses/SmartDataExchangerService/UserService/" />
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address="" binding="basicHttpBinding" contract="SmartDataExchangerService.IUserService">
          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>   </system.serviceModel> </configuration>

我使用以下命令在开发机器上安装服务:

  1. “InstallUtil.exe”“C:\ Test \ MyServiceHost.exe”
  2. 该服务已成功安装。此外,我能够在开发机器上使用WCF服务。所以一切都在开发机器上按预期工作。

    现在我正在尝试在Windows Server 2008 R2计算机上安装此Windows服务。我遵循以下步骤:

    1. 复制Windows服务项目的“Dubug”文件夹内容 开发机器到服务器上。
    2. 以管理员模式打开命令提示符。
    3. 运行命令:
    4. “InstallUtil.exe”“C:\ Test \ MyServiceHost.exe”

      执行上面的命令会返回以下错误:

        

      初始化安装时发生异常:   System.ArgumentException:URL上的目录无效..

      到目前为止我做了以下尝试:

      • 按照内联建议从配置文件中删除元素 评论。
      • 将启动对象更改为ServiceName.Program。
      • 我尝试使用机器公共IP,而不是使用localhost 地址。
      • 检查我的WCF服务未使用本地驱动器中的任何文件 即不使用“C:\”或“D:\”。

      有人可以建议我应该尝试解决这个问题的任何步骤。

      更新:

      问题解决了。我重新启动了PC,执行了新的步骤并解决了问题。我怀疑在执行命令时我没有给出正确的路径(愚蠢的我)。

0 个答案:

没有答案