Hi,

I tried as follow and it works. First the ActiveX control needs to be instantiated and initialized completely. In your code rdp.GetOcs() will always return null due to that reason, and you get the exception.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
open System 
open AxMSTSCLib 
open MSTSCLib 
open System.Threading 
open System.Windows.Forms
open System.Drawing
 
[<STAThread>] 
do 
    let form = new Form();        
    let rdp = new AxMSTSCLib.AxMsRdpClient2()
    rdp.Size <- new Size(500,500)
 
    form.Load.Add( fun _ -> 
                    let secured = rdp.GetOcx() :?> (IMsTscNonScriptable) 
                    rdp.Server <- "127.0.0.1" 
                    rdp.UserName <- "test" 
                    secured.ClearTextPassword <- "test123" 
                    rdp.Connect() 
                    if rdp.Connected.ToString() = "0" then 
                        MessageBox.Show("not connected")  |> ignore
                    else 
                        MessageBox.Show("connected")  |> ignore                     
                  )
 
    form.Controls.Add(rdp)
    form.ShowDialog() |> ignore

Regards,
nyi nyi

By on 2/17/2011 12:16 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper