At work we use Terminal Services a great deal. It allows us to use many PC’s all without getting up or having our cubes filled with them. Also we often have a “when you’re awake you work” processing load so we’re connecting from home, vacation, the parents, hotels, etc, etc, all the time. Terminal Services/Remote Desktop all makes this possible
To date we’ve used the Terminal Services MMC snap-in to manage our connections. While this works, it’s pretty bare bones and there are few configuration options.
So as a side/personal project I’ve want to create our own TS connection wrapper app. I had some time tonight, so I started with the R&D.
Of course I want to build this in VB7.1…
Well long story short, it’s been a pain. The hard part is getting the RD control to host on a form. The funny part is that it’s easy in VB6… Dogh!
Googling this for a while helped me find a couple sites that really helped me over this hump. I wanted to make sure I captured them here (leach a little their data in case they go away) for any future need.
Between the two of these and some minor open heart surgery on the VB.Net sample I now have a working starting point for my app…
Failure to add msrdp.ocx control to C#.NET or VB.NET form
“… 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(); ((System.ComponentModel.ISupportInitialize)(this.axMsTscAx1)).BeginInit();
//
// axMsTscAx1
//
this.axMsTscAx1.Enabled = true;
this.axMsTscAx1.Location = new System.Drawing.Point(58, 17);
this.axMsTscAx1.Name = "axMsTscAx1"
this.axMsTscAx1.OcxState =
((System.Windows.Forms.AxHost.State)(resources.GetObject("axMsTscAx1.OcxStat
e")));
this.axMsTscAx1.Size = new System.Drawing.Size(192, 192);
this.axMsTscAx1.TabIndex = 1;
....
this.Controls.Add(this.axMsTscAx1);
((System.ComponentModel.ISupportInitialize)(this.axMsTscAx1)).EndInit();
HTH.
Kevin Yu”
http://dev.remotenetworktechnology.com/news.htm
“… MsRdpNET - a simple demo of wrapping Microsoft's redistributable RDP web client inside a VB.NET project. …”
Here’s the “magic” from the above VB sample (which can be thought of as a C# translation of the above forum post).
“Friend WithEvents AxMsRdpClient21 As AxMSTSCLib.AxMsRdpClient
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
….
Me.AxMsRdpClient21 = New AxMSTSCLib.AxMsRdpClient
CType(Me.AxMsRdpClient21, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'AxMsRdpClient21
'
Me.AxMsRdpClient21.Dock = System.Windows.Forms.DockStyle.Top
Me.AxMsRdpClient21.Enabled = True
Me.AxMsRdpClient21.Name = "AxMsRdpClient21"
Me.AxMsRdpClient21.OcxState = _
CType(resources.GetObject("AxMsRdpClient21.OcxState"), System.Windows.Forms.AxHost.State)
Me.AxMsRdpClient21.Size = New System.Drawing.Size(792, 600)
Me.AxMsRdpClient21.TabIndex = 0
‘…
CType(Me.AxMsRdpClient21, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub”
When everything is right (with both the aximp’ed assemblies and the VB code), you’ll see the RDP Client control on the form at runtime and be ready for the races…