P.S.
Make sure to close the FileStream asap. The following is an effecient
and safe practice to do this:
using(FileStream oFileStream = new FileStream("<gifname>", ...))
{
...
}
At the end of the using code block the Dispose method will be invoked
and clean up file handle you have open.
--
Scott
http://www.OdeToCode.com/blogs/scott/ [quoted text, click to view] On 23 Oct 2004 01:05:25 -0700, tommytan25@yahoo.com (CCC) wrote:
>Hi,
>
>After reading an article on
>htttp://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=2b9ec7af-94ba-471f-afa6-4e6e852af505&sloc=en-us,
>I created a simple custome assembly with codes like below to test it
>out:
>===========================================================================
>using System;
>using System.IO;
>
>namespace RSCustomAssembly
>{
> /// <summary>
> /// Summary description for RSCustomAssembly.
> /// </summary>
> public class Charts
> {
> public Charts()
> {
> //
> // TODO: Add constructor logic here
> //
> }
>
> public static string HelloWorld()
> {
> return "Hello World!";
> }
>
> public static byte[] TestPicture()
> {
> FileStream oFileStream = new
>FileStream(@"D:\logo.gif",FileMode.Open, FileAccess.Read);
> byte[] result = new byte[oFileStream.Length];
> oFileStream.Position = 0;
> oFileStream.Write (result, 0, (int)oFileStream.Length);
> return result;
> }
> }
>}
>
>===========================================================================
>
>Then, I created an image named "image1" in my report template with to
>follow properties:
>
>Image Type = Database
>Image MIME Type = image/gif
>Value = RSCustomAssembly.Charts.TestPicture()
>
>When preview the report, the image was not loaded. Checking the output
>pane of VS.NET it has 2 warning message saying:
>The value expression for the image ‘image1' contains an error: Stream
>does not support writing.
>The value expression for the image ‘image1' did not evaluate to an
>image.
>
>can any expert help me and see what is wrong? Instead of rendering the
>image, using HelloWorld method did return the exact text in a textbox
>and I'm just wonder why the image function just don't work.
>
>I need this to run so to change my report to improve the performance
>of the RS. Please help, thanks!
>
>CCC