Re: XLANGPart.LoadFrom(stream) failing - UnauthorizedAccessException

Tech-Archive recommends: Speed Up your PC by fixing your registry



A MemoryStream will always return this exception (when GetBuffer is called)
when it is constructed with an existing byte array (which must be what is
happening with your call to Crystal's ExportToStream.)

What I would do is try creating an intermediate MemoryStream that you
allocate and write to yourself (a copy of the content in the original
stream.)

Scott Colestock
www.traceofthought.net



"Sergiy" <bryn@xxxxxxxxxxxxxxxxxx> wrote in message
news:OSXQQEpuGHA.324@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

I am trying to update an XLANGMessage in my custom component. I have an
orchestration that receives message A.
In a construct shape (declared as constructing message B), message A is
then assigned to message B, and message B is passed from a message
assignment shape into my component as a parameter to a method.
My component then generates a PDF stream using Crystal Reports, and then
attempts to load the XLANGMessage's 1st data part with the stream
generated by Crystal. This is causing an error (details at bottom of
post).
The error indicates that the GetBuffer method is causing the error. I have
tried wrapping the memory stream in a BufferedStream, but this causes
another exception altogether indicating the Load method is expecting a
MemoryStream to load from.
Does anyone have any ideas what I am doing wrong? Is there any other way
to load the stream into the part's data?

Details of code are:

// Create a crystal report object
ReportDocument report = new ReportDocument();
/// Load report here and bind to data...
// Export report to stream. Actual stream generated by Crystal is a
MemoryStream
Stream reportStream =
report.ExportToStream(ExportFormatType.PortableDocFormat);
// Stream now has data.
// Load data into XLANGMessage part. THIS CAUSES EXCEPTION...
dataMessage[0].LoadFrom(reportStream);

ERROR DETAILS:
====================
Exception thrown from: segment 1, progress 8
Inner exception: MemoryStream's internal buffer cannot be accessed.

Exception type: UnauthorizedAccessException
Source: mscorlib
Target Site: Byte[] GetBuffer()
The following is a stack trace that identifies the location where the
exception occured

at System.IO.MemoryStream.GetBuffer()
at Microsoft.XLANGs.Core.Value..ctor(Stream s)
at Microsoft.XLANGs.Core.Part.GenericLoadFrom(Object source)
at Microsoft.XLANGs.Core.XSDPart.ProtectedLoadFrom(Object source)
at Microsoft.XLANGs.Core.Part.LoadFrom(Object source)
at Microsoft.XLANGs.Core.PartWrapperForUserCode.LoadFrom(Object source)
at
Bryn.BabelTower.BizTalk.Core.Components.ReportGenerator.GenerateReport(XLANGMessage
dataMessage, String reportPath)
at
Bryn.BabelTower.BizTalk.Core.Orchestrations.ReportGenerator.segment1(StopConditions
stopOn)
at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s,
StopConditions stopCond, Exception& exp)



.



Relevant Pages

  • XLANGPart.LoadFrom(stream) failing - UnauthorizedAccessException
    ... My component then generates a PDF stream using Crystal Reports, ... attempts to load the XLANGMessage's 1st data part with the stream generated ... ReportDocument report = new ReportDocument; ... Exception thrown from: segment 1, ...
    (microsoft.public.biztalk.general)
  • Re: HOWTO: Populate a MemoryStream?
    ... > Stream, when you create the StreamReader object, the MemoryStream is still ... > at the end of the Stream. ... >> Catch ex As Exception ... >> TIA ...
    (microsoft.public.dotnet.general)
  • Re: Byte[] to Image
    ... I made the changes you told me, but I still get the same Exception... ... MemoryStream ms = new MemoryStream; ... constructor. ... You also have to *not* use a using statement in this case - as otherwise the stream will be closed automatically. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to read a file into a stream
    ... File.OpenReadwould give you a FileStream ... With the exception of MemoryStream, you don't really really read *into* ... a stream; rather, the stream is a pipe through which you read the file ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Assembly conversion to Pocket Pc format
    ... This exception could be for many reasons. ... HttpWebResponse resp = req.GetResponse; ... Stream respStream = resp.GetResponseStream; ... upload and download files in compact framework. ...
    (microsoft.public.dotnet.framework.compactframework)