失败的网站服务

时间:2015-08-25 13:58:02

标签: c# visual-studio-2010

我在asp.net c#VS2010上完成的网站想要从我运行表示以下异常:

> The type initializer for 'PmServiceLayer.PmService' threw an exception.

在视图详细信息中:

> {ExceptionDetail, probablemente creado por IncludeExceptionDetailInFaults=true, cuyo valor es:
System.TypeInitializationException: The type initializer for 'PmServiceLayer.PmService' threw an exception. ----> System.IO.FileNotFoundException: Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified.
   at PmServiceLayer.PmService..cctor()
   --- Fin del seguimiento de la pila ExceptionDetail interna ---
   at PmServiceLayer.PmService..ctor()
   at CreatePmServiceLayer.PmService()
   at System.ServiceModel.InstanceContext.GetServiceInstance(Message message)
   at System.ServiceModel.Dispatcher.InstanceBehavior.EnsureServiceInstance(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)}
> 
> 
Server stack trace: 
   en System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
   en System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   en System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   en System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   en System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
> 
> Exception rethrown at [0]:     en
> System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
> reqMsg, IMessage retMsg)    en
> System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
> msgData, Int32 type)    en
> PmPresentationLayer.WcfPmService.IpmContract.VoidInternalBatches()   
> en
> PmPresentationLayer.WcfPmService.IpmContractClient.VoidInternalBatches()
> en C:\Users\maquino.CPM\Desktop\Intranet\PmPresentationLayer\Service
> References\WcfPmService\Reference.cs:línea 742    en
> PmPresentationLayer.PmAgent.VoidInternalBatches() en
> C:\Users\maquino.CPM\Desktop\Intranet\PmPresentationLayer\Code\PmAgent.cs:línea
> 284    en PmPresentationLayer.SiteMaster.Page_Load(Object sender,
> EventArgs e) en
> C:\Users\maquino.CPM\Desktop\Intranet\PmPresentationLayer\Site.Master.cs:línea
> 25    en
> System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,
> EventArgs e)    en System.Web.UI.Control.OnLoad(EventArgs e)    en
> System.Web.UI.Control.LoadRecursive()    en
> System.Web.UI.Control.LoadRecursive()    en
> System.Web.UI.Control.LoadRecursive()    en
> System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

这向我建议VoidInternalBatches:

public void VoidInternalBatches()
    {
        _wcfContractClient = WCFServiceClientSingleton.GetInstance();
        _wcfContractClient.VoidInternalBatches();
    }
来自浏览器的品牌我有以下例外:

> Error de servidor en la aplicación '/'.
The type initializer for 'PmServiceLayer.PmService' threw an exception.
Descripción: Excepción no controlada al ejecutar la solicitud Web actual. Revise el seguimiento de la pila para obtener más información acerca del error y dónde se originó en el código.
> 
> Detalles de la excepción:
> System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail,
> System.ServiceModel, Version=4.0.0.0, Culture=neutral,
> PublicKeyToken=b77a5c561934e089]]: The type initializer for
> 'PmServiceLayer.PmService' threw an exception.

