Error accessing Types in Stimulsoft.Report.dll
Posted: Wed Oct 21, 2009 2:49 pm
Hi!
As part of some non-report-related functionality, some of our code iterated over all Types in all the loaded Assemblies. This normally worked, but occasionally failed on some projects. After some confusion, it appears that accessing types for the Stimulsoft.Report.dll causes an exception.
I've made a quick test application in C# to demonstrate this. It will normally work, unless a reference to Stimulsoft.Report.dll is added.
The error output is:
As part of some non-report-related functionality, some of our code iterated over all Types in all the loaded Assemblies. This normally worked, but occasionally failed on some projects. After some confusion, it appears that accessing types for the Stimulsoft.Report.dll causes an exception.
I've made a quick test application in C# to demonstrate this. It will normally work, unless a reference to Stimulsoft.Report.dll is added.
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace SSTest1
{
class Program
{
static void Main(string[] args)
{
try
{
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
Console.WriteLine("Assembly: " + assembly.FullName + " at " + assembly.Location);
foreach (Type type in assembly.GetTypes())
Console.WriteLine(" Type: " + type.Name);
}
}
catch (Exception ex)
{
Console.WriteLine("\nOh no! :-(\n");
Console.WriteLine(ex.ToString());
Console.WriteLine("\nProblem caused by: ");
foreach (Exception le in ((ReflectionTypeLoadException)ex).LoaderExceptions)
Console.WriteLine(le.ToString());
}
Console.WriteLine("\nAll done!");
Console.ReadKey();
//Uncomment if not running in Debugger, as it behaves differently!
Stimulsoft.Report.Viewer.IStiViewerControl it;
}
}
}
(I believe we're running the release version of 2009.2, FYI)[...]
Assembly: Stimulsoft.Report, Version=2009.2.500.0, Culture=neutral, PublicKeyToken=ebe6666cba19647a at C:\Windows\assembly\GAC_MSIL\Stimulsoft.Report\2009.2.500.0__ebe6666cba19647a\Stimulsoft.Report.dll
Oh no!
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at StimulsoftTest1.Program.Main(String[] args) in C:\Testing\SSTest1\Program.cs:line 18
Problem caused by:
System.TypeLoadException: Could not load type 'CRYPT_ALGORITHM_IDENTIFIER' from assembly 'Stimulsoft.Report, Version=2009.2.500.0, Culture=neutral, PublicKeyToken=ebe6666cba19647a' because it contains an object field at offset 4 that is incorrectly aligned or overlapped by a non-object field.
System.TypeLoadException: Could not load type 'CRYPT_ALGORITHM_IDENTIFIER' from assembly 'Stimulsoft.Report, Version=2009.2.500.0, Culture=neutral, PublicKeyToken=ebe6666cba19647a' because it contains an object field at offset 4 that is incorrectly aligned or overlapped by a non-object field.
All done!