Click here to Skip to main content
15,844,752 members
Home / Discussions / C#
   

C#

 
GeneralRe: SSD Computer and Visual Studio 2015... Pin
wtf3219-Jan-17 3:26
wtf3219-Jan-17 3:26 
AnswerRe: SSD Computer and Visual Studio 2015... Pin
Gerry Schmitz19-Jan-17 6:27
mveGerry Schmitz19-Jan-17 6:27 
QuestionWinforms custom property fails to reload - continued from QA Pin
Midi_Mick18-Jan-17 4:53
professionalMidi_Mick18-Jan-17 4:53 
AnswerRe: Winforms custom property fails to reload - continued from QA Pin
Gerry Schmitz18-Jan-17 5:47
mveGerry Schmitz18-Jan-17 5:47 
GeneralRe: Winforms custom property fails to reload - continued from QA Pin
Midi_Mick18-Jan-17 5:54
professionalMidi_Mick18-Jan-17 5:54 
GeneralRe: Winforms custom property fails to reload - continued from QA Pin
Gerry Schmitz18-Jan-17 6:19
mveGerry Schmitz18-Jan-17 6:19 
GeneralRe: Winforms custom property fails to reload - continued from QA Pin
Midi_Mick18-Jan-17 6:34
professionalMidi_Mick18-Jan-17 6:34 
QuestionRe: Winforms custom property fails to reload - continued from QA. A new clue. Pin
Midi_Mick18-Jan-17 5:48
professionalMidi_Mick18-Jan-17 5:48 
Another clue:

I modified the ControlGroup serialisation so that it serialises the list of control objects into a byte array, each control being serialised individually, like so:
C#
public ControlGroup(SerializationInfo info, StreamingContext context) {
   BinaryFormatter fmt = new BinaryFormatter();
   byte[] data = (byte[])info.GetValue("controls", typeof(byte[]));
   int count = info.GetInt32("count");
   using (MemoryStream ms = new MemoryStream(data)) {
      for (int i = 0; i < count; ++i) {
         object obj = fmt.Deserialize(ms);
         _controls.Add((Control)obj); // Error here.
      }
   }
}

public virtual void GetObjectData(SerializationInfo info, StreamingContext context) {
   BinaryFormatter fmt = new BinaryFormatter();
   using (MemoryStream ms = new MemoryStream()) {
      foreach (Control c in _controls) {
         fmt.Serialize(ms, c);
      }
      info.AddValue("controls", ms.ToArray());
   }
   info.AddValue("count", _controls.Count);
}


When I try to reopen the test form with values set, it tells me that type CheckBox cannot be cast to type Control. However, if I close and reopen VS, or at runtime, it deserialises OK. I even put in a messagebox to tell me if obj is Control - I get "True" on compile, but "False" in designer.
Cheers,

Mick
------------------------------------------------
It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.


modified 18-Jan-17 10:56am.

QuestionWhen is it safe to use Monitor (lock) with Task? Pin
Bernhard Hiller18-Jan-17 3:34
Bernhard Hiller18-Jan-17 3:34 
AnswerRe: When is it safe to use Monitor (lock) with Task? Pin
Pete O'Hanlon18-Jan-17 4:25
subeditorPete O'Hanlon18-Jan-17 4:25 
GeneralRe: When is it safe to use Monitor (lock) with Task? Pin
Bernhard Hiller18-Jan-17 22:05
Bernhard Hiller18-Jan-17 22:05 
AnswerRe: When is it safe to use Monitor (lock) with Task? Pin
Richard Deeming18-Jan-17 9:11
mveRichard Deeming18-Jan-17 9:11 
GeneralRe: When is it safe to use Monitor (lock) with Task? Pin
Bernhard Hiller18-Jan-17 22:11
Bernhard Hiller18-Jan-17 22:11 
GeneralRe: When is it safe to use Monitor (lock) with Task? Pin
Pete O'Hanlon18-Jan-17 22:15
subeditorPete O'Hanlon18-Jan-17 22:15 
QuestionGroup of Checkboxes Pin
eejaynic17-Jan-17 12:41
eejaynic17-Jan-17 12:41 
AnswerRe: Group of Checkboxes Pin
Gerry Schmitz17-Jan-17 14:02
mveGerry Schmitz17-Jan-17 14:02 
GeneralRe: Group of Checkboxes Pin
eejaynic17-Jan-17 15:11
eejaynic17-Jan-17 15:11 
GeneralRe: Group of Checkboxes Pin
Gerry Schmitz17-Jan-17 15:53
mveGerry Schmitz17-Jan-17 15:53 
AnswerRe: Group of Checkboxes Pin
Richard Deeming18-Jan-17 3:04
mveRichard Deeming18-Jan-17 3:04 
GeneralRe: Group of Checkboxes Pin
eejaynic18-Jan-17 10:03
eejaynic18-Jan-17 10:03 
QuestionCommunicating with unmanaged DLL Pin
Member 1041441717-Jan-17 3:43
Member 1041441717-Jan-17 3:43 
AnswerRe: Communicating with unmanaged DLL Pin
Midi_Mick17-Jan-17 4:19
professionalMidi_Mick17-Jan-17 4:19 
GeneralRe: Communicating with unmanaged DLL Pin
Member 1041441717-Jan-17 5:13
Member 1041441717-Jan-17 5:13 
AnswerRe: Communicating with unmanaged DLL Pin
Bernhard Hiller18-Jan-17 0:26
Bernhard Hiller18-Jan-17 0:26 
QuestionRe: Communicating with unmanaged DLL Pin
Member 1390693510-Jul-18 23:01
Member 1390693510-Jul-18 23:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.