Could not load type 'xe881e4987a64f736' from assembly 'Aspose.Cells

There is a bug loading the types included in the Aspose.Cells.dll assembly versions 4.7.0.0 and 4.7.1.0 in 64-bit Windows. These same assemblies load their types successfully on 32-bit Windows. I have written a program (see attached) to load the assembly from the disk and enumerate the types in the assembly.

The exception message from loading the types is “Could not load type ‘xe881e4987a64f736’ from assembly ‘Aspose.Cells, Version=4.7.1.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’ because it contains an object field at offset 4 that is incorrectly aligned or overlapped by a non-object field.”

Hi,

It looks that you are using the Aspose.Cells.dll component version compiled on .NET1.0 in ".....\Aspose\Aspose.Cells\Bin\Net1.0". Please use Aspose.Cells.dll component in "\Aspose\Aspose.Cells\Bin\Net2.0" which works fine on 64-bit environments. For reference, see the document: http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/using-aspose-cells-for-net-on-32bit-and-64bit-platforms.html

Kindly let us know if it works fine now.

Thank you.

I did use the .NET 2.0 assembly.
It does not appear that you looked at the source I provided.
Please run the code I provided (attached in the first post), pass in the .net 2.0 version Aspose.cells.dll and you will be able to reproduce the issue. (other .net 2.0 aspose assemblies work fine)

Here is the code (again) to reproduce the issue:


namespace ClickCommerce.Test
{
using System;
using System.Reflection;

public sealed class Load
{
public static void Main(string[] args)
{
try {
if (args == null || args.Length == 0) {
Console.WriteLine(“Load “);
return;
}
// TODO: If path is relative, make it relative to the current directory.
Assembly asm = Assembly.LoadFile(args[0]);
Console.WriteLine(asm.GetName(false).FullName);
foreach (Type type in asm.GetTypes()) {
Console.WriteLine(” Type: {0}”, type.FullName);
}
} catch (ReflectionTypeLoadException rtle) {
WriteException(string.Empty, rtle);
Console.WriteLine();
foreach (Exception le in rtle.LoaderExceptions) {
WriteException(" “, le);
}
} catch (Exception e) {
WriteException(string.Empty, e);
}
}

private static void WriteException(string indent, Exception e)
{
Console.WriteLine(”{4}Exception: {1}: {2}{0}{3}", Environment.NewLine, e.GetType().FullName, e.Message, e.StackTrace, indent);
}
}
}



Hi,

Well, we did utilize your code in vs.net 2005 with both .NET1.x and .NET2.0 compiled versions of Aspose.Cells component, it works absolutely fine on my machine (WinXp, 32-bit). It provides all the type info on the console without any error or issue. We will try to check it on 64-bit environment if we could find the issue. We will get back to you soon.

Thank you.

That is correct.
The code will work just fine on a 32 bit machine.
If you try it on a 64 bit machine it WILL fail.

Hi,

Could you try the attached latest .NET2.0 compiled version/fix.

Thank you.

We tried the latest assembly.
It did not work on 64bit windows. In 64-bit Windows (x64), we can successfully do the following:
- load the assembly
- retrieve the assembly name of the loaded assembly

We CANNOT do the following:
- Enumerate the types located in this assembly. This means the “foreach (Type t in assembly.GetTypes()) {}” FAILS on 64-bit Windows.

When running the sample program from the previous post, you get the following output:

Aspose.Cells, Version=4.7.1.19, Culture=neutral, PublicKeyToken=716fcc553a201e56

Exception: System.Reflection.ReflectionTypeLoadException: Unable to load one or
more of the requested types. Retrieve the LoaderExceptions property for more inf
ormation.
at System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at ClickCommerce.Test.Load.Main(String[] args)

Exception: System.TypeLoadException: Could not load type ‘xe881e4987a64f736’ from assembly ‘Aspose.Cells, Version=4.7.1.19, Culture=neutral, PublicKeyToken=716fcc553a201e56’ because it contains an
object field at offset 4 that is incorrectly aligned or overlapped by a non-object field.

The message indicates that an object field is not properly aligned. I would guess that your code obfuscator is not properly aligning all of the assembly attributes. 64-bit programs require different alignments than 32-bit programs. This explains why this code work on 32-bit Windows, but does not work on 64-bit Windows. I would guess that your assembly works fine on 64-bit Windows BEFORE the code obfuscation and breaks after the code obfuscation.

My OS is Windows Server 2003 x64 + SP2. I would expect that Windows XP x64 + SP2 would behave in the same way, but I have not test that OS.

Hi,

Thank you for sharing the details regarding your issue.

We will get back to you soon.

Thank You & Best Regards,

Hi,

Could you try the attached version and let us know if the issue is resolved now.

Thank you.

<span style=“font-size:11.0pt;font-family:“Calibri”,“sans-serif”;
mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:
“Times New Roman”;color:#1F497D;mso-ansi-language:EN-US;mso-fareast-language:
EN-US;mso-bidi-language:AR-SA”>Thank you. That assembly works great on
x64 and x86