2

最近、C#プロジェクトを.NET3.5から4.0に更新しました。GendarmeはローカルマシンとCC.NETで実行されます。すべてのプロジェクトを更新した後、Gendarmeはアセンブリの1つでこのエラーを受け取ります(ロギングがオンになっています):

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を参照する他のアセンブリ、および壊れているアセンブリを参照するアセンブリで正常に機能します。gendarmeの構成ファイルを作成し、.NET 4.0を指定しましたが、それでも同じエラーが発生します。参照を削除し、変更せずに再度追加しました。プログラムを実行すると、このアセンブリのコントロールがロードされ、問題なく機能します。このアセンブリには単体テストがあり、NUnitとPartCoverも正常に実行されます。

Framework64 \ v2.0.50727フォルダーのmachine.configファイルを使用していることに気付きましたが、このアセンブリが他のアセンブリと異なる理由がわかりません。それが問題になる可能性はありますか?他に何を試すことができますか?

4

2 に答える 2

1

一般に、分析しているフレームワークのバージョンは重要ではありません。つまり、Gendarmeはそれらすべてをサポートしています。ただし、この場合、ルールはリソースからデータを読み込もうとします。この逆シリアル化には、Gendarmeが実行されているバージョン(3.5)とは異なるバージョンの.NET(4.0)が必要です。

これはルール自体のバグであり、修正する必要があります(エラーメッセージのようにバグレポートを開いてください)。それまでの間、このルールを(全体的に、または一部のアセンブリ/タイプ/メソッドにわたって)分析から除外してください。

于 2011-07-16T13:16:03.890 に答える
1

参考:私はあなたと同じ問題を抱えていました。ただし、最新のスナップショットバージョンをインストールすることで、ソナーでgendarmeを実行することができました:https ://github.com/spouliot/gendarme/downloads (現在はgendarme-2.11-snapshot-20110305-win32-setup.zip)

sonar-project.propertiesファイルでインストールパスを設定してください。

sonar.gendarme.installDirectory = C:/ Program Files / Gendarme /

于 2011-11-22T20:26:55.540 に答える