|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Managed DX - 'DrawText' ambiguousI 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); Alex C. Barberi wrote:
> I'm using VB.NET 2005 and DX9 SDK (Apr 2006). Through the magic of case sensitive languages, such as C and all its> > 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? 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... -- Larry Lard Replies to group please 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... Show quoteHide quote "Larry Lard" wrote: > > Alex C. Barberi wrote: > > 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... > > -- > Larry Lard > Replies to group please > >
Image Upload problem - tearing hair out here!!
date calculations Do loop memory consumption? Saving outlook email attachment? ListBox Control Generating Reports Using VB.net Classes and collections vs. virtual tables (datasets) Display All Domain Names on the Network simple OO question Translating VB6 Code to kill the screen saver. |
|||||||||||||||||||||||