鱼C论坛

 找回密码
 立即注册
查看: 2871|回复: 1

c# 问题(求大神们帮助)

[复制链接]
发表于 2016-11-16 12:57:44 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
C# 窗口启动时无法启动,from1 加上webbroser1 控件,,结果 出错 ,错误提示是:


当前线程不在单线程单元中,因此无法实例化 ActiveX 控件


这个 问题怎么解决?

网上搜索了 但是  解决方案是:


<MTAThread()> _
    Public Sub main()
        '  Application.Run(Fr1)
        '  Application.Run(Fr2)
        '   Application.Run(Fr3)

        'Dim MyThread As System.Threading.Thread
        'MyThread = New System.Threading.Thread(AddressOf LaunchForm)
        '' Specify that the MyThread thread runs in an MTA.
        'MyThread.ApartmentState = Threading.ApartmentState.STA
        'MyThread.Name = "InfraServiceThread"
        'MyThread.Start()

        Dim thd As New Thread(New ThreadStart(AddressOf LaunchForm))
        thd.SetApartmentState(ApartmentState.STA)
        '  thd.IsBackground = True
        thd.Start()
    End Sub
    Public Sub LaunchForm()
        ' Run a standard application message loop on the current thread.
        Application.Run(New MainForm)
    End Sub

但是 这个代码 放在那里?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-6-17 23:19:58 | 显示全部楼层
这是MFC板块 你题错了吧
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-3-29 14:08

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表