The type or namespace name 'DbServer' could not be found

This forum is meant for questions and discussions about the X# language and tools
Post Reply
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

The type or namespace name 'DbServer' could not be found

Post by ic2 »

Why is this?

Error: The type or namespace name 'DbServer' could not be found.
I have included VulcanVORddClasses.DLL where it is supposed to be found. Even if I change the code to:

VulcanVORddClasses.DBServer
it keeps giving the error.

When I set Enable implicit namespace lookup to true it works.

But I don't understand why an include is not enough?

Dick
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

The type or namespace name 'DbServer' could not be found

Post by robert »

Dick,

In VO there were a limited number of classes. To distinguish between types in VO and to prevent name conflicts 3rd party vendors added prefixes to class names. AdoServer, bServer etc.
In .Net the number of classes is HUGE. And there are classes with similar names for different situations. For example there is a Control class for Windows Forms, for WPF and a Control class for VOGUI.
To distinguish between these classes with the same name and a different purpose they are grouped in namespaces.
Therefore the former Vulcan development team has also put the VO Classes in a namespace.
For Vulcan that namespace was Vulcan.VO. In X# we have simply used VO.

To make it easier to migrate code we have added a special attribute (metadata) to the Vulcan Assemblies and now also to the X# assemblies. This attribute tells the compiler in which namespaces the classes in the assembly are located.
If you enable the "Implicit Namespace Lookup" then the compiler will inspect these attributes and automatically add a "virtual" USING statement to each source file so the compiler "knows" in which namespaces to look for the types in the code.
The runtime also uses this mechanism if you create a class with CreateInstance().

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

The type or namespace name 'DbServer' could not be found

Post by ic2 »

Hello Robert,

Thanks for the explanation.

I thought I had to use VulcanVORddClasses.DBServer without implicit namespace lookup. But with
Vulcan.VO.DbServer it works indeed.

I am doing this all the time because in .Net the designers didn't have enough fantasy to create unique class names so adding a class more than once results in Ambiguous Reference errors and the necessity to add the namespace, e.g. System.Drawing.Color because there is also a Color class in System.Windows.Media.Color. I've always wondered why no-one got the idea to create a System.Drawing.DrawingColor class and a System.Windows.Media.MediaColor class to prevent these errors completely....

Dick
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

The type or namespace name 'DbServer' could not be found

Post by Chris »

Hi Dick,

That's exactly what they have done, they have produced unique names. The name "System.Drawing.Color" is one class name, it's not 3 things combined together. They could had named it "System_Drawing_Color" (or even SystemDrawingColor) instead, but apparently somebody thought it's a good idea to use dots instead of underscores in the class names, while the dot is already used for another million things in c#, and this is what's causing the confusion.

But you really need to treat System.Drawing.Point as THE class name, same with Vulcan.VO.DbServer etc. It's just that for saving typing long class names, compilers allow you to specify only the last part of the name and instead mention the first part (which by convention is called the "namespace" of the class, but that's just a convention, the namespace is nothing concrete) in USING statements.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

The type or namespace name 'DbServer' could not be found

Post by ic2 »

Hello Chris,
The reason I find this an issue is that I often find a code snippet somewhere I could use without the namespace. So it says e.g.:

Something= Color.LightGray;
It compiles because I've included System.Drawing already or it does not and I have to find out which namespace I should use. Sometimes I choose the wrong one and only a while further (adding some more code) I find a line which does not work with System.Drawing and I have to start over again with (one of the) other namespaces.

Sometimes it is very clear of course but more than once I can not easily determine which namespace the sample is supposed to use. I really don't know if I am coloring a control if this control is supposed to be a Drawing or Media!

In that case it would be a lot easier if the class itself had a unique name. I normally have to type that namespace anyhow so a few more characters would not hurt.

It's an academic discussion of course, because it's already been named that way and ruined forever. But it's IMO one of the many samples of Microsoft delivering a poor result.

Dick
Post Reply