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)

AIF service: Cannot implicitly convert type

(0) ShareShare
ReportReport
Posted on by 535

I'm coming to a stand still on how I should proceed to get the data to my windows service. I have created the services and service groups for the port. Along with the classes and methods to tie in(below). I'm getting an error on the proxy (returnMessage = proxy.GetLabelData(LabelContext2);)  

Error 1 Cannot implicitly convert type 'SMCLabelAndResendPrintSvc.LoftwareLabelService.LLContract[]' to 'string' C:\""\""\SMCLabelAndResendPrintSvc\SMCLabelAndResendPrintSvc\SMCLabelAndResendPrint.cs 81 33 SMCLabelAndResendPrintSvc

[SysEntryPointAttribute(true),
AifCollectionTypeAttribute('return',Types::Class,classStr(LLContract))]
public List GetLabelData()
{
    #define.Description("Windows Label Record Retrievable")
    SMCLabelsLoftware           labelsloftware;
    SMCDefsLoftwareLabelsDtl    LabelsDtl;
    SysDictTable                sysDictTable;
    str                         fieldname;
    int                         i;
    Struct                      finalstruct, labelsStruct = new Struct(Types::String, 'FieldID', Types::AnyType,'Value', Types::AnyType, 'labelname' );
    List                        finallist, labelsList = new List(Types::Class);
    ListEnumerator              listEnum;

    try
    {
        ttsbegin;

                while select labelsloftware where labelsloftware.PrintedStatus == ''
                {
                    sysDictTable = new SysDictTable(tableNum(SMClabelsLoftware));

                    for(i=1;i<= sysDictTable.fieldCnt();i++)
                     {
                         fieldname = SysDictTable.fieldName(sysDictTable.fieldCnt2Id(i));
                         if(SMCDefsLoftwareLabelsDtl::find(labelsloftware.LabelName,SysDictTable.fieldName(sysDictTable.fieldCnt2Id(i))))
                         {
                             labelsStruct.value('FieldID',fieldName);
                             labelsStruct.value('Value',labelsloftware.(sysDictTable.fieldCnt2Id(i)));
                             labelsStruct.value('labelname',labelsloftware.LabelName);

                             //print finalstruct.value('FieldID'),  finalstruct.value('Value'), finalstruct.value('labelname');
                             //pause;

                             labelsStruct.pack();
                             labelslist.addEnd(labelsStruct);
                         }
                     }
                }

        ttscommit;
        return labelsList;
    }
    catch
    {
        error("Error!");
        return labelsList;
    }

}


Windows service Code:

string returnMessage = string.Empty;

            DataSet dataSet;
            //Paging paging = null;

            AifSos.LoftwareLabelInfoServiceClient proxy = new AifSos.LoftwareLabelInfoServiceClient();

            proxy.ClientCredentials.Windows.ClientCredential.UserName = "svc_axbcproxy";   //kmundt
            proxy.ClientCredentials.Windows.ClientCredential.Password = "mc@C0nn3ct";   //sears

            AifSos.CallContext LabelContext2;

            LabelContext2 = new AifSos.CallContext();

            try
            {
                returnMessage = proxy.GetLabelData(LabelContext2);

}
            catch (Exception e)
            {

                //strErrorMessage = "";
                LogEvent("Error getLabelInfo - (LabelService) did not run correctly: " + e.Message + " - " + System.DateTime.UtcNow + "\n" + e.InnerException + e.Source.ToString() + "\n " + e.StackTrace.ToString() + " " + e.Data + "\n");
                throw;
            }

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    The error says that the service returns an array of LLContract objects and you can't assign such an array to a string variable. Change the type of returnMessage from string to SMCLabelAndResendPrintSvc.LoftwareLabelService.LLContract[].

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