473,320 Members | 2,202 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Serialize Cursor to memory stream fails

In an attempt to get around a resource leak issue, I tried to serialize a
Cursor to a MemoryStream but the serialization fails with "Stock cursors
cannot be serialized." This is puzzling since the Cursor being serialized is
built from a bitmap and is not a stock cursor at all. Is this a misleading
error message or am I actually somehow really serializing a stock cursor.

Here's the code, pared down to its essentials.

public Cursor MakeCursor(Bitmap bm)
{
IntPtr ptr = bm.GetHicon();
Cursor retCursor = new Cursor(ptr);
BinaryFormatter f = new BinaryFormatter();
MemoryStream ms = new MemoryStream();

// The following line throws an exception...
f.Serialize(ms, retCursor);

DestroyIcon(ptr);
return retCursor;
}

--
Richard Lewis Haggard
www.Haggard-And-Associates.com
Dec 12 '06 #1
0 1624

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Brad | last post by:
I have tried both the binary and the XML serialization; both give the same results. I have an object with a MemoryStream member. When I serialize and deserialize the object, the MemoryStream...
5
by: Brian Reed | last post by:
I have a class that I want to serialize to an XML string. I want the XML to serialize to utf-8 encoding. When I serialize to an XML file, the data looks great. When I try to serialize to a String...
5
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream...
5
by: andrewcw | last post by:
I have an object to serialize. TextWriter writer = new StreamWriter("test.xml"); serializer.Serialize(writer,obj); writer.Close(); but below does not, why ?? I have a file that I will have...
0
by: Fred Heida | last post by:
Hi Al, i have a funny problem.. i you can call it funny.. what i have is 2 assemblies, the first one does nothing other then Application.Run(new MyForm())
4
by: Schorschi | last post by:
I am trying to mimic the following (which works) but Use the stock GetManifestResourceStream route. For example Public Declare Unicode Function LoadCursorFromFile Lib "USER32.DLL" Alias...
5
by: Paul Cheetham | last post by:
Hi, I have some custom colour cursors which I have added to my c# project, and set them to be compiled as "Embedded Resource" It seems impossible to load a colour cursor using the standard...
4
by: Abi | last post by:
We able to generate this error in our test environment and were able to research this enough to understand that the issue is NOT with an abject that needs to be serialized but rather as the stack...
3
by: =?Utf-8?B?UGhpbCBKb2huc29u?= | last post by:
Hi, I am using dotnet remoting with a binarry formatter. I have a property that returns a memorystream that has had a file loaded into it. When I try to access this property though I get an...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.