未处理System.TypeInitializationException
  HResult=-2146233036
  Message=“System.ServiceModel.Diagnostics.TraceUtility”的类型初始值设定项引发异常。
  Source=System.ServiceModel
  TypeName=System.ServiceModel.Diagnostics.TraceUtility
  StackTrace:
       在 System.ServiceModel.Diagnostics.TraceUtility.SetEtwProviderId()
       在 System.ServiceModel.ServiceHostBase..ctor()
       在 System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
       在 Wolfy.Server.Program.Main(String[] args) 位置 f:\SUN.TEST\Wolfy.WcfTestClient\Wolfy.Server\Program.cs:行号 16
       在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Configuration.ConfigurationErrorsException
       HResult=-2146232062
       Message=配置系统未能初始化
       Source=System.Configuration
       BareMessage=配置系统未能初始化
       Line=0
       StackTrace:
            在 System.Configuration.ConfigurationManager.PrepareConfigSystem()
            在 System.Configuration.ConfigurationManager.GetSection(String sectionName)
            在 System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
            在 System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
            在 System.Diagnostics.DiagnosticsConfiguration.Initialize()
            在 System.Diagnostics.DiagnosticsConfiguration.get_IndentSize()
            在 System.Diagnostics.TraceInternal.InitializeSettings()
            在 System.Diagnostics.TraceInternal.get_Listeners()
       InnerException: System.Configuration.ConfigurationErrorsException
            HResult=-2146232062
            Message=无法识别的配置节 behaviors。....

Source=System.Configuration
            BareMessage=无法识别的配置节 behaviors。
            Filename=F:\SUN.TEST\Wolfy.WcfTestClient\Wolfy.Server\bin\Debug\Wolfy.Server.vshost.exe.Config
            Line=7
            StackTrace:
                 在 System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
                 在 System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
                 在 System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
                 在 System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
     ...........

最后解决办法:

出现此错误肯定是配置文件的问题,检查配置文件,是否少了标签。

我这里报这个错误,是因为不想一步一步的写配置文件了,就从之前的项目中复制过来的,由于自己的粗心,发现忘了<system.serviceModel></system.serviceModel> 这对最主要的标签了,这里记录一下,提醒自己不要在这么粗心,这么懒了。

04-05 18:24