我们最近将 C# 项目从 .NET 3.5 更新到了 4.0。我们在本地机器和 CC.NET 上运行 Gendarme。在更新了我们所有的项目后,Gendarme 正在为我们的一个程序集收到此错误(打开日志记录):
An uncaught exception occured. Please fill a bug report at https://bugzilla.novell.com/
Rule: Gendarme.Rules.Globalization.SatelliteResourceMismatchRule
Target: Core.UI, Version=27.0.0.0, Culture=neutral, PublicKeyToken=null
Stack trace: System.IO.FileNotFoundException: Could not load file or assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, BooleanloadTypeFromPartialName)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError)
at System.Resources.ResourceReader.FindType(Int32 typeIndex)
at System.Resources.ResourceReader.DeserializeObject(Int32 typeIndex)
at System.Resources.ResourceReader.LoadObjectV2(Int32 pos, ResourceTypeCode& typeCode)
at System.Resources.ResourceReader.GetValueForNameIndex(Int32 index)
at System.Resources.ResourceSet.ReadResources()
at Gendarme.Rules.Globalization.SatelliteResourceMismatchRule.CheckSatelliteResource(EmbeddedResource mainResource, EmbeddedResource satelliteResource, IMetadataTokenProvider satelliteAssembly)
at Gendarme.Rules.Globalization.SatelliteResourceMismatchRule.CheckSatelliteAssembly(AssemblyDefinition satellite)
at Gendarme.Rules.Globalization.SatelliteResourceMismatchRule.CheckAssembly(AssemblyDefinition assembly)
at Gendarme.Framework.Runner.OnAssembly(RunnerEventArgs e)
at Gendarme.ConsoleRunner.OnAssembly(RunnerEventArgs e)
at Gendarme.Framework.Runner.Run()
at Gendarme.ConsoleRunner.Run()
at Gendarme.ConsoleRunner.Execute(String[] args)
=== Pre-bind state information ===
LOG: DisplayName = System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///c:/sd/trunk/bin/prod/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
LOG: Post-policy reference: System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Attempting download of new URL file:///c:/sd/trunk/bin/prod/System.Drawing.DLL.
LOG: Attempting download of new URL file:///c:/sd/trunk/bin/prod/System.Drawing/System.Drawing.DLL.
LOG: Attempting download of new URL file:///c:/sd/trunk/bin/prod/System.Drawing.EXE.
LOG: Attempting download of new URL file:///c:/sd/trunk/bin/prod/System.Drawing/System.Drawing.EXE.
在多台计算机上发生相同的错误。Gendarme 在引用 System.Drawing 的其他程序集以及引用损坏的程序集的程序集上工作正常。我为宪兵创建了一个配置文件并指定了 .NET 4.0,但我仍然遇到同样的错误。我删除了引用并再次添加它,没有任何变化。如果我运行我们的程序,则此程序集中的控件可以加载并正常工作。我们在这个程序集中进行了单元测试,NUnit 和 PartCover 也运行良好。
我注意到它使用的是 Framework64\v2.0.50727 文件夹中的 machine.config 文件,但我不明白为什么这个程序集会与其他程序集不同。这可能是个问题吗?我还能尝试什么?