web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

[External dll] Using CreateEntryFromFile(File) from SharpZipLib gives EnvironmentPermission Error

(0) ShareShare
ReportReport
Posted on by 217

Hi,

I try to create a tar.gz archive with a dotnet dll put in my server folder.

I use SharpZipLib to do that. Here is my code (where I get the issue).

FOR i := 0 TO FilesInDirectory.Length() -1 DO BEGIN
  FileInfo := FilesInDirectory.GetValue(i);
  Entry := Entry.CreateEntryFromFile(FileInfo.FullName);
  TarArchive.WriteEntry(Entry, TRUE);
END;

Entry is a dotnet variable from SharpZipLib :
ICSharpCode.SharpZipLib.Tar.TarEntry.'ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73'

When I run my code, it gives me this error message:

I've tries to add this line:

EnvironmentPersmission := EnvironmentPersmission.EnvironmentPermission(PermissionState.Unrestricted);

But I still get the same error.

Does anyone already has this kind of issue and can help me to resolve it ?

Thanks ! :)

*This post is locked for comments

I have the same question (0)
  • jdecottignies Profile Picture
    217 on at

    Here is the error message, bug when publishing it in the first one*

  • jdecottignies Profile Picture
    217 on at

    Microsoft Dynamics NAV

    ---------------------------

    A call to ICSharpCode.SharpZipLib.Tar.TarEntry.CreateEntryFromFile failed with this message:

    Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    ---------------------------

    OK

    ---------------------------

  • Verified answer
    Hannes Holst Profile Picture
    5,767 on at

    Hi,

    Could be that you try to create the file on Client-Side but the DotNet is executed on the ServiceTier.

    Either select a file destination for which the ServiceTier-User has access to (e.g. a directory on the ServiceTier-Server) or configure the DotNet-variables to run on the client-side (go into variable properties and select RunOnClient = Yes). When running on client-side, the DotNet-Assemblies are using the local user of the client-machine, which means you should have normally the right permissions to create a file in a given directory of the local PC.

  • jdecottignies Profile Picture
    217 on at

    Thank you for you quick help ! This was the problem, thank you :)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans