web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
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
    239,022 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
Henrik Nordlöf Profile Picture

Henrik Nordlöf 2 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans