Results 1 to 36 of 36

Thread: Trying to use a service and service list only once.

  1. #1

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Trying to use a service and service list only once.

    Hi , I have multiple services that are called like:
    Dim m_client As ServiceReference1.DataServiceClient
    and a list that is called like:
    Dim copyerlist As List(Of ServiceReference1.copyer)

    I have multiple servers so in each on I have this service.
    Now If I need to initialize the service I'm forced to do a case an initialize the service and the list like so:

    Code:
        Select Case ServerLocation
     Case "192.168.1"
       m_client = New ServiceReference1.DataServiceClient
        copyerlist1 = New List(Of ServiceReference1.copyer)
     Case "192.168.2"
     m_client1 = New ServiceReference2.DataServiceClient
        copyerlist1 = New List(Of ServiceReference2.copyer)
    ...etc
    I was wondering if there is any other way so I can have only one service and list to use after the initialization? Maybe with Ienumerable?
    The above does not work but I'm trying to explain better on what I would like to have:
    Just for the list, for, example
    Code:
       Dim copyerlistGlobal As IEnumerable(Of copyer)
    case ...etc
    case1
     copyerlistGlobal = New List(Of ServiceReference1.copyer)
    case2
     copyerlistGlobal = New List(Of ServiceReference2.copyer)
    
    ...etc
    Any thoughts?


    Thanks.

    Edit.
    My service function is this (deeply apologize for the c#):
    public string xcop(List<copyer> inputCommands, bool overwr, string pass)

    will it make any difference if I change this to
    public string xcop(IEnumerable<copyer> inputCommands, bool overwr, string pass)
    and try the above calls?

    edit2.
    Hmm also the services would be of the exact same class that I put in listof(), using it in the local program (aka recreating the exact class of copyer from the WCF service) does not pass along. It will probably not work if i try to pass another similar copyer from another service reference but I have currently only one service set up so I can't try that right away.
    Last edited by sapator; Jan 7th, 2021 at 02:49 PM.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  2. #2

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    I'm searching for a day now struggling with enumerations generic types etc without finding anything so instead of doing a 10 select case for the servers, I'm using a list(of string) and I'm splitting a long strangechars string in the middle. Lame but if there is nothing else I can try...
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Trying to use a service and service list only once.

    What does ServiceReference1/2 represent?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  4. #4

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    Different WCF services on different Servers
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  5. #5
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Trying to use a service and service list only once.

    So what you're asking is how you can keep all these services in a single list instead of separate lists for each server?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  6. #6

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    Yes.
    The only thing I haven't tried is directcast but now I have changed the service so any attempts will be done tomorrow.
    Although the service works fine now so I will probably let it pass but I'm still curious.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  7. #7
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Trying to use a service and service list only once.

    The only reason I can see that you have them in different lists is if ServiceReference1 and ServiceReference2 are different types. Are they?

    The code you posted doesn't make it clear what they are. They could be variables that reference objects or they could be classes of which copyer is a static member. Which is it?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  8. #8

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    Hi.
    Exact same WCF services on different servers.
    copyer is a class with properties

    Public Class copyer
    {
    Public string Something {get; set;}

    Public string SomethingElse {get; set;}

    }
    more or less.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  9. #9
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Trying to use a service and service list only once.

    Well I don't get it. What is preventing you from putting all copyer objects in a single list regardless of which server they represent?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  10. #10

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    That what I thought.
    But it says something of Cannot Convert List(of copyer) to List(of servicereference1.copyer)
    Meaning I recreate the copyer Class in the Local program and try to pass it in the xcop function that accepts a List(of copyer
    The declaration is exactly the same but the one resides locally and the other in the remote service.
    The only way I can pass it is with servicereference1.copyer and not just (local) copyer.
    I also believe that the same issue happens when I try to pass a List(of servicereference2.copyer) that is the exact same class in another server , but not 100% sure about that, have to look it up.
    Unless I made a mistake in the re-cretion of the C# class to the local VB class but the servicereference2 is the same. I would have to look this up tomorrow (almost 3 in the morning here).
    Thanks, any comment will look it up tomorrow.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  11. #11
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Trying to use a service and service list only once.

    Wait a second is servicereference1 a class? You still haven't made that clear. I thought it was a variable.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  12. #12

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    Hi.
    C# WCF Service:
    Code:
    namespace MYVWOL
    {
        // Define a service contract.
        [ServiceContract(Namespace = "http://MyDataServices.foo.com")]
        public interface IDataService
        {
            [OperationContract]
      string xcop2(List<copyer> inputCommands, bool overwr);
    
    .....
    
      public class DataService : IDataService
        {
    
    .....
    
       public string xcop2(List<copyer> inputCommands, bool overwr)
            {
    ........
    
    
    
      public class copyer
    
    
        {
    
            public string server { get; set; }
           
    
            public string copyname { get;  set;}
            
    
        }
    
    }
    VB Local PC reference call on WCF service:

    Code:
    
            Dim cp As New List(Of copyer) ' local class
            Dim srv1 As ServiceReference1.DataServiceClient = New ServiceReference1.DataServiceClient
            Dim cp2 As New List(Of ServiceReference1.copyer)  ' WCF remote class
    
            Dim s1 As String = srv1.xcop2(cp2, True) 'ok
            Dim s2 As String = srv1.xcop2(DirectCast(cp, List(Of ServiceReference1.copyer)), True) '''' error List(of copyer) cannot be converted to List(of copyer)
    
    
    Public Class copyer
        Public Property server As String
        Public Property copyname As String
        Public Property ExtensionData As Runtime.Serialization.ExtensionDataObject  ''''This because the C# service class exposes this property by itself??? 'do not work if exists or not exist anyhow
    
    End Class
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  13. #13
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Trying to use a service and service list only once.

    Oh I think I understand what's happening here. It seems you were expecting that just because the copyer class in your VB code has the same name as the copyer class in the C# code that they would be polymorphic. No, it doesn't work like that. As far as the compiler is concerned, they are two different classes.

    Let me ask you something, is that C# code from different assembly/DLL than your VB code?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  14. #14

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    Hi.
    Yes I understand it won't work but isn't there is a way to it?
    For example somehow creating a new known type?
    Also If I had vs 2017 (I have 2015). Is creating a tuple an option or generic.MakeGenericType?
    Dim MyObject As New List(Of String, String) , is this suppose to work in vs 2017?
    Thanks.

    Edit:
    I'm using this
    Code:
        public string xcop3(List<List<string, string>> st)
            {
                return "0";
            }
    
      public class List<t1, t2>
        {
            public string server { get; set; }
            public string copyname { get; set; }
        }
    In theory, at least it would put the variables in a List(of List(of string,string)
    but using it in vb.net says "cannot be converted to ListOf(ListOf stringstring)
    stringstring? Seriously?

    works fine on vb like so:
    Code:
      Dim srl As New List(Of List(Of String, String))
            Dim y As New List(Of String, String)
            y.x = "aa"
            y.y = "asd"
    
            srl.Add(y)
    
    Class List(Of T1, T2)
        Public Property x As String
        Public Property y As String
    
    End Class
    but on the service no
    Code:
       Dim sr As New ServiceReference1.DataServiceClient
            Dim srl As New ServiceReference1.ListOfstringstring
            srl.copyname = "sa"
            srl.server = "asd"
            sr.xcop3(srl)
    It throws the stringstring error.
    Maybe I should turn the remote service on VB, C# is giving me a headache .
    Last edited by sapator; Jan 10th, 2021 at 01:22 PM.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  15. #15
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Trying to use a service and service list only once.

    Ok, I'm still not quite understanding what you really want to do here.

    Here's what we can do. Mock up a simple example of what your problem is and lets see if we can get to the core of what you're really asking. There are a lot of details in your actual problem that is getting in the way of me trying to flesh out the core of your problem. Give give a very very simple mock example of the issue you're getting into.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  16. #16

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    Hi.
    OK.
    So instead of this:


    Code:
    Dim sr1 as new servicereference1.
    Dim sr2 as new servicereference2.
    Dim sr3 as new servicereference3.
    
    dim L1 as new servicereference1.copyer  ''exact same class
    dim L2 as new servicereference1.copyer ''exact same class
    dim L3 as new servicereference1.copyer ''exact same class
    
    Select case somedecision 
    
    Case "decisionX"
    L1 = getdata1()
    sr1.xcop(L1)
    Case decisionXorY
    L2 = getdata1()
    sr2.xcop(L2)
    Case decisionYorZ
    L3 = getdata1()
    sr3.xcop(L3)
    
    .....
    I would like to do this:

    Code:
    
    Dim sr1 as new servicereference1.
    Dim sr2 as new servicereference2.
    Dim sr3 as new servicereference3.
    
    L1 = local.copyer
    L1 = getdata1()
    
    Select case somedecision 
    
    Case "decisionX"
    sr1.xcop(L1)
    Case decisionXorY
    sr2.xcop(L1)
    Case decisionYorZ
    sr3.xcop(L1)
    
    .....
    OR:

    Code:
    Dim sr1 as new servicereference1.
    Dim sr2 as new servicereference2.
    Dim sr3 as new servicereference3.
    
    'simulate the properties of the copyer class, for example:'
    Dim L1 as new List(Of string,string,boolean,integer)
    L1 = getdata1()
    
    Select case somedecision 
    
    Case "decisionX"
    sr1.xcop(L1)
    Case decisionXorY
    sr2.xcop(L1)
    Case decisionYorZ
    sr3.xcop(L1)
    
    
    .....
    Last edited by sapator; Jan 11th, 2021 at 12:09 PM.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  17. #17
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Trying to use a service and service list only once.

    Something doesn't make sense here. Here:-
    vbnet Code:
    1. dim L1 as new servicereference1.copyer  ''exact same class
    2. dim L2 as new servicereference1.copyer ''exact same class
    3. dim L3 as new servicereference1.copyer ''exact same class

    You're instantiating new copyer instances but then in your switch statement you're replacing the references with the return value of getdata:-
    Code:
    L1 = getdata1()
    ...
    Why create the objects in the first place if you're not actually gonna use them?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  18. #18

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    getdata1() can be any function that will fill up the copyer class

    The getdata1 will fill up a copyer class nomatter from which service reference it is called.
    I put it there so I can show that the copyer class if filled with the exact same data from the local app, regardless of the servicereference that is called from.

    So sr1 = getdata1()
    sr2 = getdata1()
    sr3 = getdata1()

    always the same data.

    Code:
    Case "decisionX"
    sr1.xcop(L1)  
    sr2.xcop(L1)  
    Case decisionXorY
    sr2.xcop(L1)
    sr1.xcop(L1)
    Case decisionYorZ
    sr3.xcop(L1)
    For example here I have X decision, so I will use sr1 and sr2 but not sr3. It's not an actual example, just wanted to show that I will be using more than one service at a time. Granted Case may not have been the best example of all put you get the idea.
    Last edited by sapator; Jan 11th, 2021 at 12:32 PM.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  19. #19

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    Hi.
    It appears that I can do that in VS2015: List(Of Tuple(Of String, String, String))
    I could check this out tomorrow..
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  20. #20
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Trying to use a service and service list only once.

    I still don't get it. You said you wanted to do something like this:-
    Code:
    Dim sr1 as new servicereference1.
    Dim sr2 as new servicereference2.
    Dim sr3 as new servicereference3.
    
    L1 = local.copyer
    L1 = getdata1()
    
    Select case somedecision 
    
    Case "decisionX"
    sr1.xcop(L1)
    Case decisionXorY
    sr2.xcop(L1)
    Case decisionYorZ
    sr3.xcop(L1)
    
    .....
    So why not just do that. I don't see where the problem is.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  21. #21

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    But local.copyer will not work with remote copyer as you said it will not be polymorphic.

    Edit:

    I can also do this:
    Code:
      Dim x As New List(Of String())
            Dim x11() As String = {"arg1", "arg2"}
            Dim x12() As String = {"arg3", "arg4"}
            x.Add(x11)
            x.Add(x12)
    
            Dim val1() As String
        
                val1 = x(1)
    That will take the 2 or more arguments but the array can only be of a specific type.
    Last edited by sapator; Jan 11th, 2021 at 02:56 PM.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  22. #22
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Trying to use a service and service list only once.

    Hmmm.....so you have a want to use your local copyer class. However, where does the service copyer class come in. Why does that class have to be involved at all. What is the relationship between the local copyer class and the service copyer class.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  23. #23

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    It doesn't have to be a Local class.
    I just want a Class that will intercommunicate with all the services.
    If I pass a known type like List(Of String()) or a dictonary or an arraylist then there is no issue. If i try to pass a class with properties then it's no go.
    Current;y I have moved along from this , just asking for educational purposes.
    The copyer Class is an exact duplicate of the copyer Class that reside in every servicereference on every server. It has to be used as it is passed as a parameter in the xcop servicereference fucntion . Now even if it is an exact duplicate it cannot be used as we saw in the previous posts. So "function xcop(List(of copyer)" That is in every service reference on every server. Locally I tried to create an exact duplicate of the copyer class so I can pass it to servicereference.xcop function, that does not work.
    That is fine, is there something that can be used other than known types?
    Last edited by sapator; Jan 11th, 2021 at 05:52 PM.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  24. #24
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Trying to use a service and service list only once.

    I think your problem is coming into focus now. I had a very similar problem when I was designing a TCP/IP protocol for one of my programs. The protocol was a message protocol and I used classes to represent messages. The problem was that I needed to use the same class in both client and server applications. The way I solved it was by creating a separate assembly that contained only the protocol classes and then I had my client application and server application use the classes from identical copies of the assembly. It worked beautifully. The only cost was a responsibility to always use the EXACT same copy of the "middle man" protocol assembly for both client and server. So if I made any changes to the protocol assembly, I had to always make sure that both clients and server used the same version.

    Your problem sounds like something very similar.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  25. #25

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    Hi.
    Yes that would be a good solution. The issue here is that the servers are not in parallel, not communicating with each other or accessing a common reference server, so I do not have a "middle man" reference point that all the servers can connect to.
    Can it be done with the current configuration?

    P.S. Thanks for sticking around.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  26. #26
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

    Re: Trying to use a service and service list only once.

    Quote Originally Posted by sapator View Post
    Hi.
    Yes that would be a good solution. The issue here is that the servers are not in parallel, not communicating with each other or accessing a common reference server, so I do not have a "middle man" reference point that all the servers can connect to.
    Can it be done with the current configuration?

    P.S. Thanks for sticking around.
    Are you responsible for the servers and the application running on them? The servers wouldn't need to communicate with each other or any middle man, they would need to be slightly rewritten and redeployed (as would the client application).

  27. #27

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    No I'm not responsible.
    But how would the configuration work. I'm curious.
    From what I can think of is a common dll on all servers with the class needs to be involved or that dll on the GAG of every server but that requires, if changed, a fix on (8-10) x 2 servers every time.
    Thanks.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  28. #28
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

    Re: Trying to use a service and service list only once.

    Quote Originally Posted by sapator View Post
    No I'm not responsible.
    But how would the configuration work. I'm curious.
    From what I can think of is a common dll on all servers with the class needs to be involved or that dll on the GAG of every server but that requires, if changed, a fix on (8-10) x 2 servers every time.
    Thanks.
    Pretty much what would be required...

    If all the servers have a DataServiceClient that exposes the same methods I suppose it might be possible to modify the auto-generated code by extracting an interface and making all of the auto-generated classes implement this interface...

    Then again, it has been a while since I have worked with a service reference but is it possible to set the url of the DataServiceClient when you create it? If so you would only need a single DataServiceClient nad when you instantiate it just point to to the correct url. Does the DataServiceClient's constructor accept any parameters?

  29. #29

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    Yes there url is there.
    But how would I point to a single url?
    Servers are something like \\100.100.1.15:8080 , \\100.100.2.15:8080, \\100.100.3.15:8080 etc , I cannot point ,let's say. server \\100.100.1.15:8080 to \\100.100.2.15:808 , that is not allowed.
    I cannot even point to a common reference server for all servers, let's say , \\100.100.100.100:8080 that is not allowed.
    Locally I can point to every server but it will still have to pass though the WCF, so if I have the same dll on all servers then i will not work, as pointing to a servicereference1.mydll for server \\100.100.1.15:8080 with the class that I want and try to passing that class to servicereference2.mydll \\100.100.2.15:8080 will not work for the issues mentioned above.
    It would work if every server was pointing to \\100.100.100.100:8080 and my local server took the dll from there , err, probably but the again I'm not sure as I would still have to pass from servicereference1.mydll for server \\100.100.1.15:8080 that would reference the main server dll and at this point I'm not sure if it would work, over these days no call will work whatsoever from Local to WCF unless it is a one to one call, meaning Local.servicereference1.commonclass to \\100.100.1.15:8080 , Local.servicereference2.commonclass to \\100.100.2.15:8080 etc , doing Local.commonclass to servicereferenceWhatever.class to \\100.100.Whatever.15:8080 will not work. The examples that I have seen for normalizing these a over 100 lines of convertions per property and I'm beginning to thing MS developers where smoking something in particular when they made WCF.
    I've used WCF again in the past from websites (I had some post that I eventually asked and figured out myself how to fix things , especially with mex ) and it gave me hell.
    So why did I used WCF? It was the only solution to pass a WCF inside a Windows service, that and WEB API that I've skipped since I was ending the development when Niya suggested a possible solution but that is that. I will never ever use WCF again intentionally. I have fixed the issues I had a couple of days now so this is just from educational purposes but I'm beginning to think that it's not ever worth that since for me that is that, I will never use it again.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  30. #30
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

    Re: Trying to use a service and service list only once.

    Quote Originally Posted by sapator View Post
    Yes there url is there.
    But how would I point to a single url?
    Servers are something like \\100.100.1.15:8080 , \\100.100.2.15:8080, \\100.100.3.15:8080 etc , I cannot point ,let's say. server \\100.100.1.15:8080 to \\100.100.2.15:808 , that is not allowed.
    I cannot even point to a common reference server for all servers, let's say , \\100.100.100.100:8080 that is not allowed.
    Locally I can point to every server but it will still have to pass though the WCF, so if I have the same dll on all servers then i will not work, as pointing to a servicereference1.mydll for server \\100.100.1.15:8080 with the class that I want and try to passing that class to servicereference2.mydll \\100.100.2.15:8080 will not work for the issues mentioned above.
    It would work if every server was pointing to \\100.100.100.100:8080 and my local server took the dll from there , err, probably but the again I'm not sure as I would still have to pass from servicereference1.mydll for server \\100.100.1.15:8080 that would reference the main server dll and at this point I'm not sure if it would work, over these days no call will work whatsoever from Local to WCF unless it is a one to one call, meaning Local.servicereference1.commonclass to \\100.100.1.15:8080 , Local.servicereference2.commonclass to \\100.100.2.15:8080 etc , doing Local.commonclass to servicereferenceWhatever.class to \\100.100.Whatever.15:8080 will not work. The examples that I have seen for normalizing these a over 100 lines of convertions per property and I'm beginning to thing MS developers where smoking something in particular when they made WCF.
    I've used WCF again in the past from websites (I had some post that I eventually asked and figured out myself how to fix things , especially with mex ) and it gave me hell.
    So why did I used WCF? It was the only solution to pass a WCF inside a Windows service, that and WEB API that I've skipped since I was ending the development when Niya suggested a possible solution but that is that. I will never ever use WCF again intentionally. I have fixed the issues I had a couple of days now so this is just from educational purposes but I'm beginning to think that it's not ever worth that since for me that is that, I will never use it again.
    Just to make sure I have understood things....

    1. You have a local application that is a client to three remote services.
    2. These remote services are all different instances of the same service. i.e. they look and behave the same, same functionality, same data being sent back and fore.
    3. You want you local application to be able to use a single set of classes that can work with all the remote services, rather than a specific set of classes for each service reference. e.g. you want one DataClient that can work with all of the remote servers.

    Is that correct?

  31. #31

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    Yes if it doesn't involve writing hundred lines and lines of code that I saw in some examples and is hardly worth the try.
    P.S. The class would be passed as a ListOf(theclass)
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  32. #32
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

    Re: Trying to use a service and service list only once.

    Quote Originally Posted by sapator View Post
    Yes if it doesn't involve writing hundred lines and lines of code that I saw in some examples and is hardly worth the try.
    P.S. The class would be passed as a ListOf(theclass)
    As a quick experiment.. is it possible to create and instance of ServiceReference1.DataClient and pass in the address of either the ServiceReference2 or ServiceReference3 servers? If so does that work without errors?

  33. #33

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    No that does not work.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  34. #34
    Fanatic Member
    Join Date
    Jun 2019
    Posts
    557

    Re: Trying to use a service and service list only once.


  35. #35

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Trying to use a service and service list only once.

    What does this have to do with implementing an excoteric class?
    That just creates the endpoint manually.
    Anowho, I'm kinda done with this question , the answer is most probably "Don't use WCF".
    So thanks for taking it this far.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  36. #36
    Fanatic Member
    Join Date
    Jun 2019
    Posts
    557

    Re: Trying to use a service and service list only once.

    You have 3 different instances of same services but you probably added using "Add service reference" using URLs for each server. This generates configuration in app.config for each service. But the service is the same - all "contracts" are the same and you don't need to have 3 different references to be added. You can create as many instances you want in code, set endpoints and use according your app requirements.

    And yes, WCF sucks. It is so complicated and the overhead is too much just to create simple service and use it. This is just one of the reasons Microsoft left to the community to develop WCF for .NET Core (now .NET 5).

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