Error Opening File

Hi there,

I’m making some tests with Aspose.Tasks and I’m receiving a message error, basically my code work on my XP machine but when I upload to the hosting server (its other company) the Aspose.Tasks stop to work and give me a Open file error message this into inner exception.

Request for the permission of type ‘System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ failed

The funny thing is this error only happens when I upload a .MPP file when I upload a .MPX everything works fine.

Any idea about how to fix that?

This is my test code:

try{

string fileName = Request.Files[0].FileName;

string extension = Path.GetExtension(fileName);

byte[] stInput = new byte[(int)Request.Files[0].InputStream.Length];

Request.Files[0].InputStream.Read(stInput, 0, (int)Request.Files[0].InputStream.Length);

MemoryStream st = new MemoryStream(stInput);

MPXFile mpx;

if (extension.ToLower() == ".mpx")

mpx = new MPXFile(st);

else

mpx = new MPPFile(st);

String sTasks = "";

//foreach (Task t in mpx.ChildTasks[0].ChildTasks)

// sTasks += TaskToJSON(t);

Response.Write(sTasks);

}

catch (Exception ex)

{

Response.Write("ERROR: " + ex.Message);

if (ex.InnerException != null)

Response.Write("
ERROR: " + ex.InnerException.Message);

}

Regards

Fabio

Dear Fabio,

Are there any .NET framework(s) differences between two computers? If you have resolved it, then please update the thread.

I couldn't solve it yet; I don’t have much access to live because it’s hosted on digiweb; I already sent some e-mails to then and I didn’t receive any answer so far. I’m wondering if the aspose.dll is trying to read or write some file, it can be causing the error because probably aspose.dll don’t have this permissions for a anonymous user.

I’m going to make some tests this week using Windows 2003 server and try to reproduce this error. If you have any idea about what is going on, please let me know it can be helpful.

Note: I’m using demo license yet, I don’t know if it can make any difference.

Feel free to drop me an e-mail
Regards
Fabio Torres

Hi,

I could reproduce the problem locally, the difference between the computer are the security level, the hosting server are using a medium trust setup and by default the .Net framework is set to full trust.

To reproduce the problem I used one Virtual Machine with Win2003 server and the following article to setup the a medium trust How To: Use Medium Trust in ASP.NET 2.0 | Microsoft Learn ; after this setup I got the same error of the hosting. This is the full error stack.

[SecurityException: Request for the permission of type 'System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]

System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0

System.Security.CodeAccessPermission.Demand() +59

System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp) +60

System.Windows.Forms.Control.CreateHandle() +299

System.Windows.Forms.Control.get_Handle() +118

System.Windows.Forms.Control.CreateHandle() +286

System.Windows.Forms.TextBoxBase.CreateHandle() +55

System.Windows.Forms.RichTextBox.set_Rtf(String value) +97

ӓ.૾.ਅ(MPPFile ৺, ૡ ৽, ଶ ଩, Hashtable ପ) +12622

ӓ.૾.৹(MPPFile ৺, ૡ ৻) +369

Aspose.Tasks.MPPFile.৹(Stream ਔ) +152

I think hard to find a setup solution for that because the hosting as a very rigid policy restrictions.

Regards

Fabio Torres

Hello Fabio,

Currently Aspose.Tasks uses System.Windows.Forms.RichTextBox to process mpp properties with text in rtf format.
It doesn’t work with medium trust level. We will investigate possibility to avoid using it in the next release.