开发者

Could not load file or assembly ... from SatelliteResourceMismatchRule

开发者 https://www.devze.com 2023-03-17 07:08 出处:网络
We\'ve recently updated our C# projects from .NET 3.5 to 4.0.We run Gendarme on our local machines and on CC.NET.After updating all of our projects, Gendarme is is getting this error for one of our as

We've recently updated our C# projects from .NET 3.5 to 4.0. We run Gendarme on our local machines and on CC.NET. After updating all of our projects, Gendarme is is getting this error for one of our assemblies (with logging turned on):

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 refl开发者_JAVA技巧ectionOnly, 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.

The same error occurs on multiple computers. Gendarme works fine on other assemblies that reference System.Drawing as well as assemblies that reference the one that is broken. I created a config file for gendarme and specified .NET 4.0, but I still get the same error. I removed the reference and added it again with no change. If I run our program, the controls in this assembly load and work without any issues. We have unit tests in this assembly and NUnit and PartCover also run fine.

I noticed that it is using a machine.config file from the Framework64\v2.0.50727 folder, but I can't see why this assembly would be different from the others. Could that be an issue? What else can I try?


In general it does not matter what version of the framework you're analyzing, i.e. Gendarme supports them all. However in this case the rule tries to load data from the resources, which deserialization requires a version of .NET (4.0) that is different from the one Gendarme is being executed (3.5).

This is a bug in the rule itself and needs to be fixed (please open the bug report like the error message asked). In the mean time exclude this rule (totally or over some assembly/type/method) from your analysis.


FYI: I had the same problem as you; however, I was able to get gendarme running in sonar by installing the most recent snapshot version: https://github.com/spouliot/gendarme/downloads (currently at gendarme-2.11-snapshot-20110305-win32-setup.zip)

Make sure to set the installation path in your sonar-project.properties file:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消