Personalized Community is here!
Quickly customize your community to find the content you seek.
Have questions on moving to the cloud? Visit the Dynamics 365 Migration Community today! Microsoft’s extensive network of Dynamics AX and Dynamics CRM experts can help.
2022 Release Wave 1 PlanDynamics 365 release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.
2022 release wave 1 plan
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Community | FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | Upcoming TechTalks | All TechTalks
I have pictures in the data base (such as company logo) and I need to pass it to an external application which need the content as a System.Byte array.
How can I achieve such a thing?
I tried to find answer on same question and found static method in ax 2012 SRSFrameworkServiceHelper::convertContainerToBytes() ( same code must be available on 2009 too).
private static System.Byte convertContainerToBytes(container _container)
assemblyBinary = Binary::constructFromContainer(_container);
memStream = assemblyBinary.getMemoryStream();
bytes = memStream.ToArray();
}PS Ofc "_container" it is a blob data type.
I think that getMemoryStream() was added in AX 2012.
AX 2009 probably requires using the Binary class to write bytes one by one.
Yep, you are right, my solution only for ax 2012.
In order to resolve this issue in ax 2009 use BinData class.
binData = new BinData();
bytes = System.Convert::FromBase64String(binData.base64Encode());
Hello, I just want post a solution for similar issue you mentioned.
My original problem was, that the mehod Binary::constructFromContainer(_container) returned this error “Microsoft.Dynamics.Ax.Xpp.InfoException: Error executing code: Binary (object), method constructFromContainer called with invalid parameters.”
I didn’t know, that this method expected a specific format of the given container.
I have solve this error with the code below:
public static System.Byte container2Byte(container value)
System.Byte byteArray = null;
ContainerClass containerClass = new ContainerClass(value);
container blobContainer = containerClass.toBlob();
Binary binary = Binary::constructFromContainer(blobContainer);
using (System.IO.MemoryStream stream = binary.getMemoryStream())
byteArray = stream.ToArray();
And the vice versa way:
public static container byte2Container(System.Byte value)
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(value))
Binary binary = Binary::constructFromMemoryStream(stream);
blobContainer = binary.getContainer();
Maybe this helps others with the same issue which I had.
Business Applications communities