Issue while using aspose.cell in 64 bit machine

Hi Team,

We are facing some strange issue while using aspose.cell on 64 bit machine. At the time of file creating the following code is failing:

using Aspose.Cells;
using NUnit.Framework;

[TestFixture]
public class Useless
{
[Test]
public void VerySimpleTest()
{
new Workbook().Save(@"C:\NewFile.xls"); // Error mentioned below.
}
}

The above code is passing in 32 bit with version: 5.3.1.0, 7.0.0.0 & 7.0.3.0. While it is passing in 64 bit maching only with version 5.3.1.0.

The error is:

System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=Aspose.Cells
StackTrace:
at 䉍.䊗.䊣(String ࣦ, Int32 Ắ, FontStyle ܍)
at 䉍.䊗.䊤(Font 㪷, Single ㍡, ArrayList 䊏, Int32& 䊥, Int32& 䊦, SizeF& 䊞, Single& 䊧)
at 䉍.䊗..ctor(ArrayList dataFormatRuns, Single cellWidthPixel, TextAlignmentType hAlignment, ㎚ cellInfo, Double[] scale)
at 䉍.䊃..ctor(ArrayList dataFormatRuns, ㎚ cellInfo, Single WidthPixel, Single HeightPixel, Double[] scale, Boolean isRTL)
at ۬.䉊.䉌(Cell ֡, Int32 ቕ, Int32 థ)
at ۬.䉊.㍟(Graphics យ, Cells ໵, Int32 ֻ, Int32 ּ, Int32 ־, Int32 ֿ, AutoFitterOptions Ӥ)
at ۬.䉊.㍛(Cells ໵, Int32 ֻ, Int32 ּ, Int32 ־, Int32 ֿ, AutoFitterOptions Ӥ)
at Aspose.Cells.Worksheet.AutoFitRow(Int32 startRow, Int32 endRow, Int32 startColumn, Int32 endColumn)
at Aspose.Cells.Worksheet.AutoFitRow(Int32 rowIndex)
at ۬.۫.ܴ(Worksheet Ԛ)
at ࡚.厂.㋰(WorksheetCollection ۰)
at ࡚.厂.⺪()
at ࡚.厂.آ()
at ࡚.卿.厀(Workbook ௱, Stream ԓ, FileFormatType 厁)
at Aspose.Cells.Workbook.Save(Stream stream, FileFormatType fileFormatType)
at Aspose.Cells.Workbook.Save(String fileName, FileFormatType fileFormatType)
at Aspose.Cells.Workbook.Save(String fileName, SaveType saveType, FileFormatType fileFormatType, HttpResponse response, Encoding encoding)
at Aspose.Cells.Workbook.Save(String fileName, SaveType saveType, FileFormatType fileFormatType, HttpResponse response)
at AsposeCell.TestAspose.CreateSalesReport(String filename) in C:\AsposeCell\AsposeCell\TestAspose.aspx.cs:line 70
at AsposeCell.TestAspose.BtnCreate_Click(Object sender, EventArgs e) in C:\AsposeCell\AsposeCell\TestAspose.aspx.cs:line 951
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:

Can you help in resolving the issue is asap.

Thanks,
Punit

Hi,

Aspose.Cells is fully compatible with 64bit environments. Please use the Aspose.Cells.dll file in "net2.0" folder (at your installation direcotry), see the topic for your general reference :
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/using-aspose-cells-component-on-32bit-and-64bit-platforms.html

If you still find the issue, create a separate simple project, zip it and post it here to show the issue, we will check it soon.

Also, give us your 64bit machine details, e.g OS, .NET framework, etc.

Thank you.

Hi,

Please find the sample project attached. Just for your information we tested this on 3 machines having 64 bit and faced the same issue.

We are using .net version 2 of aspose. And the machine is running on VS2010 SP1. The machine is Intel Core I5, 2.5 GHZ, OS Windows 7 Enterprise with SP1. For details refer snapshot attached.

Thanks,

Punit

Hi,

Thanks for your files and screenshot.

We were not able to find your issue on 64-bit machine at our end but we will investigate this issue further.

We have logged this issue in our database with the issue id: CELLSNET-40138.

Once, there is some update for you, we will let you know asap.

Hi,


After testing your issue on your mentioned environment, we could not find this issue on 64-bit machine. We tested it on the same environment as yours. It looks very strange to us as you are finding this issue on your end. Our hundreds of ours are using our product on their diverse 64-bit env. without any problem. By the way do you have installed Arial font on your dir/drive, e.g in C:\Windows\Fontws or in C:\Windows\Fonts?

Thank you.

Hi Amjad,

I checked for the font and found the font is already present on my/other machine. Can you please help me in resolving the above issue asap as we want to purchase the product once we complete the POC in next week.

We can schedule a call or can have a web sharing session if that suits you.

Thanks in advance,
Punit

Hi,


Now that is strange as we still could not find the issue on your mentioned environment.
Anyways, we have logged it with your issue. We will further investigate it soon.

By the way, could you try to test on some other 64-bit/32-bit machines if it works fine.

Thank you.

hi ,

Would you pleaes try followig code in web program to test if there's issue with system permission.

internal void AskClient()
{
string windowsDirectory = Path.GetDirectoryName(Environment.SystemDirectory);
string fontsDirectory = Path.Combine(windowsDirectory, "Fonts");
using (RegistryKey fontsKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", false))
{
if (fontsKey == null)
return;
string[] ttfFonts = fontsKey.GetValueNames();
foreach (string ttf in ttfFonts)
{
string filename = Path.Combine(fontsDirectory, (string)fontsKey.GetValue(ttf));
FileStream fs = new FileStream(filename, FileMode.Open);
fs.Close();
}
}
}

Hi fisher,

I ran the code provided by you but I am getting error on this line:

string[] ttfFonts = fontsKey.GetValueNames();

SubkeyCount=0
ValueCount=334

Error: IOException was unhandeled by user.

Please let me know if you want me to test any other thing. I will try to test the code on another 64 bit machine as well.

Note: I wanted to mention that on this machine ver 7.0.0.0 runtime version: v2.0.50727 is running perfectly fine.


Thanks,

Punit

Hi,

It seems that subkey in “SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts” is occupied by other process .

We ask you to check the accessibility of this registry.

Then we also ask you to try to set CellsHelper.FontDir to x:\windows\fonts where system fonts are installed.

Note: x means you windows drive. So if your Windows in C: drive, the above path will be c:\windows\fonts

Hi,

We investigated the issue and found the issue is cause of the way you are loading registry data for 64 bit machine. After modifying the way you are loading the font key data the code passed sucessfully. The modified code is:

using (RegistryKey fontsKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64).OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", false))

Note: The machine that we are using has more then one user profile and they have full machine access. Also the old code is looking at the hive key "HKEY_CURRENT_USER" in place of "HKEY_LOCAL_MACHINE" which is causing the issue as the font is not present in "HKEY_CURRENT_USER". Please refer the complete code that is passing now.

[TestMethod]
public void TestMethod1()
{
string fontsDirectory = Path.Combine(Path.GetDirectoryName(Environment.SystemDirectory), "Fonts");

using (RegistryKey fontsKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64).OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", false))
//using (RegistryKey fontsKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\fonts", false))
{
if (fontsKey == null)
return;
string[] ttfFonts = fontsKey.GetValueNames();
foreach (string ttf in ttfFonts)
{
string filename = Path.Combine(fontsDirectory, (string)fontsKey.GetValue(ttf));
FileStream fs = new FileStream(filename, FileMode.Open);
fs.Close();
}
}
}

Please let me know if you need any other information from me.

Thanks,

Punit

Hi,

We cannot use your code you provided, that the api is only used in .net 4.0.
So, we recommend you to kindly use CellsHelper.FontDir to set the fonts directory/path, that will surely fix your issue.

Thank you.

Hi Team,

Thanks for resolving the issue.

Now we are good to go for purchasing the product.

Punit

Hi,


We had the same issue on a customers computer. (We’re unable to reproduce it ourself), and the trick with setting the fonts directory works.

Is this issue fixed in a later version of aspose, or do we have to keep the hack with setting the fonts directory ourself?

cheers

Hi,

Thanks for your posting and using Aspose.Cells.

Well, it is necessary to set font directory using CellsHelper.FontDir to resolve this issue. Sometimes, things can go right without setting font directory but we recommend to set it before using any other API to get rid of such issues later on.

You can also download and try the latest version Aspose.Cells
for .NET v7.5.2
to see if it can work fine without setting the font directory.