WCF异常问题2014-09-08 “System.Transactions.Diagnostics.DiagnosticTrace”的类型初始值设定项引发异常未处理System.TypeInitializationExceptionHResult=-2146233036Message=“System.ServiceModel.Diagnostics.TraceUtility”的类型初始值设定项引发异常。Source=System.ServiceModelTypeName=System.ServiceModel.Diagnostics.TraceUtilityStackTrace:在 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.TESTWolfy.WcfTestClientWolfy.ServerProgram.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.ConfigurationErrorsExceptionHResult=-2146232062Message=配置系统未能初始化Source=System.ConfigurationBareMessage=配置系统未能初始化Line=0StackTrace:在 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.ConfigurationErrorsExceptionHResult=-2146232062Message=无法识别的配置节 behaviors。....Source=System.ConfigurationBareMessage=无法识别的配置节 behaviors。Filename=F:SUN.TESTWolfy.WcfTestClientWolfy.ServerinDebugWolfy.Server.vshost.exe.ConfigLine=7StackTrace:在 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> 这对最主要的标签了,这里记录一下,提醒自己不要在这么粗心,这么懒了。作者:Wolfy出处:http://www.cnblogs.com/wolf-sun/