Managed DX - 'DrawText' ambiguous

G

Guest

I'm using VB.NET 2005 and DX9 SDK (Apr 2006).

I created an instance of the Direct3D.Font, and when I try to call DrawText
it says:
'DrawText' is ambiguous because multiple kinds of members with this name
exist in class 'Microsoft.DirectX.Direct3D.Font'

How is that possible?

Here is a VB.NET example:
myFont.DrawText(Nothing, myText, Position.X, Position.Y, myColor)

And this is what it's like in C#:
myFont.DrawText(null, myText, Position.X, Position.Y, myColor);
 
L

Larry Lard

Alex said:
I'm using VB.NET 2005 and DX9 SDK (Apr 2006).

I created an instance of the Direct3D.Font, and when I try to call DrawText
it says:
'DrawText' is ambiguous because multiple kinds of members with this name
exist in class 'Microsoft.DirectX.Direct3D.Font'

How is that possible?

Through the magic of case sensitive languages, such as C and all its
offspring. The docs for that error message tip you off as to what is
happening:

<http://msdn2.microsoft.com/en-us/library/ms235408.aspx>
"
The most likely cause of this error is case sensitivity. Visual Basic
names are case-insensitive, which means you can capitalize them
differently at different places in your code. For example, if you
define a variable with the name XYZ and later access it as xyz, the
compiler considers the two names to be equivalent.

However, other languages, such as Visual C# and Visual C++, are
case-sensitive. In such a language, XYZ and xyz are not considered to
be the same name. Therefore, a class written in such a language could
define a variable named XYZ and a property named xyz. The common
language runtime (CLR) preserves case sensitivity in assemblies.
However, if a Visual Basic application accesses an assembly with names
XYZ and xyz, they appear as the same name.
"

It's not hard to demonstrate this problem: In C#, create this class:

public class Class1
{
public int int1;

public int Int1 // a different thing from int1!
{
get { return int1; }
set { int1 = value; }
}
}

Reference it from VB.NET and attempt to use that property:

Sub Main()
Dim x As Class1

x.int1 = 6
End Sub

You get exactly this error.

The fix... hmm, now we are in trouble. The docs for the error were
written by someone who didn't really have a fix:

"To correct this error

1.

If you have control over the source code of the defining type,
consider renaming the members so that they differ by more than only
casing. This might not be possible if the defining type has already
been published and is being used by other applications.
2.

If you cannot rename the members in the defining type, ****remove
the cited programming element from your code. You cannot access an
element that appears to Visual Basic to have multiple definitions.****
"

(my emphasis) - I'm guessing that isn't really a feasible option for
you. So I can only suggest creating a C# dll which will act as a
wrapper for the problem element - it should expose a function that
accepts a Direct3D.Font and all those parameters, and calls DrawText as
required.

And maybe send a little note to the team that decided to make this part
of Direct3D.Font VB.NET-unfriendly...
 
G

Guest

Very helpful response Larry, but I also think what they've done is bullcrap
because when I was using the first DX9.0c SDK, it worked fine; now that I've
got this Apr 2006 update, it's horrible. If only I knew how to contact the
DirectX team...

--
Alex C. Barberi
Chief Executive Officer
VisionForce
http://www.visionforceweb.com
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top