none
Issue with using AdvancedSettings2.LoadBalanceInfo

    Question

  • Hi,

    I am trying to use the 'AxInterop.MSTSCLib' and create a RDP Session in a C# Winfroms Application.

    The issue I am facing is especially with the LoadBalanceInfo which is available in the 'AdvancedSettings2.LoadBalanceInfo', as I need to send RDP Routing information as a part of the connection request. The issue is the Connect() method just stits there trying to connect even after 10 mins.

    When I try this as a normal .rdp file and open it using the "Remote Desktop Connection" available in Windows, I am able to connect.

    So, I have done a network trace on both the tools the Remote Dektop Connection tool in Windows and also the request that my code was sending and I see the following difference.

    Windows RDP :

    0000  00 22 3f 52 28 ba 00 24  d6 28 ea 30 08 00 45 00   ."?R(..$ .(.0..E.
    0010  00 5e 35 22 40 00 80 06  db 73 c0 a8 00 0b 41 34   .^5"@... .s....A4
    0020  e8 1c e0 f1 0d 3d b7 f0  c9 ef 2a b7 b5 d7 50 18   .....=.. ..*...P.
    0030  00 44 91 2e 00 00 03 00  00 36 31 e0 00 00 00 00   .D...... .61.....
    0040  00 43 6f 6f 6b 69 65 3a  20 6d 73 74 73 68 61 73   .Cookie:  mstshas
    0050  68 3d 52 44 53 43 48 23  52 44 53 43 48 5f 49 4e   h=RDSCH# RDSCH_IN
    0060  5f 30 0d 0a 01 00 08 00  03 00 00 00               _0...... .... 

    My Code :

    0000  00 22 3f 52 28 ba 00 24  d6 28 ea 30 08 00 45 00   ."?R(..$ .(.0..E.
    0010  00 7d 31 b5 40 00 80 06  de c1 c0 a8 00 0b 41 34   .}1.@... ......A4
    0020  e8 1c e0 c5 0d 3d ee cc  6b 83 a7 23 63 5f 50 18   .....=.. k..#c_P.
    0030  00 44 13 2f 00 00 03 00  00 55 50 e0 00 00 00 00   .D./.... .UP.....
    0040  00 43 00 6f 00 6f 00 6b  00 69 00 65 00 3a 00 20   .C.o.o.k .i.e.:.
    0050  00 6d 00 73 00 74 00 73  00 68 00 61 00 73 00 68   .m.s.t.s .h.a.s.h
    0060  00 3d 00 52 00 44 00 53  00 43 00 48 00 23 00 52   .=.R.D.S .C.H.#.R
    0070  00 44 00 53 00 43 00 48  00 5f 00 49 00 4e 00 5f   .D.S.C.H ._.I.N._
    0080  00 30 00 01 00 08 00 00  00 00 00                  .0...... ...

    Could be some encoding issue or something. Can Any one help me how to send the LoadBalanceInfo along with my request?

    Thanks & Regards.

    -Kiran Grandhe.

    Friday, March 30, 2012 6:51 AM

Answers

All replies

  • Hi,

    According to the description, the issue seems to be related to development. As we are mainly focus on the management issue and here is not the best support resource for development, it is recommend you to initial a new thread in our MSDN forum.
     

    MSDN forum
    http://social.msdn.microsoft.com/Forums/en-US/categories/


     


    Technology changes life……

    Tuesday, April 03, 2012 7:38 AM
    Moderator
  • Did you find a solution to this problem?  I'm having the same exact issue.
    Monday, February 04, 2013 5:09 PM
  • I had this same problem recently when trying to add support for Windows Azure RDP connections to the open-source Terminals program.  I don't know if this is the best solution, but I basically took the string and re-encoded it as UTF-8 inside of the UTF-16 string, so it would have the right byte-for-byte value.  Basically squishing the equivalent of two one-bytes characters into each two-byte character in .NET strings.  The only catch is that the number of bytes must be even, so I pad the end with a space if it is odd, which seems to work okay:

    var temp = LoadBalanceInfo;
    if (temp.Length % 2 == 1) temp += " ";
    temp += "\r\n";
    var b = Encoding.UTF8.GetBytes(temp);
    var final = Encoding.Unicode.GetString(b);
    activeX.AdvancedSettings2.LoadBalanceInfo = final;

    Also LoadBalanceInfo must be suffixed by "\r\n" to work properly, as you can see in the sample WireShark trace of Windows RDP ("0d 0a").

    I must say thank you for your post, because your question was what first gave me the clue to dig into the network trace with WireShark, and I wouldn't have found my solution without that key insight :)

    Friday, August 16, 2013 1:56 PM