Author Topic: How to run BricsCAD with a C# windows form?  (Read 1890 times)

0 Members and 1 Guest are viewing this topic.

gschmidt

  • Guest
How to run BricsCAD with a C# windows form?
« on: January 27, 2011, 09:04:06 AM »
Hi,

I am trying to run BricsCAD with a C# windows form, but I am getting a security exception error.

Anyone familiar with this problem?

This is my code sofar:

Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using BricscadApp;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Microsoft.VisualBasic;

namespace ComExample
{
  public partial class Form1 : Form
  {
    private AcadApplication m_BricsCad = null;

    public Form1()
    {
      InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
      try
      {
        m_BricsCad = new AcadApplication();
        Interaction.AppActivate(m_BricsCad.Application.Caption);
      }
      catch (COMException ce)
      {
        MessageBox.Show(ce.Message, "No BricsCad was found. Start V9 before running this program.");
      }
    }
  }
}

extra information: I have installed 3 versions of BricsCAD (V9, V10 and V11) but I use the BricscadApp & BricscadDb from V11


Greetzzz,

Gerben

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8858
  • AKA Daniel
Re: How to run BricsCAD with a C# windows form?
« Reply #1 on: January 27, 2011, 09:47:46 AM »
all you should need is something like;

Code: [Select]
AcadApplication app = new AcadApplication();
 app.Visible = true;

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8858
  • AKA Daniel
Re: How to run BricsCAD with a C# windows form?
« Reply #2 on: January 27, 2011, 09:49:45 AM »
Also, the com interfaces are version specific, if you reference V9, your app will only work with V9

gschmidt

  • Guest
Re: How to run BricsCAD with a C# windows form?
« Reply #3 on: February 03, 2011, 03:21:54 AM »
Thanx,

I am playing with it now!