Bitmap本身是MarshalByRef的,所以直接返回应该也能工作。
但如果要将所有数据都传导Client端,就需要将Bitmap转换成byte[]数据(Bitmap.LockBits),或者直接传文件。

解决方案 »

  1.   

    //构造代理类的对象
    localhost.CGoodsInfo goodsInfo = new localhost.CGoodsInfo();
    //调用代理类的方法
    DataSet ds = goodsInfo.GetGoodsInfo(textBox1.Text);
    //使用url创建HTTP请求,获取图片
    string url = ds.Tables["DataTable"].Rows[0]["Photo"].ToString();
    HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(url);
    httpRequest.Method = "GET";
    httpRequest.Timeout = 10000;
    HttpWebResponse httpResponse = null;
    try
        {
    //获取HTTP响应
    httpResponse = (HttpWebResponse)httpRequest.GetResponse();
    //使用流构造Bitmap对象,并返回该对象
    pictureBox1.Image = new Bitmap(httpResponse.GetResponseStream());
        }
    catch(Exception exc)
    {
         throw(new Exception("Error retrieving image " + exc.Message));
    }
    finally
    {
    //关闭响应
    if(httpResponse != null)
    httpResponse.Close();
    }
      

  2.   

    Bitmap本身是MarshalByRef的,所以直接返回应该也能工作。
    但如果要将所有数据都传导Client端,就需要将Bitmap转换成byte[]数据(Bitmap.LockBits),或者直接传文件。