Click here to Skip to main content
15,912,578 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: Overriding void Dispose(bool disposing) in C++/CLI? [modified] Pin
George L. Jackson20-May-06 15:44
George L. Jackson20-May-06 15:44 
AnswerRe: Overriding void Dispose(bool disposing) in C++/CLI? Pin
Dave Doknjas20-May-06 19:25
Dave Doknjas20-May-06 19:25 
GeneralRe: Overriding void Dispose(bool disposing) in C++/CLI? Pin
Filip Strugar22-May-06 22:34
Filip Strugar22-May-06 22:34 
GeneralRe: Overriding void Dispose(bool disposing) in C++/CLI? Pin
George L. Jackson23-May-06 1:57
George L. Jackson23-May-06 1:57 
GeneralRe: Overriding void Dispose(bool disposing) in C++/CLI? Pin
Dave Doknjas23-May-06 12:31
Dave Doknjas23-May-06 12:31 
QuestionMixing native and managed code Pin
Saurabh.Garg19-May-06 18:44
Saurabh.Garg19-May-06 18:44 
AnswerRe: Mixing native and managed code Pin
georgeraafat23-May-06 12:50
georgeraafat23-May-06 12:50 
QuestionSerialization Issue with Int32 Pin
jmlstele19-May-06 9:51
jmlstele19-May-06 9:51 
While I'm posting possible problems I've found...

When a struct (or class for that matter) with an Int32 ^ is deserialized an exception is thrown.

Again: Is this a "feature" that I just haven't seen documented anywhere, or an actual issue?

----CODE----
using namespace System;
using namespace System::IO;
using namespace System::Runtime::Serialization::Formatters::Binary;

[Serializable]
public ref struct TestStruct {
Int32^ i;
};

[Serializable]
public ref struct TestStruct2 {
int i;
};

int main(array<System::String ^> ^args)
{
//MemoryStream to do use for serializing
MemoryStream^ ms = gcnew MemoryStream();
//Binary Format
BinaryFormatter^ bf = gcnew BinaryFormatter();

//Create the structure
TestStruct ^t = gcnew TestStruct();
//Initialize the data
t->i = 42;

//Serialize the string
bf->Serialize(ms,t);
//GO back to the beginning of the stream to deserialize
ms->Seek(0,SeekOrigin::Begin);

try {
Object^ o = bf->Deserialize(ms);
System::Console::WriteLine("o is {0}",o);
} catch(System::Runtime::Serialization::SerializationException^ e) {
System::Console::WriteLine("Caught an exception while trying to deserialize TestStruct!");
System::Console::WriteLine(e->Message);
}
/* Generates Exception:
Type: System.Runtime.Serialization.SerializationException
Additional information: Binary stream '42' does not contain a valid
BinaryHeader. Possible causes are invalid stream or object version
change between serialization and deserialization.

Note the 42. If t->i is set to a different value, this changes.
*/

//Reset for second test
ms = gcnew MemoryStream();
bf = gcnew BinaryFormatter();

TestStruct2 ^t2 = gcnew TestStruct2();
t2->i = 42;

bf->Serialize(ms,t2);
ms->Seek(0,SeekOrigin::Begin);
try {
Object^ o = bf->Deserialize(ms);
System::Console::WriteLine("o is {0}",o);
} catch(System::Runtime::Serialization::SerializationException^ e) {
System::Console::WriteLine("Caught an exception while trying to deserialize TestStruct2!");
System::Console::WriteLine(e->Message);
}
/* No Exception Generated */

return 0;
}
----CODE END----


AnswerRe: Serialization Issue with Int32 Pin
georgeraafat23-May-06 13:17
georgeraafat23-May-06 13:17 
GeneralRe: Serialization Issue with Int32 Pin
jmlstele29-May-06 1:22
jmlstele29-May-06 1:22 
QuestionUndocumented problem with for each Pin
jmlsteele19-May-06 9:14
jmlsteele19-May-06 9:14 
GeneralRe: Undocumented problem with for each Pin
jmlstele19-May-06 9:18
jmlstele19-May-06 9:18 
AnswerRe: Undocumented problem with for each Pin
Nish Nishant19-May-06 10:10
sitebuilderNish Nishant19-May-06 10:10 
QuestionIs it possible to write a parser which will find.... Pin
SasikumarRenjith19-May-06 1:23
SasikumarRenjith19-May-06 1:23 
AnswerRe: Is it possible to write a parser which will find.... Pin
Cedric Moonen19-May-06 3:54
Cedric Moonen19-May-06 3:54 
QuestionHow do I Convert Struct to ByteArray in .net 2005 Pin
ShayD118-May-06 6:32
ShayD118-May-06 6:32 
AnswerRe: How do I Convert Struct to ByteArray in .net 2005 Pin
2bee 18-May-06 11:37
2bee 18-May-06 11:37 
Questionporting managed c++ from vs2003 to vs2005 Pin
Hohenloher16-May-06 21:50
Hohenloher16-May-06 21:50 
AnswerRe: porting managed c++ from vs2003 to vs2005 Pin
George L. Jackson17-May-06 4:43
George L. Jackson17-May-06 4:43 
GeneralRe: porting managed c++ from vs2003 to vs2005 Pin
Hohenloher17-May-06 21:38
Hohenloher17-May-06 21:38 
GeneralRe: porting managed c++ from vs2003 to vs2005 Pin
George L. Jackson18-May-06 0:34
George L. Jackson18-May-06 0:34 
GeneralRe: porting managed c++ from vs2003 to vs2005 Pin
Nemanja Trifunovic18-May-06 6:31
Nemanja Trifunovic18-May-06 6:31 
AnswerRe: porting managed c++ from vs2003 to vs2005 Pin
George L. Jackson18-May-06 11:02
George L. Jackson18-May-06 11:02 
QuestionGeneration of Class Diagrams Pin
madhusri16-May-06 5:37
madhusri16-May-06 5:37 
GeneralRe: Generation of Class Diagrams Pin
George L. Jackson17-May-06 10:43
George L. Jackson17-May-06 10:43 

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.