473,714 Members | 3,077 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DragDrop between 2 instances of same VB.Net program doesn't work

I am using dragdrop to drag and drop a custom class instance. When I
drag/drop from one window to another window in the same application
everything works fine. But when trying to move between the same windows
running in different instances of the application the "dropped" data comes
across as a system.__ComObj ect and I can't CType it to my class to extract
the data. I've been searching for hours and haven't found any solution so
I am hoping that somebody can help me out here. Has anybody who has done
this in VB.Net please share the solution.

Thanks, John
Nov 21 '05 #1
7 4002
Hi,

"JohnR" <Jo******@hotma il.com> wrote in message
news:B4j4f.3028 $Gt2.2150@trndn y01...
I am using dragdrop to drag and drop a custom class instance. When I
drag/drop from one window to another window in the same application
everything works fine. But when trying to move between the same windows
running in different instances of the application the "dropped" data comes
across as a system.__ComObj ect and I can't CType it to my class to extract
the data. I've been searching for hours and haven't found any solution so
I am hoping that somebody can help me out here. Has anybody who has done
this in VB.Net please share the solution.
Have you tried using the Serializable attribute on your custom class ?

<Serializable() > _
Public Class CustomClass
' If this class references an other class then that other
' class must also have the Serializable attribute or the
' field that references the other class must have the
' NonSerialized attribute.
End Class

Public Sub DragDrop( .....)
Dim co As CustomClass
co = DirectCast( _
e.Data.GetData( GetType(CustomC lass)), _
CustomClass )

End Sub

HTH,
Greetings


Thanks, John

Nov 21 '05 #2
Hi Bart,

I put the <serializable() > attribute on my custom class and I'm getting a
little closer :). Now what is happening is that the "dragdrop" doesn't
seem to be able to access what I am dragging. Using a breakpoint in my
dragdrop routine and using quickview the 'structures' in my custom class
come across (ie: the arraylist is an arraylist) but the contents of the
arraylist is "System.runtime .remoting.proxi es.__Transparen tProxy" and I
can't seem to get to my data.

Any Ideas of how I might do this?

Thanks, John
"Bart Mermuys" <bm************ *@hotmail.com> wrote in message
news:OF******** ******@TK2MSFTN GP12.phx.gbl...
Hi,

"JohnR" <Jo******@hotma il.com> wrote in message
news:B4j4f.3028 $Gt2.2150@trndn y01...
I am using dragdrop to drag and drop a custom class instance. When I
drag/drop from one window to another window in the same application
everything works fine. But when trying to move between the same windows
running in different instances of the application the "dropped" data comes
across as a system.__ComObj ect and I can't CType it to my class to extract
the data. I've been searching for hours and haven't found any solution
so I am hoping that somebody can help me out here. Has anybody who has
done this in VB.Net please share the solution.


Have you tried using the Serializable attribute on your custom class ?

<Serializable() > _
Public Class CustomClass
' If this class references an other class then that other
' class must also have the Serializable attribute or the
' field that references the other class must have the
' NonSerialized attribute.
End Class

Public Sub DragDrop( .....)
Dim co As CustomClass
co = DirectCast( _
e.Data.GetData( GetType(CustomC lass)), _
CustomClass )

End Sub

HTH,
Greetings


Thanks, John


Nov 21 '05 #3
Hi,

"JohnR" <Jo******@hotma il.com> wrote in message
news:wMS4f.5727 $hx.4318@trndny 08...
Hi Bart,

I put the <serializable() > attribute on my custom class and I'm getting
a little closer :). Now what is happening is that the "dragdrop" doesn't
seem to be able to access what I am dragging. Using a breakpoint in my
dragdrop routine and using quickview the 'structures' in my custom class
come across (ie: the arraylist is an arraylist) but the contents of the
arraylist is "System.runtime .remoting.proxi es.__Transparen tProxy" and I
can't seem to get to my data.
If the content is __TransparentPr oxy then the object in the ArrayList
inherits from MarshalByRefObj ect, doesn't need to be directly.

If you pass data from one app to another then it can't be accessed directly
because each app has it own memory space.

So the objects needs to be copied ( serializable ) or they need to be
accessed through Remoting (MarshalByRefOb ject). If you access them through
Remoting then you use a proxy object that is connected to the real object,
and you can cast this __TransparentPr oxy to your original class.

To keep it simple, try to keep the object graph copyable, meaning all
objects have the Serializable attribute and don't inherit from
MarshalByRefObj ect directly or indirectly.

If you still want to use MarshalByRefObj ect's (and therefore Remoting) then
you have to register a Channel, i'm no expert at remoting, but it should
look like:

' set a reference to System.Runtime. Remoting.dll at project references
' then use this code
Import System.Runtime. Remoting.Channe ls
Import System.Runtime. Remoting.Channe ls.Tcp

Public Sub Form_Load(...) Handles Form.Load
Dim ch As New TcpChannel(0)
ChannelServices .RegisterChanne l(ch)
End Sub

HTH,
Greetings

Any Ideas of how I might do this?

Thanks, John
"Bart Mermuys" <bm************ *@hotmail.com> wrote in message
news:OF******** ******@TK2MSFTN GP12.phx.gbl...
Hi,

"JohnR" <Jo******@hotma il.com> wrote in message
news:B4j4f.3028 $Gt2.2150@trndn y01...
I am using dragdrop to drag and drop a custom class instance. When I
drag/drop from one window to another window in the same application
everything works fine. But when trying to move between the same windows
running in different instances of the application the "dropped" data
comes across as a system.__ComObj ect and I can't CType it to my class to
extract the data. I've been searching for hours and haven't found any
solution so I am hoping that somebody can help me out here. Has anybody
who has done this in VB.Net please share the solution.


Have you tried using the Serializable attribute on your custom class ?

<Serializable() > _
Public Class CustomClass
' If this class references an other class then that other
' class must also have the Serializable attribute or the
' field that references the other class must have the
' NonSerialized attribute.
End Class

Public Sub DragDrop( .....)
Dim co As CustomClass
co = DirectCast( _
e.Data.GetData( GetType(CustomC lass)), _
CustomClass )

End Sub

HTH,
Greetings


Thanks, John



Nov 21 '05 #4
Hi Bart,

First I want to thank you for taking the time to help me out... I really
appreciate it.

I certainly don't want to use MarshalByRefObj ect's. I really want to keep
it as simple as possible. As I mentioned the drag/drop works fine within
different windows in the same program, and I'm trying to make it work when
doing a drag/drop from the 'same' windows in different instances of the
program. I don't think I am using anything that is not serializable. Here
is my class that I am attempting to drag/drop (the ultragrid is a grid
control from Infergistics (an excellent set of controls, by the way)):

#Region "MyDragDropCont ainer class"

<Serializable() > _

Public Class MyDragDropConta iner

Private _SelectedRows As New ArrayList

Private _SelectedCells As New ArrayList

Private _SourceGrid As UltraGrid

Property SourceGrid() As UltraGrid

Get

Return _SourceGrid

End Get

Set(ByVal Value As UltraGrid)

_SourceGrid = Value

End Set

End Property

Public Property SelectedCells() As ArrayList

Get

Return _SelectedCells

End Get

Set(ByVal Value As ArrayList)

_SelectedCells = Value

End Set

End Property

Public Property SelectedRows() As ArrayList

Get

Return _SelectedRows

End Get

Set(ByVal Value As ArrayList)

_SelectedRows = Value

End Set

End Property

End Class

#End Region

this is how I load the instance of the class

Public Function LoadDragDropCon tainer(ByRef MyGrid As UltraGrid) As
MyDragDropConta iner

Dim ddc As New MyDragDropConta iner

Dim myRow As UltraGridRow

Dim myCell As UltraGridCell

For Each myRow In MyGrid.Selected .Rows

ddc.SelectedRow s.Add(myRow)

Next

For Each myCell In MyGrid.Selected .Cells

ddc.SelectedCel ls.Add(myCell)

Next

ddc.SourceGrid = MyGrid

Return ddc

End Function

And then I do the "DoDragDrop " filling the dataobject with 2 sets of data.
one is my custom class, and the other is a plain string so I can drop to an
entity that will accept strings.

ddc = LoadDragDropCon tainer(CType(se nder, UltraGrid)) 'sender is my grid
passed to the mousemove event

data_object.Set Data("MyDragDro pContainer", False, ddc)

data_object.Set Data(DataFormat s.StringFormat, True,
myCell.Row.Cell s("MyField").Te xt)

ug.DoDragDrop(d ata_object, DragDropEffects .Copy)

Do you see anything that might be causing a problem or causing
MarshalByRefObj ects to be invoked???

Thanks, John
Nov 21 '05 #5
Hi,

"JohnR" <Jo******@hotma il.com> wrote in message
news:KoV4f.2565 3$p_.13638@trnd ny05...
Hi Bart,

First I want to thank you for taking the time to help me out... I really
appreciate it.

I certainly don't want to use MarshalByRefObj ect's. I really want to keep
it as simple as possible. As I mentioned the drag/drop works fine within
different windows in the same program,
Yes, but I explained that it is much harder between apps, because of the
seperated memory space or different AppDomains in .NET.
and I'm trying to make it work when doing a drag/drop from the 'same'
windows in different instances of the program. I don't think I am using
anything that is not serializable.
Because of the __TransparentPr oxy I'm suspecting that that object inherits
(direct or indirectly) from MarshalByRefObj ect.
Here is my class that I am attempting to drag/drop (the ultragrid is a
grid control from Infergistics (an excellent set of controls, by the
way)):
<code snipped> Do you see anything that might be causing a problem or causing
MarshalByRefObj ects to be invoked???

Unfortunately it is impossible for me to see this without having the
UltraGrid. You should check if UltraGrid, UltraGridCell and UltraGridRow
inherit directly or indirectly from MarshalByRefObj ect, you can see this
inside the Object Browser (visual studio) or in the documentation for the
grid.

I'm almost certain UltraGrid inherits indirectly from MarshalByRefObj ect
because if it inherits from Control, then
UltraGrid -> Control -> Component -> MarshalByRefObj ect.
HTH,
Greetings


Thanks, John

Nov 21 '05 #6
Hi Bart,

You are certainly correct. The Infergistics grid stuff all inherits from
MarshalbyRefObj ect. While researching this topic, I have found statements
such as ".NET allows you to MarshalByRef or MarshalByValue" , so the next
logical question is when I'm loading the instance of my custom class with
the ultragrid stuff, can I force it to MarshalByValue? ????

John

"Bart Mermuys" <bm************ *@hotmail.com> wrote in message
news:e8******** ******@TK2MSFTN GP12.phx.gbl...
Hi,

"JohnR" <Jo******@hotma il.com> wrote in message
news:KoV4f.2565 3$p_.13638@trnd ny05...
Hi Bart,

First I want to thank you for taking the time to help me out... I really
appreciate it.

I certainly don't want to use MarshalByRefObj ect's. I really want to
keep it as simple as possible. As I mentioned the drag/drop works fine
within different windows in the same program,


Yes, but I explained that it is much harder between apps, because of the
seperated memory space or different AppDomains in .NET.
and I'm trying to make it work when doing a drag/drop from the 'same'
windows in different instances of the program. I don't think I am using
anything that is not serializable.


Because of the __TransparentPr oxy I'm suspecting that that object inherits
(direct or indirectly) from MarshalByRefObj ect.
Here is my class that I am attempting to drag/drop (the ultragrid is a
grid control from Infergistics (an excellent set of controls, by the
way)):

<code snipped>
Do you see anything that might be causing a problem or causing
MarshalByRefObj ects to be invoked???


Unfortunately it is impossible for me to see this without having the
UltraGrid. You should check if UltraGrid, UltraGridCell and UltraGridRow
inherit directly or indirectly from MarshalByRefObj ect, you can see this
inside the Object Browser (visual studio) or in the documentation for the
grid.

I'm almost certain UltraGrid inherits indirectly from MarshalByRefObj ect
because if it inherits from Control, then
UltraGrid -> Control -> Component -> MarshalByRefObj ect.
HTH,
Greetings


Thanks, John


Nov 21 '05 #7
Hi,

"JohnR" <Jo******@hotma il.com> wrote in message
news:O1X4f.1121 2$f02.2959@trnd ny02...
Hi Bart,

You are certainly correct. The Infergistics grid stuff all inherits
from MarshalbyRefObj ect. While researching this topic, I have found
statements such as ".NET allows you to MarshalByRef or MarshalByValue" ,
so the next logical question is when I'm loading the instance of my custom
class with the ultragrid stuff, can I force it to MarshalByValue? ????
If all classes involved have the Serializable attribute, then you can force
marshal by value by serializing everthing into a MemoryStream and then pass
a Byte array between apps and then deserialize the Byte array. But i doubt
that will work, because eg. Control class is not marked Serializable. And
even if it would, it makes not much sense to copy a Control because it is on
a Form. It may work for the cells or rows alone but that also depends if
they are marked Serializable.

I think the best thing you can do is either use remoting ( adding a
Channel ) or extract the values you need and put them in serializable
classes that don't inherit from MarshalByRefObj ect.

HTH,
Greetings

Code to force marshal-by-value:

Imports System.Runtime. Serialization.F ormatters.Binar y
Imports System.IO

Public Sub MouseDown( .. ) Handles SomeControl.Mou seDown
Dim bf As New BinaryFormatter
Dm ms As New MemoryStream
Dim data As New DataObject
Dim co As New MyDragDropConta iner
...
bf.Serialize( ms, co )
data.SetData( "MyDragDropCont ainer", False, ms.ToArray() )
SomeControl.DoD ragDrop( data, .... )

End Sub

Public Sub DragDrop(...) Handles SomeControl.Dra gDrop
Dim bf As New BinaryFormatter
Dm ms As New MemoryStream( _
DirectCast( e.Data.GetData( "MyDragDropCont ainer"), Byte() )

Dim co As MyDragDropConta iner = _
DirectCast( bf.Deserialize( ms ), MyDragDropConta iner )

End Sub

HTH,
Greetings

John

"Bart Mermuys" <bm************ *@hotmail.com> wrote in message
news:e8******** ******@TK2MSFTN GP12.phx.gbl...
Hi,

"JohnR" <Jo******@hotma il.com> wrote in message
news:KoV4f.2565 3$p_.13638@trnd ny05...
Hi Bart,

First I want to thank you for taking the time to help me out... I
really appreciate it.

I certainly don't want to use MarshalByRefObj ect's. I really want to
keep it as simple as possible. As I mentioned the drag/drop works fine
within different windows in the same program,


Yes, but I explained that it is much harder between apps, because of the
seperated memory space or different AppDomains in .NET.
and I'm trying to make it work when doing a drag/drop from the 'same'
windows in different instances of the program. I don't think I am using
anything that is not serializable.


Because of the __TransparentPr oxy I'm suspecting that that object
inherits (direct or indirectly) from MarshalByRefObj ect.
Here is my class that I am attempting to drag/drop (the ultragrid is a
grid control from Infergistics (an excellent set of controls, by the
way)):

<code snipped>
Do you see anything that might be causing a problem or causing
MarshalByRefObj ects to be invoked???


Unfortunately it is impossible for me to see this without having the
UltraGrid. You should check if UltraGrid, UltraGridCell and UltraGridRow
inherit directly or indirectly from MarshalByRefObj ect, you can see this
inside the Object Browser (visual studio) or in the documentation for the
grid.

I'm almost certain UltraGrid inherits indirectly from MarshalByRefObj ect
because if it inherits from Control, then
UltraGrid -> Control -> Component -> MarshalByRefObj ect.
HTH,
Greetings


Thanks, John



Nov 21 '05 #8

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

Similar topics

7
5842
by: Kate | last post by:
Hi: I have a form with a picture box and some command buttons to make certain shapes appear in the picture box. The shapes are drawn on blank UserControls added like this: 'at top of form module Dim WithEvents tc As testControl 'button1_click (for example)
10
436
by: KS | last post by:
I have a Button I want to pull to a Label. I want the Button visualy to move when I pull it. When I drop the button on the Label I want to test some data coming with the Button - f.ex is the Button.Text="The right one!". I have some code that can do the DragDrop-effect BUT this code disables the visual effect og the Button visualy moving to the Label.
1
2522
by: KS | last post by:
In want to visualy drag a Button to a Label and when I depress the mousebutton on top of the label I want to show some dato from the Button in a MsgBox - that's my primary goal. I have made a simple sample code - a form with a Button1, a Label1 and a Timer1. The Button1 has Tag="SomeData", the Label1 has AllowDrop=True and the Timer1 has an Interval=20.
4
3688
by: Chad Myers | last post by:
I'm instrumenting my app with a few performance counters and I'd like to ask you all for some advice on how to handle performance counter instances. I have a class library that is a base library for most of our ..NET applications. It provides configuration, logging, exception management/publishing, data access, etc. I have my counters, but I'm curious how I should handle instances. Right now, the instance name is exename-procid like...
2
1660
by: active | last post by:
I'm about ready to give up unless someone has an idea. Trying to do in a ListView DragDrop and DoubleClick. I can make it work if they use different mouse buttons. But if I use the left button for drag I do not get a DoubleClick event with the Left Button. I'd guess that's the way it is but am wondering if there is a way that I
0
901
by: SamSpade | last post by:
How to program DragDrop with a RichTextBox? If I develop by inherit I can override the DragDrop methods and do it that way. But if I want to include a RichTextBox on a UserControl the MethodName drop down box does not include methods for the DragDrop events. Is there some way to get the methods to show? Is it OK to program them manually?
0
887
by: Sarika | last post by:
Hello all, I have a MDI form w/ a treeview. A splitter control separates the treeview part of the form from the MDI client. (MDI Client is placed on the MDI parent). The client form has a panel control on which I drag and drop treeview items or draw shapes. I have a drop down menu, with a list of items present in the treeview. Clicking on any of the menu items triggers the treeview.DoDragDrop event. Basically this should give me the...
90
4391
by: Ben Finney | last post by:
Howdy all, How can a (user-defined) class ensure that its instances are immutable, like an int or a tuple, without inheriting from those types? What caveats should be observed in making immutable instances? -- \ "Love is the triumph of imagination over intelligence." -- |
10
1262
by: Ratnesh Raval | last post by:
Hi All, My question is on DragDrop, How would I implement a Drag from listview and Drop on Desktop or any other folder on the computer. The listview contains list of files, so basically I should be able to drop
0
8808
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8712
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9179
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9023
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7954
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6638
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4466
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2525
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2113
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.