XLANGPart.LoadFrom(stream) failing - UnauthorizedAccessException



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

  • Re: XLANGPart.LoadFrom(stream) failing - UnauthorizedAccessException
    ... A MemoryStream will always return this exception ... My component then generates a PDF stream using Crystal Reports, ... ReportDocument report = new ReportDocument; ...
    (microsoft.public.biztalk.general)
  • Re: Problem with CRVIEWER
    ... I can open the database because to login into the application I need to ... verify the user in the database and when I select the report option I bring ... line the report is failing, I never get an error, if ends the load procedure ... An unhandled exception occurred during the execution of the ...
    (microsoft.public.vb.crystal)
  • Re: using serialization to serialize my objects to hard drive
    ... The Load and Save functions are inconsistent in that the save throws ... As I said before if the BinaryFormatter throws an exception the ... stream will be left open, use an additional try catch finally or move ... Prev by Date: ...
    (microsoft.public.dotnet.csharp.general)
  • Re: Can a generic Crystal report be dynamically instantied at runtime?
    ... ReportDocument.Loaddoes not take a stream ... so you can't load the report from anywhere but a file. ... So deploying it on a shared drive seems pretty much your only option. ...
    (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)