Home > Net >  The codesoft problem "will object reference not set to an instance of an object"
The codesoft problem "will object reference not set to an instance of an object"

Time:10-05

The younger brother recently in write a c # call codesoft applications, need to read variables in codesoft file, and then in a c # program assignment, and then print, but the following problems please eldest brother elder brothers help to look at? Thank you very much!



ApplicationClass LBL=new ApplicationClass ();

Try
{
LBL. Documents. Open (@ ";" , false);
//the Document doc=new Document ();
Document doc=LBL. ActiveDocument;
Doc. Variables. FormVariables. Item (variable "0"). The Value=https://bbs.csdn.net/topics/textBox1.Text.Trim ();
Doc. Variables. FormVariables. Item (" 1 "variable). Value=" https://bbs.csdn.net/topics/1234325435465676576876876 ";
Doc. PrintDocument (1);
Doc. Close (false);
}
The catch (Exception ex)
{
MessageBox. Show (ex. Message);
LBL. Quit ();
}



CodePudding user response:

Doc. Variables. FormVariables=null!
His breaking point and have a look, don't interrupt point?
https://jingyan.baidu.com/article/cb5d6105e6309c005c2fe0f5.html

CodePudding user response:

This kind of problem, a breakpoint can solve,

CodePudding user response:

Using breakpoint test also found before the sentence is empty, but I don't know why it is empty,

CodePudding user response:

Error in where?

CodePudding user response:

Error in this line of doc. Variables. FormVariables. Item (variable "0"). Value=https://bbs.csdn.net/topics/textBox1.Text.Trim ();
Now I only know that the Variables it is a COM object, COM objects are unable to extract which contains the variable name?

CodePudding user response:

reference 5 floor m0_37629182 reply:
error in this line of doc. Variables. FormVariables. Item (variable "0"). The Value=https://bbs.csdn.net/topics/textBox1.Text.Trim ();
Now I only know that the Variables it is a COM object, COM objects are unable to extract which contains the variable name?

You will eat, then you know there is a kind of food called milk residue, this kind of thing what to eat best? Can you and "sapodilla" eat together?
This is why the com and ocx reference to issues such as general reason, no too many people answer your own components, find oneself to solve,
  •  Tags:  
  • C#
  • Related