Skip to main content

Notifications

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 795

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.

  • ergun sahin Profile Picture
    8,816 Moderator on at
    RE: some system classes do not work AOS

    See task manager for any open excels

  • dark_knight Profile Picture
    795 on at
    RE: some system classes do not work AOS

    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.

  • Martin Dráb Profile Picture
    232,866 Most Valuable Professional on at
    RE: some system classes do not work AOS

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

  • dark_knight Profile Picture
    795 on at
    RE: some system classes do not work AOS

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

  • Martin Dráb Profile Picture
    232,866 Most Valuable Professional on at
    RE: some system classes do not work AOS

    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
    795 on at
    RE: some system classes do not work AOS

    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
    232,866 Most Valuable Professional on at
    RE: some system classes do not work AOS

    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.

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: some system classes do not work AOS

    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?

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,118 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans