CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 1999
    Posts
    7

    VB client, VC server

    Hi there,
    i'm a beginner using COM/DCOM..i have an ATL server..which has an interface function with 3 out parameters...returned back to the client as double*...i'm able to access the function in my VB client...but...its giving me the "argument by reference mismatch error"...my function in the interface of my server is as follows STDMETHODIMP CMyinterface::Get(double *x, double *y, double *ammun)...my VB client code looks sth like this
    Private Sub Form_Load()
    Dim x, y, z As Double
    Dim obj As FPSERVERLib.Myinterface
    Set obj = New FPSERVERLib.Myinterface


    obj.Get x, y, z//////its giving me error at this point
    Text1.Text = x
    Text2.Text = y
    Text3.Text = z
    End Sub

    Thank you once again for your time..and any help is apppreciated.
    Vishal



  2. #2
    Join Date
    May 1999
    Posts
    4

    Re: VB client, VC server

    Hi,

    Try changing your ATL function declaration from:

    STDMETHODIMP CMyinterface::Get(double *x, double *y, double *ammun)

    to

    STDMETHODIMP CMyinterface::Get(double **x, double **y, double **ammun)
    {
    *y = 10; // Or what every value you use.
    }

    Because your trying to receive reference values from a COM object, you may need to pass in a double-dereference operator, to get the values from the COM object across to the VB client.

    You don't need to do anything in the client, just the server.

    Hope this helps.



  3. #3
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: VB client, VC server

    Hi, its got nothing to do with COM :-)

    This is VB syntax quirk. UNLIKE in VC,
    a definition of

    Dim x, y, z as Double
    means

    DIm X as Variant, y as Varient , z as Double




    Change it to
    DIm X as Double, y as Double , z as Double

    it should work





    RK

  4. #4
    Join Date
    Nov 1999
    Posts
    7

    Re: VB client, VC server

    Thanx ravi...i knew somewher i made a silly mistake...now the new problem's one of my client sends data to the server and the other retrieves the same data..the second client retrieves correct data...as long as the server's active...but after that it retrieves junk....how do i make the server always active....as long as the 2 clients r connected...thanx once again for ur help.


  5. #5
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: VB client, VC server

    In the server is strong ( in error handling) , COM makes sure that the server keeps running as long as any client is connected to it or keep a reference of the server. ( Another reason as to why even clients should do a clean exit!)

    I dont know, if you should make special efforts to keep the server alive.

    Dont just say:
    perror("Something went wrong!!");
    exit(1); type of codes, in the server

    When server not active, clients not able to communicate is just natural, right?

    In the client side, make sure that the server variable has global/modulelevel global scope so that you are sure. VB may generate error 91, but it could be negated with on Error resume next kind of code.

    That's being as general as i(t) can get!!!.

    RK

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

Featured