You need something to bind the attribute to, a do will do good, try:

1
2
3
4
[<STAThread>]

do Application.Run(form)
By on 10/1/2008 4:20 AM ()

thanks for your reply Torbjorn....

After using

1
2
[]
do Application.Run(form)

it will given same error...
Thanks

By on 10/1/2008 4:31 AM ()

You need something to bind the attribute to, a do will do good, try:

1
2
3
4
[<stathread>]

do Application.Run(form)

That brings up a good point. Here are some other ways to apply the attribute.

You can apply the attribute to any module level action. So this is valid as mentioned above:

1
2
3
4
let form = new Form()
    
[<STAThread>]
do Application.Run(form)

The do is optional:

1
2
3
4
let form = new Form()
    
[<STAThread>]
Application.Run(form)

You can also apply the STAThread attribute to a class member:

1
2
3
4
5
6
type MyApp() =
    let form = new Form()
    
    [<STAThread>]
    member this.Run() =
        Application.Run(form)

But as I mentioned above, you cannot apply the attribute at the function level. So this is invalid:

1
2
3
4
5
let form = new Form()
    
let run() =
    [<STAThread>]
    Application.Run(form)
By on 10/1/2008 4:31 AM ()

Functions can only have attributes at the Module or Class levels so this is invalid:

1
2
3
4
5
6
let run() =
    let form = new Form()
    
    [<STAThread>]
    let main() =
        Application.Run(form)

But this is valid:

1
2
3
4
5
let form = new Form()
    
[<STAThread>]
let run() =
    Application.Run(form)
By on 10/1/2008 4:20 AM ()

after using

1
2
3
[<STAThread>]
  let run() = 
   Application.Run(form)

it will still given same error error

By on 10/1/2008 4:29 AM ()
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