Hi,
I'm writing some code in C# to talk to the AOS and get some information about AOT objects. I’ve been using Peter Villadsen’s examples that he uploaded to GitHub for reference and he uses the following method to get labels:
/// <summary>
/// Resolve the given label to the text it represents in the default language. If a non
/// label is passed, that text is returned unchanged.
/// </summary>
/// <param name="label">The label to look up.</param>
/// <returns>The text for the label resolved to the current language.</returns>
private string ResolveLabel(string label)
{
var labelResolver = CoreUtility.ServiceProvider.GetService(typeof(Microsoft.Dynamics.Framework.Tools.Integration.Interfaces.ILabelResolver)) as Microsoft.Dynamics.Framework.Tools.Integration.Interfaces.ILabelResolver;
if (labelResolver != null)
{
return labelResolver.GetLabelText(label);
}
return label;
}
I am trying to do the same and my code is similar:
private String getLabel(string _labelID)
{
String ret;
ret = "";
if (_labelID != "")
{
var labelResolver = CoreUtility.ServiceProvider.GetService(typeof(Microsoft.Dynamics.Framework.Tools.Integration.Interfaces.ILabelResolver)) as Microsoft.Dynamics.Framework.Tools.Integration.Interfaces.ILabelResolver;
if (labelResolver != null)
{
ret = labelResolver.GetLabelText(_labelID);
}
}
return ret;
In my test project I’ve been able to pick up a label ID from a table but when I try to resolve I get the an NullReferenceException error on the line where I create my variable.
So clearly its not getting the object from the AOS, although I can talk to the AOS and I can get AX classes and tables etc. Now I have seen some changes in the references in C# that are not in his code so I’m not sure if its because we are using different version.
*This post is locked for comments
I have the same question (0)