C# 添加/删除方法会导致异常

C# 添加/删除方法会导致异常,c#,exception,C#,Exception,奇怪的问题。我有一个类,如果我从中添加任何方法(包括私有方法),它会在另一个类中导致异常 例外情况是: An exception of type 'System.MemberAccessException' occurred in mscorlib.dll but was not handled in user code Additional information: Type initializer was not callable. compositionService.DefaultC

奇怪的问题。我有一个类,如果我从中添加任何方法(包括私有方法),它会在另一个类中导致异常

例外情况是:

An exception of type 'System.MemberAccessException' occurred in mscorlib.dll
but was not handled in user code

Additional information: Type initializer was not callable.
compositionService.DefaultCompositionService.SatisfyImportsOnce(this);
导致异常的行是:

An exception of type 'System.MemberAccessException' occurred in mscorlib.dll
but was not handled in user code

Additional information: Type initializer was not callable.
compositionService.DefaultCompositionService.SatisfyImportsOnce(this);
compositionService
的类型为
Microsoft.VisualStudio.ComponentModelHost.ComponentModel
是一个实现
Microsoft.VisualStudio.Shell.TableManager.ITableDataSource
接口的类。)

即使我添加了以下方法,也会发生这种情况:

private void DoNothing()
{
}
如果我删除一个类,则异常发生在同一行中,但实际上是此异常:

An exception of type 'System.InvalidCastException' occurred in mscorlib.dll 
but was not handled in user code

Additional information: Unable to cast object of type 
'System.Reflection.RuntimeMethodInfo' to type 
'System.Reflection.ConstructorInfo'.
添加和删除的方法都是私有的

代码来自
Sarif.Viewer.VisualStudio
项目,我正在添加
DoNothing()
方法的文件是
codelanalysisresultmanager.cs
,在第36行的
ErrorList\SarifTableDataSouce.cs
中导致异常


有什么想法吗?

您需要发布完整的代码,以便识别/复制问题。这并不意味着发布你所有的代码,只有相关的完整代码。耶!如果您正在使用任何特定的库、框架或设计模式,则需要发布完整的代码。出现以下错误:“”“System.Reflection.RuntimeMethodInfo”以键入“System.Reflection.ConstructorInfo”。“,给我一种命名约定冲突的感觉。当然,我明天会添加一些细节。我不确定什么代码相关与否,但代码是开源的。我会在问题文本中添加信息。您需要发布完整的代码,以便识别/复制问题。这并不意味着发布所有代码,只有相关的完整代码.Yap!您需要发布完整的代码。如果您使用的是任何特定的库、框架或设计模式,则会出现以下错误:“”“System.Reflection.RuntimeMethodInfo”以键入“System.Reflection.ConstructorInfo”。”,给我一种命名约定冲突的感觉。当然,我明天会添加一些细节。我不确定哪些代码相关或不相关,但代码是开源的。我将在问题文本中添加信息。