M
Michael
Hi all..
I'm trying to work with DimeAttachment.
Please, take a look at code here - it's very simple to understand.
Server Side:
public class MyDimeService : System.Web.Services.WebService
{
[WebMethod]
public void DoNothing() { }
}
Client Side:
public class ClientClass
{
private void CallServer()
{
MyDimeService svc = new MyDimeService();
DimeAttachment dimeAttach = new DimeAttachment("image/gif",
TypeFormatEnum.MediaType, new MemoryStream());
dimeAttach.Stream = new MemoryStream();
dimeAttach.Stream.Write(new Byte[10], 0, 10);
svc.RequestSoapContext.Attachments.Add(dimeAttach);
svc.DoNothing();
dimeAttach.Stream.Write(new Byte[10], 0, 10);
}
}
What I get, when executing the last command in CallServer() function
is:
An unhandled exception of type 'System.ObjectDisposedException'
occurred in mscorlib.dll
Additional information: Cannot access a closed Stream.
Why do we want to do it this way ?
This is a simplified code, just to show the problem, but in general
what we want is -> pass a big file in chunks from one side to another
(from client to server).
We can, ofcource, for every chunk, create a new stream and write data
of next chunk to it, but in this case we get much much memory usage.
We have to activate garbage collector to free memory, but, this is not
the best way to do things.
There are 2 questions:
1 --> any idea, why do I get this exception ?
2 --> any idea how to solve the general problem ?
Thank you
I'm trying to work with DimeAttachment.
Please, take a look at code here - it's very simple to understand.
Server Side:
public class MyDimeService : System.Web.Services.WebService
{
[WebMethod]
public void DoNothing() { }
}
Client Side:
public class ClientClass
{
private void CallServer()
{
MyDimeService svc = new MyDimeService();
DimeAttachment dimeAttach = new DimeAttachment("image/gif",
TypeFormatEnum.MediaType, new MemoryStream());
dimeAttach.Stream = new MemoryStream();
dimeAttach.Stream.Write(new Byte[10], 0, 10);
svc.RequestSoapContext.Attachments.Add(dimeAttach);
svc.DoNothing();
dimeAttach.Stream.Write(new Byte[10], 0, 10);
}
}
What I get, when executing the last command in CallServer() function
is:
An unhandled exception of type 'System.ObjectDisposedException'
occurred in mscorlib.dll
Additional information: Cannot access a closed Stream.
Why do we want to do it this way ?
This is a simplified code, just to show the problem, but in general
what we want is -> pass a big file in chunks from one side to another
(from client to server).
We can, ofcource, for every chunk, create a new stream and write data
of next chunk to it, but in this case we get much much memory usage.
We have to activate garbage collector to free memory, but, this is not
the best way to do things.
There are 2 questions:
1 --> any idea, why do I get this exception ?
2 --> any idea how to solve the general problem ?
Thank you