Hello. I'm writing a services, like this in the code below:
I have several problems:
- First I wrote a class.
- Empty Class Decleration.
- Just this method getinfo(Args _args).
- Empty main(Args _args) method
I compiled the class with no main method (because static method can act as an service, and got error about the class should have a main method. So I added EMPTY main(Args _args) method.
I cimpiled again and got Warning: MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "Microsoft.Dynamics.AX.ManagedInterop", "x86". This mismatch may cause runtime failures. Please consider changing. I think that's a minor error because I'm use a Remote Desktop Connection to the AX2012R3VMA server (the A server). But I don't know if I need to fix that Warning - if so, I can't get any informaton about that in user forums, all the people say it's just normal Warning because you are on a server on x64.
So, with empty Class Decleration, and empty main method I run the class and No Errors. But no infolog appeard - what do I need to do there to make the infolog appear - call the static method from another class?
Well I though let's try to copy the code to job with the same name "getInfo" and the Job as also with no error. I compiled it and also everything is OK. But when I ran the Job I got this error: Assembly containing type My_NameSpace1.Client is not referenced.
I tried to look on forums and read about hotwapping configuration, compile full or/and incremental CIL, restart AOS and check if the .dll file does exist both in the Client URL and Server URL. But Notice I'm just working on the demo Server.
Client URL: C:\Users\[username]\AppData\Local\Microsoft\Dynamics Ax\VSAssemblies{2F8DEE4C-881F-4848-BA09-72758B1ADA6D}
Server URL: C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin\VSAssemblies
But Notice I see the GUID ID {2F8DEE4C-881F-4848-BA09-72758B1ADA6D} who is not as I have seen it in another forums, but we are two persones who use Remote Desktop Connection to that server through Terminal License.
Here is the code, and notice also that I have check Add reference to the System.ServiceModel.
According to the last error I need to get a reference to My_NameSpace1 - but how can I do that?
Any ideas of soltuions?
static void getInfo(Args _args)
{
// Vars from .NET Project C#
My_NameSpace1.Client client;
My_NameSpace1.GetSetInfo getInfo;
My_NameSpace1.GetSetInfo setInfo;
// System vars,
//I have previosly went to AOT-Reference-Node-Add-Reference and select System.ServiceModel, and choose OK
System.ServiceModel.Description.ServiceEndpoint endpoint;
System.ServiceModel.EndpointAddress endpointAddress;
System.Exception exception;
System.Type type;
;
try
{
type = CLRInterop::getType('My_NameSpace1.client');
client = AifUtil::createServiceClient(type);
endpointAddress = new System.ServiceModel.EndpointAddress("https://test.ausVATagency.au.com/WS/VATService.svc");
// Set endpoint, and endpoint address.
endpoint = client.get_Endpoint();
endpoint.set_Address(endpointAddress);
//setInfo to parameter;
setInfo.set_ID("1234567890");
setInfo.set_version("9600");
setInfo.set_key ("XXXXXXX");
//get info back;
info (strFmt("%1, %2, %3, %4, %5", getInfo.get_ExtensionData(), getInfo.get_Amount(), getInfo.get_ListOfRec(), getInfo.get_Succseed(), getInfo.get_errors()));
}
//Typical error handling.
catch (Exception::CLRError)
{
// Get the .NET Type Exception
exception = CLRInterop::getLastException();
// Go through the inner exceptions
while (exception)
{
// Print the exception to the infolog
info (CLRInterop::getAnyTypeForObject(exception.ToString()));
// Get the inner exception for more details
exception = exception.get_InnerException();
}
}
}