> 
> Error de código fuente:
> 
> 
> Línea 740:         Línea 741:        public void VoidInternalBatches()
> { Línea 742:            base.Channel.VoidInternalBatches(); Línea 743:
> } Línea 744:        
> 
> 
> Archivo de origen:
> C:\Users\maquino.CPM\Desktop\Intranet\PmPresentationLayer\Service
> References\WcfPmService\Reference.cs    Línea: 742
> 
> Seguimiento de la pila:
> 
> 
> [FaultException`1: The type initializer for 'PmServiceLayer.PmService'
> threw an exception.]   
> System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
> reqMsg, IMessage retMsg) +10818447   
> System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
> msgData, Int32 type) +336   
> PmPresentationLayer.WcfPmService.IpmContract.VoidInternalBatches() +0 
> PmPresentationLayer.WcfPmService.IpmContractClient.VoidInternalBatches()
> in C:\Users\maquino.CPM\Desktop\Intranet\PmPresentationLayer\Service
> References\WcfPmService\Reference.cs:742   
> PmPresentationLayer.PmAgent.VoidInternalBatches() in
> C:\Users\maquino.CPM\Desktop\Intranet\PmPresentationLayer\Code\PmAgent.cs:284
> PmPresentationLayer.SiteMaster.Page_Load(Object sender, EventArgs e)
> in
> C:\Users\maquino.CPM\Desktop\Intranet\PmPresentationLayer\Site.Master.cs:25
> System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,
> EventArgs e) +51    System.Web.UI.Control.OnLoad(EventArgs e) +92   
> System.Web.UI.Control.LoadRecursive() +54   
> System.Web.UI.Control.LoadRecursive() +145   
> System.Web.UI.Control.LoadRecursive() +145   
> System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
> +772
> 
> 
> Información de versión: Versión de Microsoft .NET Framework:4.0.30319;
> Versión ASP.NET:4.0.30319.34249

检查行错误:

Site.Master.cs:25

protected void Page_Load(object sender, EventArgs e)
        {
            PmAgent _agent = new PmAgent();
            _agent.VoidInternalBatches();
        }

PmAgent.cs:284

public void VoidInternalBatches()
        {
            _wcfContractClient = WCFServiceClientSingleton.GetInstance();
            _wcfContractClient.VoidInternalBatches();
        }

Reference.cs:742

public void VoidInternalBatches() {
            base.Channel.VoidInternalBatches();
        }

我将以下代码提供给服务

代码webservice:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
  </configSections>
  <appSettings>
    <add key="appName" value="cpmapp" />
    <add key="appPassword" value="appuser.123" />
  </appSettings>
  <log4net>
    <appender name="LogFileAppender" type="log4net.Appender.FileAppender">
      <file value="c:\log\Log.txt" />
      <appendToFile value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%ndc] ID=%property{EventID} - %message%newline" />
      </layout>
    </appender>
    <!-- Define some output appenders -->
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%ndc] ID=%property{EventID} - %message%newline" />
      </layout>
    </appender>
    <!-- Setup the root category, add the appenders and set the default level -->
    <root>
      <level value="ALL" />
      <appender-ref ref="LogFileAppender" />
      <appender-ref ref="ConsoleAppender" />
    </root>
  </log4net>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <services>
      <service behaviorConfiguration="basicBh" name="PmServiceLayer.PmService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="usernameHttp" contract="PmContractLayer.IpmContract" />
      </service>
      <service name="PmServiceLayer.WebService" behaviorConfiguration="WebBh">
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="AjaxBehavior" bindingConfiguration="webBinding" contract="PmContractLayer.IwebContract" />
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="AjaxBehavior">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="basicBh">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Windows" />
          </serviceCredentials>
        </behavior>
        <behavior name="WebBh">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Windows" />
          </serviceCredentials>
        </behavior>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <webHttpBinding>
        <binding name="webBinding" maxBufferSize="520000" maxReceivedMessageSize="520000">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </webHttpBinding>
      <basicHttpBinding>
        <binding name="usernameHttp" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="520000" maxReceivedMessageSize="520000">
          <readerQuotas maxDepth="520000" maxStringContentLength="520000" maxArrayLength="520000" maxBytesPerRead="520000" maxNameTableCharCount="520000" />
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
</configuration>

我为这种语言道歉,我来自阿根廷,甚至我在处理这种语言方面遇到了麻烦。

我感谢您给予我的帮助,当然还有阅读我的查询所花费的时间。

问候和早上好!

2 个答案:

答案 0 :(得分:0)

您的项目未找到 log4net 的1.2.10版。您有几种方法可以解决此问题:

  1. 将正确的版本程序集(log4net 1.2.10)放在它所引用的位置。
  2. 使用NuGet并在packages.config中指定程序集。
  3. 升级到最新版本的log4net(1.2.13)。
  4. 强制从NuGet控制台安装log4net:update-package -reinstall log4net.
  5. 如果绝望,请编辑项目文件(.csproj)并搜索如下所示的行:Reference Include="log4net", Version=1.2.10.0, Culture=neutral ...",您可以检查引用程序集的版本和位置。

答案 1 :(得分:0)

我做了以下事情:PM&gt; update-package -reinstall log4net 更新包:无法找到包'log4net'。 在行:1 char:15 + update-package&lt;&lt;&lt;&lt; -reinstall log4net     + CategoryInfo:NotSpecified:(:) [Update-Package],InvalidOperationException     + FullyQualifiedErrorId:NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.UpdatePackageCommand

PM&GT;安装包log4net 安装'log4net 2.0.3'。 已成功安装'log4net 2.0.3'。 将“log4net 2.0.3”添加到PmPresentationLayer。 成功将“log4net 2.0.3”添加到PmPresentationLayer。同时删除log4net项目,但我提出了同样的错误。