I'm currently trying to convert a MemoryStream (contains a bitmap, created
at runtime) into a container (so I can use the bitmap on a report).
Unfortunelly I doesn't found a way how to pass a .NET-Array into a X++-Array
in a fast way. With the current solution I get an error "the array is not
safe" and I loose so much time, so it is not applicable.
Here's the sample code:
container getBinData(System.IO.MemoryStream _inputStream)
{
System.Array netByteArray;
System.Collections.IEnumerator netByteArrayEnumerator;
Array axByteArray;
ComVariant comVariant = new COMVariant();
int i;
container con;
;
netByteArray = _inputStream.ToArray(); // makes a Byte-Array
netByteArrayEnumerator = netByteArray.GetEnumerator();
// that loop is extremly time consuming (event the stream contains
really small picture data of 100 x 100 Pixel)
while (netByteArrayEnumerator.MoveNext())
{
i++;
axByteArray.value(i, netByteArrayEnumerator.get_Current());
}
comVariant.safeArray(axByteArray);
con = comVariant.container(); // that command raises an exception ...
return con;
}
Does anybody have some better Ideas? I would glad to hear about :-)
Best regards
Patrick
Have you ever viewed the article about .NET and x++ Arrays?
http://blogs.msdn.com/x/archive/2007/06/20/using-arrays-with-clr-interop.aspx
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Thank you for the response. The blog you refering confirms what I thought
about. But, may be there are other ways to get a stream into a container?
The method with an array was just my way to solve it. And as you may have
seen, it wouldn't work either, because I get an error when try to assign 'con
= comVariant.container();'.
Other Ideas are welcome again :-)
PS/Off Topic : Did you see the response for SmartStart3000 in MSDynamics.de
Forum to your question concerning sound off feature?
Best regards
Patrick
i played a little bit with .NET Streams and AX. But i found no real
solutions for your problem. Had the same problems....
The only way i found to get something like this working was to:
1. Create the bitmat at runtime with .NET
2. Save the bitmap in a folder with .NET
3. Load/open the file (from step 2) with AX.
Thanks for investigation. The approach to save it to disk, we've also
discovered. Unfortunetaly in our Solution we don't have disk access as needed.
I've opended now a service request by Microsoft. Hope these guys find
something, we've overlooked :)
Will inform here, If I get anwer from there.