这是new
我表单中的方法:
Public Sub New(ByVal ConnectionString As String, ByVal ConSql As SqlClient.SqlConnection, ByVal Daman As Array, ByVal SDate As Integer, ByVal FDate As Integer)
Threading.Thread.CurrentThread.TrySetApartmentState(Threading.ApartmentState.STA)
' This call is required by the Windows Form Designer.
'Error Appear in this line
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Me.Sto_TypeFormFrameTableAdapter.Connection.ConnectionString = ConnectionString
Me.Sto_typeformTableAdapter.Connection.ConnectionString = ConnectionString
con = ConSql
com.Connection = con
ConNew = ConnectionString
DamaneCod = Daman
Start = SDate
Final = FDate
Fill()
End Sub
当我创建表单的新对象时,该InitializeComponent
命令出错。
错误信息是:
在进行 OLE 调用之前,必须将当前线程设置为单线程单元 (STA) 模式。确保您的 Main 函数上标记了 STAThreadAttribute。
此表单在一个项目中,其输出是另一个项目的 DLL 文件,并且在使用此 DLL 文件的另一个项目中不会出现错误。我该如何解决?