LinkDemand error

Hello,

I have the following situation : When running a simple console application that uses Aspose.Words.dll i have the following error :

Unhandled Exception: System.Security.SecurityException: That assembly does not a
llow partially trusted callers.
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly a
sm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, Secur
ityAction action, Object demand, IPermission permThatFailed)
at PicConv.PictureConverter.Main(String[] args)
The action that failed was:
LinkDemand
The assembly or AppDomain that failed was:
PicConv, Version=1.4.5424.30122, Culture=neutral, PublicKeyToken=null
The Zone of the assembly that failed was:
Internet
The Url of the assembly that failed was:
file:///H:/PicConv.exe

The OS is Windows Server 2003 and the H drive is a network drive.
When running the same application on Windows 7 on the same network drive it is working.

My application has the [assembly: AllowPartiallyTrustedCallers] in the AssemblyInfo.cs file.

Can you help me please

Hi,

Thanks for your inquiry. This is more like a server configuration issue. Please refer to the following MSDN entry which might help you in resolving this issue.
http://blogs.msdn.com/b/shawnfa/archive/2005/02/04/367390.aspx

Best regards,

Hello back,

Thank you for the response.

I’ve changed my app so that the Aspose.Words.dll is not invoked / loaded. Result : My application is starting and is having a normal flow.

From what i read from the blog :
"
APTCA needs to be applied to the assembly which is being called. So if your code is calling into xxx.dll, then xxx.dll will need APTCA.
"

So my question is : Does Aspose.Words.dll allows partially trusted callers . ? From my test it seems it does not .

My Aspose.Words.dll : version 13.10.0.0
On my server i am having installed only .net 2.0

Hi,

Thanks for your inquiry.

Aspose.Words rendering on a server will typically not work in an ASP.NET application configured to run under the Medium Trust level because it prohibits access to registry and limits access to the file system. To solve this issue you can need to specify your own folders filled with the appropriate fonts as suggested in the following article:
https://docs.aspose.com/words/net/specifying-truetype-fonts-location/

In addition are a few considerations when running on a shared server environment:

All Aspose .NET components are recommended to run with Full Trust permission set. This is because Aspose .NET component sometimes need to access registry settings and files located in places other than the virtual directory e.g. for reading fonts etc. Furthermore, Aspose.NET components are based on core .NET system classes, some of which also require Full Trust permission to run in some cases.

Internet Service Providers hosting multiple applications from different companies mostly enforce Medium Trust security level. In the case of .NET 2.0, such a security level may set the following constraints which could affect the ability of Aspose.Words to perform properly.

  • RegistryPermission is not available. This means you cannot access the registry, which is required to enumerate installed fonts when rendering documents.
  • FileIOPermission is restricted. This means you can only access files in your application’s virtual directory hierarchy. This potentially means fonts cannot be read during export.

For these reasons specified above, it is recommended that Aspose.Words is run on Full Trust permissions.

Best regards,