Re: Managed DX - 'DrawText' ambiguous
- From: Alex C. Barberi <AlexCBarberi@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 2 May 2006 17:48:01 -0700
It shows as an error in the VS IDE, here is the exact message:
'DrawText' is ambiguous because multiple kinds of members with this name
exist in class 'Microsoft.DirectX.Direct3D.Font'
Here's what Larry Lard told me:
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...
--
Alex C. Barberi
Chief Executive Officer
VisionForce
http://www.visionforceweb.com
"Richard [Microsoft Direct3D MVP]" wrote:
[Please do not mail me a copy of your followup].
=?Utf-8?B?QWxleCBDLiBCYXJiZXJp?= <AlexCBarberi@xxxxxxxxxxxxxxxxxxxxxxxxx> spake the secret code
<23D85460-8CC6-44D2-B928-DC4A5D7ED1B7@xxxxxxxxxxxxx> thusly:
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'
Is this a runtime error or a compile error? If the latter, please
post the exact error message from the compiler output window.
--
"The Direct3D Graphics Pipeline"-- code samples, sample chapter, FAQ:
<http://www.xmission.com/~legalize/book/>
Pilgrimage: Utah's annual demoparty
<http://pilgrimage.scene.org>
- Follow-Ups:
- Re: Managed DX - 'DrawText' ambiguous
- From: Richard [Microsoft Direct3D MVP]
- Re: Managed DX - 'DrawText' ambiguous
- References:
- Re: Managed DX - 'DrawText' ambiguous
- From: Richard [Microsoft Direct3D MVP]
- Re: Managed DX - 'DrawText' ambiguous
- Prev by Date: Re: change d3dx9 dll version
- Next by Date: Re: Managed DX - 'DrawText' ambiguous
- Previous by thread: Re: Managed DX - 'DrawText' ambiguous
- Next by thread: Re: Managed DX - 'DrawText' ambiguous
- Index(es):
Relevant Pages
|