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 :
Finance | Project Operations, Human Resources, ...
Unanswered

some system classes do not work AOS

(0) ShareShare
ReportReport
Posted on by 942

Hello,

I have two classes. IN one of them I have a code:

new InteropPermission(InteropKind::ClrInterop).assert();
    workbook.Close(true,  fullFileName, missing);
    application.Quit();
    CodeAccessPermission::revertAssert();

where workbook is Microsoft.Office.Interop.Excel._Workbook

on the string 

workbook.Close(true,  fullFileName, missing);

It stops the logic processing without giving any errors.

Also I have another class with the code inside:

System.Net.Mail.Attachment

Which gives me an error

CLRObject can't be created.

Both classes work fin on one AOS and do not work on the other so I suppose it's something to do with the either settings of the problematic AOS or some external libraries.

How to troubleshoot this?

Thanks.

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Azat Mukhametzyanov,

    Are you logging in directly into the AOS servers and running these classes? Is Office installed on one the AOS servers and not installed on the other?

  • Martin Dráb Profile Picture
    237,970 Most Valuable Professional on at

    The fact that "It stops the logic processing without giving any errors" suggests that you don't catch CLR exceptions. Add something like this:

    try
    {
    	 ... your code using CLR Interop ...
    }
    catch (Exception::CLRError)
    {
    	throw error(AifUtil::getClrErrorMessage());
    }

    It should give you a better idea about what's going on.

  • dark_knight Profile Picture
    942 on at

    Hello Martin,

    Thanks a lot for your help.

    The strange thing when I launch this class on the client it works. When I launch it on the AOS server it throws an error

    Microsoft Excel can't access the file "\\path to the file\". It can happen due to one of the reasons below:

    - file doesn't exist

    - file is used by other app

    - workbook name is the same as other workbook name currently opened

    I have translated error from Russian.

    I'm sure the file exists and I can open it from the AOS where class doesn't works. It's located on the shared folder on the file server.

    So what is the difference when the class works on the client and on the server? ON the client it works fine, on the server it doesn't

  • Martin Dráb Profile Picture
    237,970 Most Valuable Professional on at

    That you can open it doesn't necessarily mean that the AOS service account can open it too. That's the first thing that I would check.

  • dark_knight Profile Picture
    942 on at

    Thanks. What AOS service account do you mean? Is it domain service account under which AOS service is launched?

  • Martin Dráb Profile Picture
    237,970 Most Valuable Professional on at

    Yes, that's correct. That the process, and the user, which actually executes the code.

  • dark_knight Profile Picture
    942 on at

    I've checked it and I can open the file on the problematic AOS server under this account. Also there is an account connected to business connector and it also has full access to the file.

  • ergun sahin Profile Picture
    8,826 Moderator on at

    See task manager for any open excels

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 456 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans