Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

pass a .NET-Stream into a container.

727 views
Skip to first unread message

Luegisdorf

unread,
Feb 22, 2008, 8:03:01 AM2/22/08
to
Hi there

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

Axel Kühn

unread,
Feb 22, 2008, 9:29:00 AM2/22/08
to
Hi,

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)

Luegisdorf

unread,
Feb 25, 2008, 6:15:00 AM2/25/08
to
Hi Axel

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

Axel Kühn

unread,
Mar 11, 2008, 2:19:00 PM3/11/08
to
Hi 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.

Luegisdorf

unread,
Mar 12, 2008, 5:38:01 AM3/12/08
to
Hi Alex

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.

0 new messages