Click here to Skip to main content
15,912,578 members
Home / Discussions / C#
   

C#

 
GeneralConsole.writeline not working from a windows app. Pin
Admiral Ackbar30-Jul-04 3:00
Admiral Ackbar30-Jul-04 3:00 
GeneralRe: Console.writeline not working from a windows app. Pin
Wender Oliveira30-Jul-04 4:41
Wender Oliveira30-Jul-04 4:41 
GeneralRe: Console.writeline not working from a windows app. Pin
Michael P Butler30-Jul-04 4:54
Michael P Butler30-Jul-04 4:54 
GeneralRe: Console.writeline not working from a windows app. Pin
Heath Stewart30-Jul-04 7:32
protectorHeath Stewart30-Jul-04 7:32 
GeneralRe: Console.writeline not working from a windows app. Pin
Admiral Ackbar30-Jul-04 8:19
Admiral Ackbar30-Jul-04 8:19 
GeneralDrag n drop treeview Nodes between two different applications Pin
misterbear30-Jul-04 2:02
misterbear30-Jul-04 2:02 
GeneralRe: Drag n drop treeview Nodes between two different applications Pin
Heath Stewart30-Jul-04 5:58
protectorHeath Stewart30-Jul-04 5:58 
GeneralRe: Drag n drop treeview Nodes between two different applications Pin
misterbear31-Jul-04 4:59
misterbear31-Jul-04 4:59 
Isn't it possible to serialize the raw object data from memory into a binary data format and just transport that?
If I just define the MyTreeNode2 class as serializable with the [Serializable] attribute before the class definition
and then I should be able to Serialize it into a byte array or something right? And that should be no problem to
marshal I reckon...
From what I could conclude there is built-in support for this type of binary serialization and deserialization,
(BinaryFormatter class) which should mean that I should be able to use this method without a problem to transport an object..

So, if my thinking is right, can you tell me what's wrong with this? All I know is it doesn't do what I want it to...

(code handling start drag event)
<br />
// Create a formatter object<br />
IFormatter formatter = new BinaryFormatter();<br />
<br />
// Create a memoryStream<br />
MemoryStream ms = new MemoryStream();<br />
<br />
// Serialize the object (here of type MyNameSpace.MyTreeNode2) into the memory stream using the binary formatter<br />
formatter.Serialize(ms, draggedItem);<br />
<br />
// Put the byte array from the memory stream into a data object and specify the format <br />
// type to be of type "MyNameSpace.MyTreeNode2"<br />
DataObject dObj = new DataObject( "MyNamespace.MyTreeNode2", ms.GetBuffer() );<br />
selectedTreeView.DoDragDrop( dObj, DragDropEffects.All );<br />


and here is what I want to use on the receiving side. But it doesn't work, the method actually returns after the last line (data = ...) without even continuing execution of the remaining part of the method, or at least the debug stepper of VS won't continue past this point. (Why does this happen?)

(code for handling drop event)
<br />
// check the data member of drag event argument for the data we're willing to receive<br />
if ( e.Data.GetDataPresent("MyNamespace.MyTreeNode2") )<br />
{<br />
MyTreeNode2 data = null;<br />
IFormatter formatter = new BinaryFormatter();<br />
<br />
byte[] serializedBytes = (byte[])e.Data.GetData("MyNamespace.MyTreeNode2", false);<br />
MemoryStream ms = new MemoryStream( serializedBytes );<br />
data = (MyTreeNode2)formatter.Deserialize( ms );<br />
...<br />

GeneralRe: Drag n drop treeview Nodes between two different applications Pin
Heath Stewart31-Jul-04 5:26
protectorHeath Stewart31-Jul-04 5:26 
GeneralMessage Removed Pin
30-Jul-04 1:01
wibblewibblewibble30-Jul-04 1:01 
GeneralRe: Image Class Problem Pin
Bret Mulvey9-Aug-04 17:54
Bret Mulvey9-Aug-04 17:54 
GeneralWebBrowser's Document Complete event Pin
profoundwhispers29-Jul-04 23:02
profoundwhispers29-Jul-04 23:02 
GeneralRe: WebBrowser's Document Complete event Pin
HiltonG30-Jul-04 2:30
HiltonG30-Jul-04 2:30 
GeneralRe: WebBrowser's Document Complete event Pin
profoundwhispers30-Jul-04 8:33
profoundwhispers30-Jul-04 8:33 
GeneralRe: WebBrowser's Document Complete event Pin
Dave Kreskowiak30-Jul-04 4:27
mveDave Kreskowiak30-Jul-04 4:27 
GeneralInvoking a Win32 DLL from C# Pin
rana7429-Jul-04 23:00
rana7429-Jul-04 23:00 
GeneralRe: Invoking a Win32 DLL from C# Pin
Heath Stewart30-Jul-04 5:53
protectorHeath Stewart30-Jul-04 5:53 
GeneralRe: Invoking a Win32 DLL from C# Pin
rana741-Aug-04 16:18
rana741-Aug-04 16:18 
GeneralRe: Invoking a Win32 DLL from C# Pin
Heath Stewart4-Aug-04 5:04
protectorHeath Stewart4-Aug-04 5:04 
Questionhow do i pass null to dateTime variable Pin
robmays29-Jul-04 22:56
robmays29-Jul-04 22:56 
AnswerRe: how do i pass null to dateTime variable Pin
Ryan Roberts30-Jul-04 0:15
Ryan Roberts30-Jul-04 0:15 
GeneralRe: how do i pass null to dateTime variable Pin
robmays30-Jul-04 0:17
robmays30-Jul-04 0:17 
QuestionHow to passing parameters from eVC++ to a running C# program? Pin
ting66829-Jul-04 22:40
ting66829-Jul-04 22:40 
AnswerRe: How to passing parameters from eVC++ to a running C# program? Pin
Heath Stewart30-Jul-04 5:40
protectorHeath Stewart30-Jul-04 5:40 
Questionmatching regex at exact index? Pin
Roger Alsing29-Jul-04 21:44
Roger Alsing29-Jul-04 21:44 

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.