Failure to add msrdp.ocx control to C#.NET or VB.NET form.

Discussion in 'Microsoft C# .NET' started by Bill Struve, Apr 11, 2005.

  1. Bill Struve

    Bill Struve Guest

    Need: Auto-logon to a terminal server, start a program, and, when the user
    is quits the program, auto-logoff.

    Problem: When msrdp.ocx is added to the Toolbox, attempting to draw the
    control on the form gives the following "Microsoft Development Environment"

    "Compiler errors occured when generating a Windows Forms wrapper for ActiveX
    control 'AxMSTSCLib'. Source code saved in '...AxInterop.MSTSCLib.cs'.
    c:Documents and Settings\struvew\Local
    Settings\Temp\8rzmsoz_.0.cs(493,24):error CS0037: Cannot convert null to
    'MSTSCLib.AutoReconnectContinueState' because it is a value type
    c:Documents and Settings\struvew\Local
    Settings\Temp\8rzmsoz_.0.cs(1282,24):error CS0037: Cannot convert null to
    'MSTSCLib.AutoReconnectContinueState' because it is a value type"

    Note that I can find no files like "c:Documents and Settings\struvew\Local
    Settings\Temp\8rzmsoz" either before, during, or after the above error

    There is a similar message from either VC.NET or VB.NET, and the control
    never appears on the form.

    My workaround has been to use VB6, since the control can be drawn on a VB6
    form with no problem. The following code is then used to satify the "Need"

    Private Sub Form_Load()
    MsRdpClient.DesktopHeight = Screen.Height / Screen.TwipsPerPixelY
    MsRdpClient.DesktopWidth = Screen.Width / Screen.TwipsPerPixelX
    MsRdpClient.FullScreen = True
    UsersForm.Height = (MsRdpClient.DesktopHeight + 30) *
    UsersForm.Width = MsRdpClient.DesktopWidth * Screen.TwipsPerPixelX
    MsRdpClient.Height = MsRdpClient.DesktopHeight * Screen.TwipsPerPixelY
    MsRdpClient.Width = MsRdpClient.DesktopWidth * Screen.TwipsPerPixelX
    MsRdpClient.Server = "PC07405"
    MsRdpClient.UserName = "******"
    MsRdpClient.Domain = "PC07405"
    MsRdpClient.AdvancedSettings2.ClearTextPassword = "******"
    MsRdpClient.SecuredSettings.StartProgram = _
    MsRdpClient.FullScreen = True
    End Sub

    Note that I changed the user name and password to ***** after pasting into

    After making the VB6 executable, I call it from C#. Although this works OK,
    it is UGLYto have to write part in C# and part in VB6.

    Is there anyting I can do so the auto-generated "Windows Forms wrapper" will
    complete without error?
    Bill Struve, Apr 11, 2005
    1. Advertisements

  2. I wrote my own C# RDP client based on the ocx.

    I only added the ActiveX component in code rather than graphically, but that
    worked out nicely. There's just one thing.. I don't get any events thrown
    from the control for some wicked reason.. I have the listeners properly set
    up, but if the user logs off, the control just turns white and the window
    never closes (the listener for the disconnect event would close the window,
    but since it's never fired).

    I don't have access to the code right now, but if you're interested, I can
    post the relevant lines for you later on.

    Stephan Steiner, Apr 11, 2005
    1. Advertisements

  3. Hi Bill,

    First of all, I would like to confirm my understanding of your issue. From
    your description, I understand that when you have drag and drop a Terminal
    Services Control on a windows form, a compiler error was generated. If
    there is any misunderstanding, please feel free to let me know.

    Based on my research, this is a known issue. The wrapper generater fails to
    generate correct method for returning an enum value. Here is a workaround.

    1. md c:\temp
    2. cd c:\temp
    3. %<SDK bin directory>%\aximp.exe %windir%\system32\mstscax.dll
    This will generate MSTSCLib.dll and AxMSTSCLib.dll.
    Make sure Interop.MSTSCLib.dll and AxInterop.MSTSCLib.dll have been deleted
    in the obj and bin\Debug directories.
    4. Copy the generated files (without renaming) - MSTSCLib.dll and
    AxMSTSCLib.dll into the project's obj directory.
    5. In the project's references, add MSTSCLib.dll and AxMSTSCLib.dll from
    the obj directories.
    6. Now, instead of drag-drop'ing the control from the toolbox, write code
    to add the control:
    Goto Form.cs code view
    Declare: private AxMSTSCLib.AxMsTscAx axMsTscAx1;
    In InitializeComponent:
    this.axMsTscAx1 = new AxMSTSCLib.AxMsTscAx();

    // axMsTscAx1
    this.axMsTscAx1.Enabled = true;
    this.axMsTscAx1.Location = new System.Drawing.Point(58, 17);
    this.axMsTscAx1.Name = "axMsTscAx1"
    this.axMsTscAx1.OcxState =
    this.axMsTscAx1.Size = new System.Drawing.Size(192, 192);
    this.axMsTscAx1.TabIndex = 1;



    Kevin Yu
    "This posting is provided "AS IS" with no warranties, and confers no
    Kevin Yu [MSFT], Apr 12, 2005
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. none

    Dynamic OCX control creation in DotNet

    none, Jun 24, 2005, in forum: Microsoft C# .NET
  2. Guest

    How to create OCX Control

    Guest, Jul 6, 2005, in forum: Microsoft C# .NET
    Carlos J. Quintero [.NET MVP]
    Jul 6, 2005
  3. Guest
    Jun 26, 2006
  4. Guest

    Ocx does not add to Windows Form in Vs2005

    Guest, Aug 13, 2006, in forum: Microsoft C# .NET
    Aug 13, 2006
  5. E L

    using old ocx control

    E L, Feb 12, 2008, in forum: Microsoft C# .NET
    Nicholas Paldino [.NET/C# MVP]
    Feb 12, 2008

Share This Page