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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

ClrObject static method invocation error

(0) ShareShare
ReportReport
Posted on by

Hi everyone.

i have to create a file with the payment's transactions of many clients that will be uploaded to a bank, and in case of an error delete the file.

i've done some investigation to achieve ths porpuse and after setting the TextIo Object that modifies the file is set to null, and ask for the necessary permissions,(which are granted.) i check the the filename status(WinApi::statusblocked) and it keeps true so doesn't let me delete the file throwing a ClrObject error.

am i doing somiething wrong? is there another way to unlock the file for edition?

mi code is the next, both methods are from a VendOutPaym Derived Class

GeneratePaymentsLines:

//some stuffs

if(error)

{

file = null;

VendOutPaymDerivedClass::Deletefile(filename);

throw error(@"")

FileIoPermission FileIoPermission;

//more stuffs

deleteFile:

static client void deleteFile(Filename _filename)

{

FileIoPermission FileIoPermission;

try

{

FileIoPermission = new set(Types::Class);

FileIoPermission.add(new InteropPermission(interopKind::ClrInterop));

FileIoPermission.add(new fileIOPermission(_filename,'rw'));

codeAccessPermission::assertMultiple(FileIoPermission);

print(WinApi::fileLocked(_filename));

WinApi::deleteFile(_filename);

info('file was not maked');

}

catch

{

warning('incomplete file');

 }

}

i override the deletemethod to make sure the delete run on client's side, since "filename" was a server variable on generatepaymentlines method, hopying it would help but the filename status still es blocked

hope i made myself clear.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Chandra Wijaya Setiawan Profile Picture
    1,145 on at

    Try to put CodeAccessPermission.RevertAssert befire deletion

  • Community Member Profile Picture
    on at

    already tried, "filename" is still blocked

  • Chandra Wijaya Setiawan Profile Picture
    1,145 on at

    perhaps take over the file handler then set it to null in the static method

    FileIoPermission = new set(Types::Class);

    FileIoPermission.add(new InteropPermission(interopKind::ClrInterop));

    FileIoPermission.add(new fileIOPermission(_filename,'rw'));

    codeAccessPermission::assertMultiple(FileIoPermission);

    file = new commatextio(_filename,'rw');

    file  = null;

    print(WinApi::fileLocked(_filename));

    WinApi::deleteFile(_filename);

    info('file was not maked');

  • Community Member Profile Picture
    on at

    thanks but this didn't solve the issue either. is there other form to release the file?

  • Chandra Wijaya Setiawan Profile Picture
    1,145 on at

    Not really but could you try to remove static keyword

    Static method will create new  instance class instance and OS will consider it to be different user session

    If you have concern the code will run on server you can generate the file to UNC shared drive \\server\folder\filename.txt so it can be recognized by server or client

    And perhaps you need to change to winapiserver.deletefile()

    Another question which method generate the file?Is it created on client or server?

    File = null which is basically file.close() should be placed in same method of file creation so it is within same class session

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 39

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans