C# 未处理System.InvalidOperationException HResult=-2146233079

1.异常信息:

未处理System.InvalidOperationException

HResult=-2146233079

Message=The custom trace listener 'custom listener' does not have a listener type name set or the type is invalid (F:\CBCT64\Output\Polaris.exe.Config line 45).

Source=Microsoft.Practices.EnterpriseLibrary.Logging

StackTrace:

在 Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.BasicCustomTraceListenerData.GetConstructor(Type\[\] constructorParameters)

在 Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.BasicCustomTraceListenerData.CoreBuildTraceListener(LoggingSettings settings)

在 Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.CustomTraceListenerData.CoreBuildTraceListener(LoggingSettings settings)

在 Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.TraceListenerData.BuildTraceListener(LoggingSettings settings)

在 Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings.BuildTraceListener(String name, ConfigurationElement requestor)

在 Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings.<>c__DisplayClass45_0.<BuildTraceSource>b__0(TraceListenerReferenceData tln)

在 System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()

在 System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)

在 Microsoft.Practices.EnterpriseLibrary.Logging.LogSource..ctor(String name, IEnumerable`1 traceListeners, SourceLevels level, Boolean autoFlush)

在 Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings.BuildTraceSource(TraceSourceData tsd, Dictionary`2 listeners)

在 Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings.<>c__DisplayClass44_0.<BuildLogWriter>b__1(TraceSourceData tsd)

在 System.Linq.Enumerable.ToDictionaryTSource,TKey,TElement(IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)

在 System.Linq.Enumerable.ToDictionaryTSource,TKey,TElement(IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)

在 Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings.BuildLogWriter()

在 Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterFactory.LogWriterConfigurationBuilder.Create()

在 Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterFactory.Create()

在 Foundation.Logger.Logger.SetLogWriter()

在 Polaris.EntryPoint.Main(String\[\] args)

InnerException:

FileName=LogViewerByMonth, Culture=neutral

FusionLog==== 预绑定状态信息 ===

日志: DisplayName = LogViewerByMonth, Culture=neutral

(Partial)

警告: 为程序集提供了部分绑定信息:

警告: 程序集名称: LogViewerByMonth, Culture=neutral | 域 ID: 1

警告: 当仅提供程序集显示名称的一部分时,将发生部分绑定。

警告: 这可能导致联编程序加载错误的程序集。

警告: 建议为程序集提供完全指定的文字标识,

警告: 并由简单名称、版本、区域性和公钥标记组成。

警告: 有关此问题的详细信息和常见解决方案,请参见白皮书 http://go.microsoft.com/fwlink/?LinkId=109270。

日志: Appbase = file:///F:/CBCT64/Output/

日志: 初始 PrivatePath = NULL

调用程序集: Microsoft.Practices.EnterpriseLibrary.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null。

===

日志: 此绑定从 default 加载上下文开始。

日志: 正在使用应用程序配置文件: F:\CBCT64\Output\Polaris.exe.Config

日志: 使用主机配置文件:

日志: 使用 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config 的计算机配置文件。

日志: 此时没有为引用应用策略(私有、自定义、分部或基于位置的程序集绑定)。

日志: 尝试下载新的 URL file:///F:/CBCT64/Output/LogViewerByMonth.DLL。

日志: 尝试下载新的 URL file:///F:/CBCT64/Output/LogViewerByMonth/LogViewerByMonth.DLL。

日志: 尝试下载新的 URL file:///F:/CBCT64/Output/LogViewerByMonth.EXE。

错误: 未能完成程序集的安装(hr = 0x8007000b)。探测终止。

HResult=-2147024885

Message=未能加载文件或程序集"LogViewerByMonth, Culture=neutral"或它的某一个依赖项。试图加载格式不正确的程序。

Source=mscorlib

StackTrace:

在 System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)

在 System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)

在 System.Type.GetType(String typeName, Boolean throwOnError)

在 Microsoft.Practices.EnterpriseLibrary.Common.Configuration.AssemblyQualifiedTypeNameConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)

在 Microsoft.Practices.EnterpriseLibrary.Common.Configuration.NameTypeConfigurationElement.get_Type()

在 Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.BasicCustomTraceListenerData.GetConstructor(Type\[\] constructorParameters)

InnerException:

2.解决方法

(1)检查 Polaris.exe.Config 文件,确保custom listener节点配置正确。确认自定义跟踪侦听器的名称是否正确,以及是否设置了正确的侦听器类型名称。

复制代码
<add name="custom listener" />

(2)在问题描述中可以看到红色字体部分,重新生成"LogViewerByMonth"项目。

其他注意点

  1. 确认自定义跟踪侦听器的类是否存在,并且它实现了正确的接口。确保类的名称与配置文件中指定的侦听器类型名称匹配。
  2. 检查自定义跟踪侦听器的代码,确保它正确地实现了必要的接口和方法。确保类的构造函数没有任何错误或异常。
  3. 如果可能的话,尝试重新编译和部署应用程序,以确保所有的依赖项都正确加载。
  4. 如果问题仍然存在,可能需要查看更详细的错误信息或日志,以获取更多的上下文和线索。查看应用程序的日志文件或使用调试工具来获取更详细的错误信息。

3.其他问题

未处理System.TypeInitializationException

HResult=-2146233036

Message="ExaminationUI.IPWInitliazer"的类型初始值设定项引发异常。

Source=ExaminationUI

TypeName=ExaminationUI.IPWInitliazer

StackTrace:

在 ExaminationUI.IPWInitliazer.Initlizer()

在 ExaminationUI.Examation..ctor()

在 Polaris.EntryPoint.Main(String\[\] args)

InnerException:

FileName=XRayIPWraper, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

FusionLog==== 预绑定状态信息 ===

日志: DisplayName = XRayIPWraper, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

(Fully-specified)

日志: Appbase = file:///F:/CBCT64/Output/

日志: 初始 PrivatePath = NULL

调用程序集: ExaminationUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null。

===

日志: 此绑定从 default 加载上下文开始。

日志: 正在使用应用程序配置文件: F:\CBCT64\Output\Polaris.exe.Config

日志: 使用主机配置文件:

日志: 使用 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config 的计算机配置文件。

日志: 此时没有为引用应用策略(私有、自定义、分部或基于位置的程序集绑定)。

日志: 尝试下载新的 URL file:///F:/CBCT64/Output/XRayIPWraper.DLL。

错误: 未能完成程序集的安装(hr = 0x8007000b)。探测终止。

解决方案同上。

相关推荐
小羊没烦恼!3 天前
初探性能优化——2个月到4小时的性能提升
java·开发语言·windows·算法·c#
神仙别闹3 天前
基于C#+MySQL实现(WinForm)个人聊天室软件
c#
kybs19913 天前
全球灾害数据分析可视化 毕业设计-附源码66794
vue.js·spring boot·mysql·安全·django·c#·asp.net
Polevne3 天前
C# SFTP客户端实现文件传输
c#·ssh
samble3 天前
从零搭建灌装监控系统(四):深色主题与样式系统,ResourceDictionary 统一管理
c#·wpf·mvvm·样式·工业控制
_Jonas3 天前
.net framework开发环境正式环境配置文件的切换
.net·wpf
cjp5603 天前
024 . WPF MVVM类封装优化
c#
淡海水4 天前
13-04-面试-源码级深度追问链
数据结构·unity·面试·c#·游戏引擎·源码·il2cpp
asdzx674 天前
如何使用 C# 提取 PPT 文本与图片
c#·ppt·提取文本
2501_930707784 天前
使用C#代码使用条件格式为 Excel 隔行设置颜色
c#·excel