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 AX (Archived)

Class not exists when using business connector.

(0) ShareShare
ReportReport
Posted on by

I just created a new class + full cil + adding the following syntax:

using MIL = Microsoft.Dynamics.AX.ManagedInterop;
...
public static MIL.Session axSession = null;
if (MIL.Session.Current == null
                        || !MIL.Session.Current.isLoggedOn())
                            try
                            {
                                // Login to Microsoft Dynamics Ax.
                                axSession = new MIL.Session();
                                axSession.Logon(null, null, null, null);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine("An error occurred in object creation or Axapta logon: {0}", e.Message);
                                return null;
                            }

MyClass c = new MyClass(); // here I got an exception: The operation failed. The class MyClass does not exist.


The class was drug and drop into the the class library - new class which I want to use.

The proxy is used in several environments on same server (maybe this is the problem, but it is just a guess).

There is a proxy account imported as a user.

What may be the problem that the class isn't known when running (I succeeded log on with proxy account)?

Thanks :)

*This post is locked for comments

I have the same question (0)
  • Bilal Issa Profile Picture
    4,370 on at

    Hi,

    can you please try to use logonAs method where you can specify the object server and configuration to make sure you point to the correct environment .

    Regards,

    Bilal

  • Community Member Profile Picture
    on at

    Ok.

    I did some check, and found that, when doing axSession.Logon(null, null, null, null), I see that there is logon  not to the expected environment.

    I want to logon to current running environment.

    1. Isn't any global axsession, I can refer to, and not doing again and again axSession.Logon(null, null, null, null)? - just have the current login with business logic method.

    2. logonAs - I need to know the password. It is hard coded, and I want to prevent some "hard coded", because that may be changed.

    Thanks :)

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

    No, Business Connector can't automatically figure out the configuration for "currently running environment" and use it. You either specify where to connect in parameters, or use the default configuration if you leave parameters empty (as you did).

    I don't understand what you mean by your second point.

  • Community Member Profile Picture
    on at

    The main goal is to run SSRS report, and than run business logic function.

    I don't know for sure that axsession.logon(null, null, null, null) run the default environment declared, and not exactly the environment that is called from AX. If so, than default configuration shall be declared on each client. What if I don't want to declare BC connector for each client by AxCliCfg.exe?

     

    Bilal Lisa said that logonAs is the solution, so I have mentioned LogonAs at second point - one of the parameters is System.Net.NetworkCredential and System.Net.NetworkCredential takes two arguments: user+password, so I think it is complicated to have a solution for passing parameters to logonAs, when I have several environment.

    For point 1 - I think it is the easiest way, since I need to pass company+language+object server+configuration (to axsession.logon function), and that I can get from X++.

    So, is there any way getting from ax the object server+configuration values (axsession.logon ... 3rd and 4th parameters)? (Directly from C# is the preferred wat, when using SSRS, but if there is not any way X++ may be also a solution).

    Thanks :)

    Thanks :)

  • Suggested answer
    Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    Aha, so you're using MIL in a report, not the Business Connector. In that case, I think you could use types in Microsoft.Dynamics.Framework.Reports namespace.

    Nevertheless you might want to explain to us what you're trying to achieve; you have a tendency to choose wrong means.

  • Community Member Profile Picture
    on at

    OK.

    I presume I can add new parameter as the parameter: AX_CompanyName, and add it Default value as:

    =Microsoft.Dynamics.Framework.Reports.BuiltInMethods.GetUserCompany(Parameters!AX_UserContext.Value)

    but the above is for getting the company-name.

    How can I get the server+configuration values (axsession.logon 3rd and 4th parameters), and shall I put the configuration value, or the server name is enough.

    I have tried adding manually in code as the server name in: dministration | Setup | Business intelligence | Reporting services | Report Server, but I don't think this is the correct syntax, since logon had not been succeeded.

    Thanks :)

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

    What are you doing? Why do you want to create a new session? What configuration are you looking for?

  • Community Member Profile Picture
    on at

    In SSRS, I am have Business Logic, and want to call a method from AX.

    I need to call the method on the same environment that I run the report.

    As I have mentioned on the first post on this thread, on line 10 - axSession.Logon(null, null, null, null);

    I need to pass parameters to axSesson.logon function.

    1st is company which is obvious as parameter: AX_CompanyName,

    2nd is language, which is also obvious as parameter: AX_ReneringCulture.

    3rd parameter - object server. I don't know what to put here.

    4th parameter - configuration. I don't know what to put here or whether necessary.

    I have seen that AX_CompanyName parameter has function behind on default value property of that parameter: =Microsoft.Dynamics.Framework.Reports.BuiltInMethods.GetUserCompany(Parameters!AX_UserContext.Value)

    Please, help me: What shall I put on 3rd+4th parameters of axSession.logon function, and is 4th parameter necessary, since I think the environment is enough?

    If there is no way from SSRS (which is better) to add parameters for 3rd+4th of axSession.logon function, passing parameter from AX is also applicable. 

    Thanks :)

  • Suggested answer
    Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    As far as I can say from your brief description, you shouldn't use Logon() at all, therefore you're spending time with a completely wrong problem. Forget about Logon().

    I thought you would tell us what functionality you're trying to implement, instead of details of the technical solution which you've already chosen and which is clearly wrong in some parts. You see that you're digging deep in technical details of a wrong component, because you lost track of the bigger picture. Maybe you shouldn't be doing any callback to AX at all (e.g. if you want to call AX from a data method) and the solution is in using better architecture instead of struggling with callbacks. Maybe it's all right for your specific case. We can't say because you didn't tell us enough.

    In general (without knowing what exactly you're trying to do), the recommended way is using a custom service. Implement a service as usual and the create a service client by calling Microsoft.Dynamics.Framework.Reports.AxServiceManagement.CreateServiceClient().

    If you want to use the old, deprecated API for some reason, call Microsoft.Dynamics.Framework.Reports.SessionManager.GetSession(). But it's not recommended.

  • Bilal Issa Profile Picture
    4,370 on at

    Hi Eitan,

    the configuration parameter should be the path of AX configuration file, I hope that helps I prefer to use it to make sure you are pointing to the right environment.

    Regards,

    Bilal

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 AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans