Results 1 to 13 of 13

Thread: Help! How to share object between clients?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Location
    Kiev, Ukraine
    Posts
    5

    Question Help! How to share object between clients?

    I have an object (Singleton) in ActiveX DLL and want to share it between several clients but new copy of it created for each client even if I use Standard Module. I try to experiment with Project options. But no success.
    Who can help me with that problem???? (Maybe GOD )

  2. #2
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    do you mean you want to access details entered by another program in the activeX
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  3. #3

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    He might mean that he wants to share the instance of a class/dll started in 1 app with another app:

    If so:

    http://www.vbforums.com/showthread.p...=getobject+dll
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Location
    Kiev, Ukraine
    Posts
    5

    Thumbs up Thanks to Cander

    Really thank's Cander. Beer to you
    This is impressive.

  6. #6
    Lively Member
    Join Date
    Aug 2002
    Posts
    126
    i'm sorry guys,
    but you'r totally wrong with this concept.
    by using GetObject function u r absolutely NOT sharing object between clients because each client get is own copy (instance) of the class.

  7. #7
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    uhh no deja. GetObject does what it says. You are GETTING an instance and using it. CreateObject creates a new instance.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  8. #8
    Lively Member
    Join Date
    Aug 2002
    Posts
    126
    (sorry for my english)
    let's have some order here.
    there is a Commponent and ther is an Object.
    Component is a DLL file that contain Class/es inside.
    Object is an Instance of Class.
    now, there is a different between ActiveX DLL that is "In-Process Component" and ActiveX EXE that is "Out-Of-Process Component".
    ActiveX DLL always running in the client process (unless u put it in a DLL Surrogate, which is a separate process called DLLHOST.EXE. for instance, COM+ use it), ActiveX EXE always run in a separate process (Excel, Word etc. is a good example of ActiveX EXE).
    GetObject function uses CoGetObject COM API function behind the scene, CoGetObject calls IMoniker::BindToObject method, and that method looks in the ROT (running object table) to find the specified server, if he find the object he bind the client to it (not precisely), if not he create new one.
    but that's not precisely (as i mentioned), because it depend on the COM object type, if it is a in-proc component (ActiveX DLL) he always create a new instance because it is ALWAYS running in the client (of course that the Component (not the class) is only one instance in the system - that's the whole concept of DLL), so again u getting new instance of the Object, not the Component (COM is also much cleaver to separate Code and Data - so the code of the class maybe only have once).
    in ActiveX EXE it is different, because it's running in a different process, so if u call GetObject u ALWAYS bind your variable to the running server.
    the question (if i'm not wrong) was to be able to share data (or instances) between client. the ONLYway to do that is to use ActiveX EXE or using COM+ SPM (Shared Property Manager), or sending messages between two process (by using Pipes or something else), or even using DataBase or flat file.
    i rest my case.

  9. #9

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Location
    Kiev, Ukraine
    Posts
    5

    Post recovery to all

    Wake up NEO ! MATRIX has got you ...
    (dedicated to deja)

    [SIZE=3]You can't believe ?????? Try this.
    And don't forget to thank for another one sight of light !!!

    [SIZE=4]
    Who don't believe you are welcome here.
    And the story continues ...
    Attached Files Attached Files

  10. #10
    Lively Member
    Join Date
    Aug 2002
    Posts
    126
    that code contain non trivial operations, and can cause some problems. that's also why visual basic do not supply this functions naturally.
    u should read ome more stuff.

    http://www.microsoft.com/msj/default...ctivex0895.htm

    http://groups.google.com/groups?hl=i...TF-8%26hl%3Diw

    http://msdn.microsoft.com/library/de...dn_objlife.asp

  11. #11

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Location
    Kiev, Ukraine
    Posts
    5

    Angry

    So why i use this? Because i read so many papers and articles and all this information gave me equally NOTHING.
    Why - because all authors was as so pessimistic as you!!!


    You will never be SELECTED... because you not NEO.


    Bye deja ...

  12. #12
    Lively Member
    Join Date
    Aug 2002
    Posts
    126
    first of all i'm not pessimistic.
    what i'm trying to tell u is that there r different ways to implement COM Singleton, and better ways.
    u know what? let's try something, add some code to your server:

    Public Sub ShortOp()

    End Sub

    Public Sub LongOP()

    Dim l As Long
    Dim s As String

    For l = 1 To 10000000
    s = "xxx"
    Next l

    End Sub

    now, add two command buttons to the client exe's and put that code:

    Private Sub Command1_Click()
    Server.ShortOp
    MsgBox "short op over"
    End Sub

    Private Sub Command2_Click()
    Server.LongOP
    MsgBox "long op over"
    End Sub

    now, run these clients, press the button of LongOp at one of them, and then press the button ShortOp on the other client...
    now what? u stuck, aren't you?

    that exactly one of the problem i'm taking about.
    if i would have to implement a singleton, i would do it with C++, not in VB, why? because ROT is obsolete and intend for backward compatibility. with COM Singleton your VB client need simply that code:

    dim obj as MyServer.MyClass
    set obj = new MyServer.MyClass
    tha's all.

    if u want to share information between clients, but still want each client to have it's own thread (so u won't get stcuk) use COM+ SPM or out-of-process COM object (ActiveX EXE).

  13. #13

    Thread Starter
    New Member
    Join Date
    Jan 2003
    Location
    Kiev, Ukraine
    Posts
    5
    I agree with this but I need object only to share data.
    If it were possible to share UDT i'll be doing it this way.

    In short I was found what I need.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width