C# Type Conversion

Matt Klassen

Usenet Archive
Joined
Feb 1, 2004
Messages
2
Reaction score
0
I'm working on my first c# AutoCAD addin, and I'm having one of my stupid-moments. I'm trying to get an AcadText object. I keep getting This error

"An unhandled exception of type 'System.InvalidCastException' occurred in mscorlib.dll

Additional information: Object must implement IConvertible."

Anyone have any ideas? My head hurts haha. This was so much easier with VB
6.

here's my code

private void cbtSelect_Click(object sender, System.EventArgs e)

{

object oPoint;

object actTemp;

AcadText actField;

// System.IConvertible actTemp;

this.Hide;

oAcadDoc.Utility.GetEntity(out actTemp, out oPoint,"Select Text: ");

this.Show;

actField = (AcadText)Convert.ChangeType(actTemp,typeof(object )); <-- error occurs here

acadUtils.setXDataValues(actField,
cboTableList.Text,lbxFields.SelectedItem.ToString);

}
 
never mind, stupid-moment is over. I got it.

use this
actField =(AcadText)actTemp;

instead of this

actField = (AcadText)Convert.ChangeType(actTemp,typeof(object ));
 

Latest threads

Back
Top