Author Topic: VB.NET and namespace conflicts  (Read 2947 times)

0 Members and 1 Guest are viewing this topic.

Keith Brown

  • Swamp Rat
  • Posts: 601
VB.NET and namespace conflicts
« on: April 27, 2016, 09:18:51 AM »
At home I use C# when coding but at work I have to use VB.NET and i have ran into a snag when converting some code.

I use the following namespace aliases in C#

Code - C#: [Select]
  1. using AcRx = Autodesk.AutoCAD.Runtime;
  2. using AcAp = Autodesk.AutoCAD.ApplicationServices;
  3. using AcDb = Autodesk.AutoCAD.DatabaseServices;
  4. using AcGe = Autodesk.AutoCAD.Geometry;

And when I create the same namespaces alias in vb.net

Code - Visual Basic: [Select]
  1. Imports AcRx = Autodesk.AutoCAD.Runtime
  2. Imports AcAp = Autodesk.AutoCAD.ApplicationServices
  3. Imports AcDb = Autodesk.AutoCAD.DatabaseServices
  4. Imports AcGe = Autodesk.AutoCAD.Geometry

I get the error Imports alias 'AcXX' conflicts with 'AcXX' declared in the root namespace.  So then of course if i remove the alias and try to just use 'AcXX' I get 'AcXX' is not accessible in this context because it is 'Friend'

Is there anyway around this WITHOUT changing my namespace Alias abbreviations?
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

Keith Brown

  • Swamp Rat
  • Posts: 601
Re: VB.NET and namespace conflicts
« Reply #1 on: April 27, 2016, 11:45:31 AM »
After some internal deliberation we have decided to change the namespaces alias to CadXX instead of AcXX.  In reality this makes more sense as the Ac refers to Autocad and we were using the aliases to distinguish between AutoCAD, Bricscad, etc.  These aliases do not cause a conflict with the managed assemblies.


vb.net still sucks.
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

Jeff_M

  • King Gator
  • Posts: 4100
  • C3D user & customizer
Re: VB.NET and namespace conflicts
« Reply #2 on: April 27, 2016, 12:07:36 PM »

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: VB.NET and namespace conflicts
« Reply #3 on: April 27, 2016, 04:00:36 PM »
Quote
After some internal deliberation we have decided to change the namespaces alias to CadXX instead of AcXX.
You win the first round.

You'll win the match when some internal deliberation will decide to abandon VB to C#... :whistling:
Speaking English as a French Frog

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: VB.NET and namespace conflicts
« Reply #4 on: April 27, 2016, 10:23:20 PM »
Quote
At home I use C# when coding but at work I have to use VB.NET and i have ran into a snag when converting some code.

That stinks. Couldn't go back to vb if I wanted to...C# has permanently distorted my brain.

Jeff H

  • Needs a day job
  • Posts: 6151
Re: VB.NET and namespace conflicts
« Reply #5 on: April 28, 2016, 10:18:56 AM »
Why people use VB.NET just baffles me its like they never thought there was another option. Whenever I see a VB.NET example posted I want to yell at the computer "Have you ever heard of VBA dumbarse." Get with times and start using VBA like everyone else.