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 793

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
    ergun sahin 8,816 Moderator on at
    RE: some system classes do not work AOS

    See task manager for any open excels

  • dark_knight Profile Picture
    dark_knight 793 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
    Martin Dráb 231,403 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
    dark_knight 793 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
    Martin Dráb 231,403 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
    dark_knight 793 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
    Martin Dráb 231,403 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
    Gunjan Bhattachayya 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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,403 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans