Hi,
It looks like Authentication Error.In your code, you have loggedon as
Current Windows Account. Is that configured as a user in AX? Try using the
LogonAs() method. I have created a C# code which logs on to AX. See the
code. Its workin fine.
Axapta AX = new Axapta();
try
{
AX.Logon(null, null, null, null);
{
Object AXVersion,AXPOToday,AXPOTodayValue;
Object AXPOLastWeek, AXPOLastWeekValue;
String VendAccountNumberField = "AccountNum";
Object VendAccountNum;
String VendNameField = "Name";
Object VendName;
String VendCurrencyField = "Currency";
Object VendCurrencyNum;
String VendEMailField = "EMail";
Object VendEMailNum;
//Top Purchase Order Group which fetches PO Details
groupAXVersion.Visible = true;
AXVersion = AX.CallStaticClassMethod
("AXPurchStatistics","ApplicationVersion");
textAXVersion.Text = AXVersion.ToString();
AXPOToday = AX.CallStaticClassMethod("AXPurchStatistics",
"PORaisedToday");
textPOGeneratedToday.Text = AXPOToday.ToString();
AXPOTodayValue =
AX.CallStaticClassMethod("AXPurchStatistics",
"PORaisedTodayValue");
textPOGeneratedTodayValue.Text = AXPOTodayValue.ToString
();
AXPOLastWeek =
AX.CallStaticClassMethod("AXPurchStatistics",
"PORaisedLastWeek");
textPOGeneratedLastWeek.Text = AXPOLastWeek.ToString();
AXPOLastWeekValue =
AX.CallStaticClassMethod("AXPurchStatistics",
"PORaisedLastWeekValue");
textPOGeneratedLastWeekValue.Text =
AXPOLastWeekValue.ToString();
//Lists vendors in the List Control
AxaptaRecord AXRecord = AX.CreateAxaptaRecord
("VendTable");
AXRecord.ExecuteStmt("Select * from %1 ");
while (AXRecord.Found)
{
VendAccountNum = AXRecord.get_Field
(VendAccountNumberField);
VendName = AXRecord.get_Field(VendNameField);
VendCurrencyNum = AXRecord.get_Field
(VendCurrencyField);
VendEMailNum = AXRecord.get_Field(VendEMailField);
//Console.WriteLine(VendName);
listVendors.Items.Add(VendAccountNum + " \t"
+VendName+ " - " + VendCurrencyNum + " - " + VendEMailNum);
AXRecord.Next();
}
AXRecord.Dispose();
}
groupPurchaseOrder.Show();
listVendors.Show();
label7.Show();
}
catch (Exception)
{
MessageBox.Show("Login failed due to unknown error");
}
AX.Logoff();
}
Arijit Basu
On 5/9/07, Daniel Selles <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I'm trying to use the Business Connector to execute my class. I've created
> a dll to call on sql 2005 assembly. But my C# class can't access the axapta
> and give the follow error message on the Ax. Logon statment:
>
> My class:
> public void Run(string IdIntranet, string Modulo)
>
> {
>
> Axapta ax;
>
> ax = new Axapta();
>
> ax.Logon(null, null, null, null);
>
> ax.CallStaticClassMethod("GsInsereDiario_FundoFixo", "Run", "IdIntranet",
> "Modulo");
>
> ax.Logoff();
>
> }
>
> Error Message:
> Microsoft.Dynamics.BusinessConnectorNet.LogonFailedException:
>
> at Microsoft.Dynamics.BusinessConnectorNet.Axapta.Logon(BC_PROXY_ACCOUNT_INFO*
> pBCProxyAccountInfo, String company, String language, String objectServer,
> String configuration)
>
> at Microsoft.Dynamics.BusinessConnectorNet.Axapta.Logon(String company,
> String language, String objectServer, String configuration)
>
> at ClassFundoFixo.FundoFixo.Run(String IdIntranet, String Modulo) in
> C:\Documents and Settings\deselles\My Documents\Visual Studio
> 2005\Projects\ClassLibrary1\ClassLibrary1\ClassFundoFixo.cs:line 20
>
> at TesteFundoFixo.Form1.button1_Click(Object sender, EventArgs e) in
> C:\Documents and Settings\deselles\My Documents\Visual Studio
> 2005\Projects\TesteFundoFixo\TesteFundoFixo\Form1.cs:line 25
>
> Thanks in advance,
>
> Daniel Selles | Dynamics Ax Developer | Systems Advisers Group Brazil
>
> Tel: +55 11 3345 5001 Fax: +55 11 5103 0255
> Mob: +55 16 8117 7954 Web: www.systemsadvisers.com/brazil
>
> Systems Advisers Group: We provide global solutions and services around
> Microsoft Dynamics AX, Microsoft Dynamics GP and SunSystems. As one of the
> fastest growing Microsoft Dynamics partners globally we are currently 1 of
> only3 global "power vendors" to Microsoft for Microsoft Dynamics services.
> With experience in global implementations in over 47 countries, the group
> has Centres of Excellence in Asia Pac., Europe and Latin America for
> onshore-offshore capabilities to suit the needs of your organisation.
>
> Offices in: Belgium | Brazil | France | Germany | India | The Netherlands
> | UAE | United Kingdom | USA
>
> For more information visit us at www.systemsadvisers.com <
> http://www.systemsadvisers.com/> or write [EMAIL
> PROTECTED]<info%40systemsadvisers.com><mailto:
> [EMAIL PROTECTED] <info%40systemsadvisers.com>>
>
> [Non-text portions of this message have been removed]
>
>
>
--
Arijit Basu
[Non-text portions of this message have been removed]