Hello,
I would like to get the Label ID from all Layers that contain text entered from form controls.
community.dynamics.com/.../1296437
I am implementing it with reference to the above link,
A compilation error has occurred as follow.
Also, the sample code in this link only allows you to get the LabelID for the specified Layer.
Any sample code or any advice would be greatly appreciated.
Your question suggests that you didn't add the reference, which explains why your code can't compile. The compiler can't load the assembly containing objects that you're using in your code.
Open you project, right-click References node, choose Add Reference... and add AOSKernel.dll from the bin folder of your modelstore (e.g. k:\AosService\PackagesLocalDirectory\bin\).
The using statement is declared as follows. Declaring a Kernel gives an error again.
using Microsoft.Dynamics.AX.Metadata.Kernel; using Microsoft.Dynamics.AX.Metadata.MetaModel; using Microsoft.Dynamics.AX.Metadata.Storage; using Microsoft.Dynamics.AX.Metadata.Storage.Runtime; using Microsoft.Dynamics.AX.Metadata.Core.MetaModel; using Microsoft.Dynamics.Ax.Xpp.MetadataSupport; using Microsoft.Dynamics.ApplicationPlatform.Environment; public static class TestGetLabelIdClass { ////// Class entry point. The system will call this method when a designated menu /// is selected or when execution starts and this class is set as the startup class. /// /// The specified arguments. public static void main(Args _args) { var environment = Microsoft.Dynamics.ApplicationPlatform.Environment.EnvironmentFactory.GetApplicationEnvironment(); var runtimeConfiguration = new RuntimeProviderConfiguration(environment.Aos.PackageDirectory); var metadataProvider = new MetadataProviderFactory().CreateRuntimeProviderWithExtensions(runtimeConfiguration); //IMetaModelService service = new MetaModelServiceFactory().Create(Accessor::MetadataProvider); var labelFiles = metadataProvider.GetLabelFileNames(); Set prefixes = new Set(Types::String); var enumerator = labelFiles.GetEnumerator(); while (enumerator.MoveNext()) { int positionOf_ = strFind(enumerator.Current, '_', 1, strLen(enumerator.Current)); str prefix = subStr(enumerator.Current, 1, positionOf_ - 1); prefixes.add(prefix); } } }
Could you tell me how to add a reference?
Thanks.
I see several bugs:
I think you gave us wrong information about which thread you tried to follow. I believe you meant . Didn't you forget to add a reference to AOSKernel.dll?
If you have any helpful blogs or information about how to get the AOT label file list, please share it.
Hello Martin,
Thanks for your info.
I fixed it as below, but the reference error still occurs.
Can you share how to add reference?
using Microsoft.Dynamics.AX.Metadata.MetaModel; using Microsoft.Dynamics.AX.Metadata.Storage; using Microsoft.Dynamics.AX.Metadata.Storage.Runtime; using Microsoft.Dynamics.AX.Metadata.Core.MetaModel; var environment = Microsoft.Dynamics.ApplicationPlatform.Environment.EnvironmentFactory.GetApplicationEnvironment(); var runtimeConfiguration = new RuntimeProviderConfiguration(environment.Aos.PackageDirectory); var metadataProvider = new MetadataProviderFactory().CreateRuntimeProviderWithExtensions(runtimeConfiguration); //IMetaModelService service = new MetaModelServiceFactory().Create(Accessor::MetadataProvider); var labelFiles = metadataProvider.GetLabelFileNames(); Set prefixes = new Set(Types::String); var enumerator = labelFiles.GetEnumerator(); while (enumerator.MoveNext()) { int positionOf_ = strFind(enumerator.Current, '_', 1, strLen(enumerator.Current)); str prefix = subStr(enumerator.Current, 1, positionOf_ - 1); prefixes.add(prefix); }
Do it make a project with .Net and refer to it from the X project?
The first error says that you're referring to Microsoft.Dynamics.AX.Metadata.Kernel for some reason, but you haven't added a reference to an assembly containing this namespace.
Regarding Accessor, maybe you can get rid of it completely. I don't know why you're using your current approach, but what about switching to new MetadataProviderFactory().CreateRuntimeProviderWithExtensions()?
Hi
I created it with reference to the above link to get the label file. As a result, the above error occurs.
using Microsoft.Dynamics.AX.Metadata.Kernel; using Microsoft.Dynamics.AX.Metadata.Service; Public static class TestGetLabelIdClass { public static TestLabelIdTmpTable getLabelIdInfo(Str4095 _labelTxt) { TestLabelIdTmpTable testLabelIdTmpTable; IMetaModelService service = new MetaModelServiceFactory().Create(Accessor::MetadataProvider); var labelFiles = service.GetLabelFileNames(); Set prefixes = new Set(Types::String); var enumerator = labelFiles.GetEnumerator(); while (enumerator.MoveNext()) { int positionOf_ = strFind(enumerator.Current, '_', 1, strLen(enumerator.Current)); str prefix = subStr(enumerator.Current, 1, positionOf_ - 1); prefixes.add(prefix); } return testLabelIdTmpTable; } }
First, I am trying to get all label file list.
Hi Akshi,
You might have forgotten a reference, like suggested by the error. Instead asking coding, maybe it would be better if you share the class you created. You can use the rich formatting and then Insert > Code to paste the code and share what you have done so far.
André Arnaud de Cal...
291,971
Super User 2025 Season 1
Martin Dráb
230,846
Most Valuable Professional
nmaenpaa
101,156