ActiveReports for .NET 2.0 Visual Studio .NET 2005 Support

Started by hctrivedi at 11-08-2005 7:04 AM. Topic has 5 replies.

Print Search
Sort Posts:    
   11-08-2005, 7:04 AM
hctrivedi is not online. Last active: 3/8/2006 10:15:38 PM hctrivedi

Not Ranked
Joined on 09-01-2005
Posts 14
LoadLayout closes the stream if application is compiled in .NET 2.0
I am porting our app from .NET 1.1 to .NET 2.0. While testing app in .NET 2.0 I found following problem

try this code with .NET 1.1 and .NET 2.0 (I used RC1)

static void Main(string[] args)
{
    FileStream layoutStream = new FileStream(@"test.rpx", FileMode.Open);
    AR.ActiveReport theReport= new AR.ActiveReport();
    layoutStream.Position = 0;
    theReport.LoadLayout(layoutStream);
    layoutStream.Position = 0; //Raises "ObjectDisposedException: Cannot access a closed file" in .NET 2.0
    layoutStream.Close();
}

While setting position after LoadLayout, app raises ObjectDisposedException if it's compiled in .NET 2.0. But if same code is compiled in .NET 1.1 it works fine.

I have also attached code, test .rpx file and csc command lines in .zip for your ease

Would somebody please help me out in finding the reason and resolution of this problem?

   Report 
   11-08-2005, 7:09 AM
hctrivedi is not online. Last active: 3/8/2006 10:15:38 PM hctrivedi

Not Ranked
Joined on 09-01-2005
Posts 14
Re: LoadLayout closes the stream if application is compiled in .NET 2.0

Attachment: code.zip
Somehow .zip didn't got attached. Tring it out again if you couldn't find .zip with this post also please copy from this Smile


 class="txt4"> static void Main(string[] args)
  {
      FileStream layoutStream = new FileStream(@"test.rpx", FileMode.Open);
      AR.ActiveReport theReport= new AR.ActiveReport();
      layoutStream.Position = 0;
      theReport.LoadLayout(layoutStream);
      layoutStream.Position = 0; //Raises "ObjectDisposedException: Cannot access a closed file" in .NET 2.0
      layoutStream.Close();
  }

 




   Report 
   11-09-2005, 2:36 PM
Trent is not online. Last active: 8/24/2007 7:16:29 PM Trent

Top 10 Posts
Joined on 08-28-2004
Posts 2,623
Re: LoadLayout closes the stream if application is compiled in .NET 2.0

After looking into this it appears that this is a difference between the .NET frameworks.  Previously the XmlReader did not implement the IDisposable interface but in the 2.0 framework they do.  So when we dispose of the reader which we have always done previously a dispose was not being done because it was not implemented.  If the 1.1 .NET framework was updated as well you would see the same exception as you do in the 2.0 framework.  I would recommend not using the fs.position = 0 code and calling just the close should work fine.  Please let me know if any of this is still confusing.

Recommended change:


FileStream layoutStream = new FileStream(@"test.rpx", FileMode.Open);
AR.ActiveReport theReport= new AR.ActiveReport();
layoutStream.Position = 0;
theReport.LoadLayout(layoutStream);
layoutStream.Close();


   Report 
   11-10-2005, 1:03 AM
hctrivedi is not online. Last active: 3/8/2006 10:15:38 PM hctrivedi

Not Ranked
Joined on 09-01-2005
Posts 14
Re: LoadLayout closes the stream if application is compiled in .NET 2.0
Trent,

Thanks for you suggestion.

But the problem is, the code I pasted over here is not production code. We are using MemoryStream to do this and we do keep them opened even after LoadLayout is got executed and reuse it for future readings and writtings.

I was expecting LoadLayout to work like deserialize the layout and not to close the opened stream.

Are you sure there is no way out of this?

   Report 
   11-10-2005, 1:06 PM
Trent is not online. Last active: 8/24/2007 7:16:29 PM Trent

Top 10 Posts
Joined on 08-28-2004
Posts 2,623
Re: LoadLayout closes the stream if application is compiled in .NET 2.0
We will see if we can have this issue resolved in the next release.
   Report 
   11-11-2005, 12:08 AM
hctrivedi is not online. Last active: 3/8/2006 10:15:38 PM hctrivedi

Not Ranked
Joined on 09-01-2005
Posts 14
Re: LoadLayout closes the stream if application is compiled in .NET 2.0
Thanks, Trend

   Report 
GrapeCity » Forum Archives » ActiveReports f... » Re: LoadLayout closes the stream if application is compiled in .NET 2.0

Privacy Policy | Copyright © 1997-2012 — GrapeCity, inc.
All trademarks mentioned are the property of their respective owners.