我正在通过Visual Studio运行一个应用程序,该程序将构建一个特定项目并引用多个其他项目。我在项目中的一个文件中遇到InvalidCastException。
我尝试为objEmail Object属性创建一个实例。它对我没有帮助。
Public objEmail As TApplication.ITDocument
Public Function CreateObject6(progId As String, Optional serverName As String = "") As Object
'This is from a [metadata] file and I have pasted it here for better understanding.
Function Init(ByRef p_objMainForm As Object, ByRef p_objSystem As ISystemInfo, ByRef p_objDocTemplate As ITDocumentTemplate, ByRef p_objDocManager As IDocManager, ParamArray p_varParamArray() As Object) As Boolean
'This is the function that the objEmail appears to call and error appears.
objEmail = CreateObject6("cssEmail.cEmail")
WriteToActivityLog("SubMain Line 3.2")
Dim mainFormInstance As Object = frmTBWMainForm
objEmail.Init(mainFormInstance, SystemObject, DocTemplate, objDocManager) 'Error appears in this line (InvalidCastException: Specified cast is not valid)