Author Topic: Newbie Question: 'Application' is an ambiguous reference ..  (Read 2159 times)

0 Members and 1 Guest are viewing this topic.

Atook

  • Swamp Rat
  • Posts: 1029
  • AKA Tim
Newbie Question: 'Application' is an ambiguous reference ..
« on: August 15, 2011, 04:31:32 PM »
Working through he .NET tutorials myself, I've come up with a couple questions. I'm using VS2010 and r2008:

The first regards ambiguous references, and the 'using' statements. In the attached image you can see an error showing up regarding the Application object. You can also see my using statements up at the top. In order to resolve the error, I just need to specify which Application object I'm using: i.e. Autodesk.AutoCAD.ApplicationServices.Application instead of Application. No problem, but it sure makes the code silly long. Am I missing something, or do I need to be so explicit?

Second Question: in the VS2010 IDE, is there a way to highlight brackets/parens so I can easily see the matching ones? Notepad++ does this and I love it.


dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Newbie Question: 'Application' is an ambiguous reference ..
« Reply #1 on: August 15, 2011, 04:57:03 PM »
You can assign namespace aliases e.g. Using acad_app = AutoDesk.AutoCAD.blahblah
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

kaefer

  • Guest
Re: Newbie Question: 'Application' is an ambiguous reference ..
« Reply #2 on: August 15, 2011, 05:00:20 PM »
The first regards ambiguous references, and the 'using' statements.

Using Directive.

That may be useful for other parts of the Autodesk namespace too; AutoCAD's GraphicsInterface or the Aec libraries are a real treasure for such clashes.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Newbie Question: 'Application' is an ambiguous reference ..
« Reply #3 on: August 15, 2011, 05:01:31 PM »
Hi,

You can use an alias for Autodesk.AutoCAD.Application.
Add this line after other 'using' expressions:
Code: [Select]
using AcAp = Autodesk.AutoCAD.Application;Then, the alias AcAp (or any other non used name as AcadApp) can be used in the code instead of Autodesk.AutoCAD.Application:
Code: [Select]
Editor ed = AcAp.DocumentManager.MdiActiveDocument.Editor;
Speaking English as a French Frog

Atook

  • Swamp Rat
  • Posts: 1029
  • AKA Tim
Re: Newbie Question: 'Application' is an ambiguous reference ..
« Reply #4 on: August 15, 2011, 05:24:24 PM »
Thanks guys, exactly what I was looking for. :)

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Newbie Question: 'Application' is an ambiguous reference ..
« Reply #5 on: August 15, 2011, 05:31:34 PM »
You could also remove
using System.Windows.Forms
Not sure why you would need it unless it was the code behind a form.

Atook

  • Swamp Rat
  • Posts: 1029
  • AKA Tim
Re: Newbie Question: 'Application' is an ambiguous reference ..
« Reply #6 on: August 15, 2011, 05:36:23 PM »
You could also remove
using System.Windows.Forms
Not sure why you would need it unless it was the code behind a form.

Good point Jeff. This tutorial requires it though, as I'm adding a treeview form to a pallet.

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Newbie Question: 'Application' is an ambiguous reference ..
« Reply #7 on: August 15, 2011, 05:41:04 PM »
Second Question: in the VS2010 IDE, is there a way to highlight brackets/parens so I can easily see the matching ones? Notepad++ does this and I love it.

You can use Devexpress http://devexpress.com/Products/Visual_Studio_Add-in/ or another addin and I think you can change this options but if you click right in front or behind a curly brace the matching one will highlight.