任何人都可以帮助我,Visual Basic 应用程序提示我一条消息“对象引用未设置为对象的实例”。我在一个解决方案中有 2 个项目。一种是用c#开发的,另一种是用vb开发的。我在 vb 项目中调用 c# 项目的方法。VB代码是:
Dim objUserProfileSystem As New IndexCatalogSystem() // c# project class
Dim Ds_Themes As New DataSet() //dataset
Ds_Themes = objUserProfileSystem.FillThemes(msg, 1) //c# class method returning dataset
ThemeID = Ds_Themes.Tables(0).Rows(0)("ThemeID") //getting themeid from dataset
我正在从 c# 应用程序调用 vb 应用程序。喜欢:
System.Diagnostics.Process.Start(Application.StartupPath + "\\DocumentViewer.exe ", " (" + val + ") ");
当我单独调试 vb 项目时它工作正常,当我从 c# 应用程序调用 vb 应用程序时,它提示错误。我错过了任何 .net 框架参考吗?
这是 Fill_Theme 方法。
public DataSet FillThemes(ref String msg, int UserID)
{
try
{
//inilialize the Connection
Connection objCon = new Connection();
if (objCon.Ini_Connection(ref msg) == true)
{
//declare data set
DataSet DsGroup = new DataSet();
//declare data adapter
SqlDataAdapter DaRole = new SqlDataAdapter();
//initialize Sql Select Command and fill dataset
DaRole.SelectCommand = new SqlCommand("SELECT ThemeID FROM DMUsers where UserID = " + PARA_User_ID, objCon.con);
DaRole.SelectCommand.Parameters.Add(PARA_User_ID, SqlDbType.Int).Value = UserID;
DaRole.SelectCommand.CommandType = CommandType.Text;
DaRole.Fill(DsGroup, "DMUsers");
//Dispose object
objCon.Dispose_Con(ref msg);
DaRole.SelectCommand.Dispose();
DaRole.Dispose();
//Return Folder Dataset
objCon.Dispose_Con(ref msg);
return DsGroup;
}
else
{
msg = "Connect ion fail contact Administrator";
}
return null;
}
我开发的整个方法称为主题。
Private Sub Themes()
Dim objUserProfileSystem As New IndexCatalogSystem()
Dim Ds_Themes As New DataSet()
Ds_Themes = objUserProfileSystem.FillThemes(msg,modCommon.UserID)
ThemeID = Ds_Themes.Tables(0).Rows(0)("ThemeID")
If Ds_Themes IsNot Nothing Then
If ThemeID = 1 Then
MessageBox.Show("6")
THEMES3Blue()
ElseIf ThemeID = 2 Then
THEMES2Olive()
ElseIf ThemeID = 3 Then
THEMES1Silver()
Else
THEMES1Silver()
End If
End If
End Sub