C# Type Conversion

Discussion in 'AutoCAD' started by Matt Klassen, Feb 1, 2004.

  1. Matt Klassen

    Matt Klassen Guest

    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());

    }
     
    Matt Klassen, Feb 1, 2004
    #1
  2. Matt Klassen

    Matt Klassen Guest

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

    use this
    actField =(AcadText)actTemp;

    instead of this

    actField = (AcadText)Convert.ChangeType(actTemp,typeof(object ));
     
    Matt Klassen, Feb 2, 2004
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.