PC Review


Reply
Thread Tools Rate Thread

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

 
 
Bill Struve
Guest
Posts: n/a
 
      11th Apr 2005
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"
message:

"Compiler errors occured when generating a Windows Forms wrapper for ActiveX
control 'AxMSTSCLib'. Source code saved in '...AxInterop.MSTSCLib.cs'.
cocuments 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
cocuments 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 "cocuments and Settings\struvew\Local
Settings\Temp\8rzmsoz" either before, during, or after the above error
message.

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"
above:

Private Sub Form_Load()
MsRdpClient.DesktopHeight = Screen.Height / Screen.TwipsPerPixelY
MsRdpClient.DesktopWidth = Screen.Width / Screen.TwipsPerPixelX
MsRdpClient.FullScreen = True
UsersForm.Height = (MsRdpClient.DesktopHeight + 30) *
Screen.TwipsPerPixelY
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 = _
"D:\\Projects\\RMOnlineQuotes\\bin\\RunApplication.exe
RMAdministrativeTools.exe"
MsRdpClient.FullScreen = True
MsRdpClient.Connect
End Sub

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

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?


 
Reply With Quote
 
 
 
 
Stephan Steiner
Guest
Posts: n/a
 
      11th Apr 2005
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.

Regards
Stephan


 
Reply With Quote
 
 
 
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      12th Apr 2005
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();
((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
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
this.Controls.Add(Control) Does Not Add Control to child collection (this.Controls.Count == 0) Chad Scharf Microsoft ASP .NET 3 18th Oct 2007 04:53 PM
Showing 1 control inside a 2nd control where the 2nd control is a derived control. malcolm Microsoft Dot NET Framework Forms 0 10th Jun 2004 10:29 PM
Boot failure after power failure Rob Windows XP General 12 29th May 2004 01:17 AM
Login Failure due to: Driver failure Ryan Windows XP Networking 1 23rd Oct 2003 04:13 PM
router gateway failure/WMI failure/repository rebuild failure Bobby Windows XP Networking 2 21st Aug 2003 02:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:15 PM.