4

我已经使用 C# 在框架 4.0 中编写了我的服务。这是一个返回值的简单方法

Web.config 是这样的:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <machineKey validationKey="0E1F430D6FFFA91FBEDAEC1D2DDAAC2127EB055DBAFB78328C5BDE83249A94EA66400453B" decryptionKey="A13EACEAAABBECF2D06619924A8" validation="SHA1" decryption="AES" />
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="DecryptCookie.Service1">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8732/Design_Time_Addresses/WCFandEFService/ProductService/" />
          </baseAddresses>
        </host>
        <endpoint address=""  binding="wsHttpBinding"    contract="DecryptCookie.IService1">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract = "IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>  
</configuration>

当我尝试使用该服务时,我收到如下错误:

Error: The server was unable to process the request due to an internal error. 
For more information about the error, either turn on
IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from
the configuration behavior) on the server in   order to send the exception
information back to the client, or turn on tracing as per the Microsoft .NET
Framework 3.0 SDK documentation and inspect the server trace
logs.System.Exception {System.ServiceModel.FaultException}

我不确定问题是什么。

4

4 回答 4

12

当我收到这些神秘错误时,我会打开跟踪并创建一个服务日志 (.svcLog)。然后,您可以使用 Service Trace Viewer 工具加载/读取此文件。这将为您提供有关错误的详细数据。按照此链接上的说明进行操作 - http://msdn.microsoft.com/en-us/library/ms732023.aspx

于 2013-01-08T15:30:52.090 回答
1

请检查代理文件。检查您是否更新了业务/数据访问文件中的任何内容并且没有更新代理。这是由于代理错误。

于 2013-09-06T10:03:10.800 回答
0

当您将项目从一个系统复制到另一个系统时,可能会出现这种情况。在这种情况下,您必须从 web.config 中删除端点,并且应该再次添加服务引用。

尝试配置跟踪以获取更多错误信息:

打开WCF服务库的app.config文件,添加system.diagnostics的配置

  <sources>
      <source name="System.ServiceModel" 
            switchValue="Critical,Information,ActivityTracing"
                propagateActivity="true">
        <listeners>
                 <add name="messages"
                 type="System.Diagnostics.XmlWriterTraceListener"
                 initializeData="c:\logs\messages.svclog" />
          </listeners>
      </source>
    </sources>
    <trace autoflush="true" />
  </system.diagnostics> ```
于 2013-06-29T06:28:50.700 回答
0

您可以尝试在web.config文件中添加诊断信息以获取日志:

 <system.diagnostics> 
      <sources> 
        <source name="System.ServiceModel" 
                switchValue="All" 
                propagateActivity="true"> 
          <listeners> 
            <add name="traceListener" 
                type="System.Diagnostics.XmlWriterTraceListener" 
                initializeData= "D:\AppLogs\Traces.svclog" /> 
          </listeners> 
        </source> 
      </sources> 
    </system.diagnostics>
于 2017-11-16T13:48:04.403 回答