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)

Failed to Initialize Business Connector

(0) ShareShare
ReportReport
Posted on by

Hi,

I am using Ax4 and Visual studio 2010 for Business connector.

I have create a class in ax and a static method.

as I run the business connector class in visual studio am getting the below error . Please let me know what is going wrong :

BcError.JPG

Below is my Business Connector Class:

using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Drawing;
//using System.Threading.Tasks;
using Bcn = Microsoft.Dynamics.BusinessConnectorNet;

namespace GenerateQuotation
{
    class GenerateQuote
    {
         System.Net.NetworkCredential nc = new System.Net.NetworkCredential("karad","Pioneer1");
        string sRes;
        public string sID = "QJ-00098483";
        string strUserName = "karad";
        public string sAxConfig;
        public string sComp;
        public string sLang;
        public string sObjSer;
        //[STAThread]
        //static void Main(string[] args)

        // Create the .NET Business Connector objects.

        public string connect()
        {
           Bcn.Axapta ax;

           ax = new Bcn.Axapta();
           sAxConfig = @"C:\Users\karya-radhikak\Documents\Visual Studio 2010\Projects\GenerateQuotation\GenerateQuotation\bin\Debug\app.config";
            sComp = "pmf";
            sLang = "USD";
            sObjSer = "PMFCGRB23:95";
            object o;
            bool b;
          //  ax = new Axapta();
            try
            {
                // Login to Microsoft Dynamics Ax.

            //ax.LogonAs(strUserName,"pioneermetal.net", "", nc, "", "", "", "");
                ax.Logon(sComp, sLang, sObjSer, sAxConfig);
               // ax.Logon(null, null, null, null);
            }
            catch (Exception e)
            {
                MessageBox.Show("Exception Caught :" + e);
                //or Axapta logon: {0}", e.Message);
                // return e;
            }

            // Logon was successful.
            try
            {
                // Call a static class method.
                // In this example, call SysLabel::labelId2String2 
                // to determine the label string for a particular label ID.
                //   o = ax.CallStaticClassMethod("AXBusinessConnector","callBusinessLogic", sID);
                //Console.WriteLine("The Student Name for {0} is {1}.",
                //sID, o.ToString());
                //return o.ToString();
                sRes = ax.CallStaticClassMethod("pmf_GenerateQuotationRpt ", "callBusinessLogic", this.sID).ToString();

                ax.Logoff();

            }
            catch (Exception e)
            {
                // Console.WriteLine("An error has been encountered during 
                //   CallStaticClassMethod: {0}", e.Message);
                b = ax.Logoff();
                //return;
            }

            // Display the returned string.
            // Console.WriteLine("The label string for {0} is {1}.", 
            // sID, o.ToString());
            return sRes;
            // Log off from Microsoft Dynamics AX.
            b = ax.Logoff();

        }
    }
    }


Please do the needful

Thanks ,

Mania

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Just to add above . Please find the app.config code as below:

    <?xml version="1.0"?>
    <configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
      
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
    </configuration>
    


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
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans