Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Error executing code: TreeNode object not initialized

888 views
Skip to first unread message

Richard

unread,
Jul 27, 2009, 5:23:01 AM7/27/09
to
Hi all,

I am trying to call the updating of the cross-reference througt a business
connector in .NET.

It gives me the Exception: Update cross-reference (w/recompile) Error
executing code: TreeNode object not initialized.
I have had simular problems when calling other methods through a business
connector.
It seems the business connector does not instantiate a client instance with
all credentials and/or objects?

The idea is to run nightly jobs like synchrinise/compile/update
cross-referenses/perform unit test/etc...

I was under the impresion that a business connector "impersonates" a person
loging in to AX, but there seem to some differences?

Anywone know a solution to this problem? (code below)


thanx,
Richard


C# code:

using System;
using Microsoft.Dynamics.BusinessConnectorNet;
using System.Net;
using System.Configuration;
using System.Diagnostics;

namespace AXterminator
{
class Program
{

static void Main(string[] args)
{
try
{
Console.WriteLine("initiating dynamics object");
DateTime dtmStart = DateTime.Now;
Axapta objAxapta = new Axapta();

Console.WriteLine("logon to dynamics");
//logon to AX
objAxapta.Logon(null, null,
ConfigurationSettings.AppSettings["AOS"], null);

Console.WriteLine("running AXTerminator");
//start job
AxaptaObject axTerminator = objAxapta.CreateAxaptaObject(
"AXterminator" );
axTerminator.Call( "run" );

Console.WriteLine("finished");

}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
System.Threading.Thread.Sleep(5000);

}

}
}
}


x++ code:

void crossreferences()
{
int infoLines = infolog.line();
SysInfoLogEnumerator infoLogEnum;
SysInfologMessageStruct infoMessageStruct;
str infoLogMessages = '';
xRefUpdate xRefUpdate = new xRefUpdate();
;

//start updating the cross references
try
{
xRefUpdate::main(new Args(classstr(SysCompileAll)));
m_messageBody += strfmt( "%1 Updating cross references <font
color='green'>succeeded</font> <br/>",time2StrHMS( timenow() ) ) ;
}
catch (Exception::Error)
{
m_Error = true;

infoLogEnum = SysInfoLogEnumerator::newData(infolog.cut(infoLines +
1));
while(infoLogEnum.moveNext())
{
infoMessageStruct =
SysInfologMessageStruct::construct(infoLogEnum.currentMessage());

infoLogMessages += infoMessageStruct.message();
}

m_messageBody += strfmt( "%1 Updating cross references <font
color='red'>failed</font><br/> ex: %2",time2StrHMS( timenow() ) ,
infoLogMessages ) ;
}

}


0 new messages