473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Managed C++ DefaultMemberAttribute Bug

(Type your message here)
Hi, I am trying to write a managed class tha expose
Multiple Indexers Properties To C#, I use the 'DefaultMemberAttribute' Attribute,
but when i use the class from C# I get Strange Compiler Error.
Here Is The Managed C++:

[System::Reflection::DefaultMemberAttribute(S"It")]
public __gc class Dummy
{
public public:
__property Int32 get_It(Int32 I)
{
return str;
}
__property String* get_It(String* str)
{
return str;
}
};

When I Try This C# Client:
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Dummy.Dummy d = new Dummy.Dummy();
Console.WriteLine(d[4]);
}
}
it run OK, But When I try This:
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Dummy.Dummy d = new Dummy.Dummy();
Console.WriteLine(d["HH"]);
}
}
The Compiler Give this error:
"error CS1546: Property, indexer, or event '$Item$' is not supported by the language; try directly calling accessor method 'Dummy.Dummy.get_It(string)'"

I Don not if something that i have done is Wrong, Or Something in the
Managed C++ Compiler.

Thanks in Advance.

--------------------------------
From: ahmed alhamed

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>191+phbvWEq2cxiMJB/FQA==</Id>
Nov 17 '05 #1
1 1507
You must have not typed or pasted the C++ code properly, when you are
passing an Int32 and getting Int32 the why you are returning str ?

"ahmed alhamed via .NET 247" <an*******@dotnet247.com> wrote in message
news:OM******************@TK2MSFTNGP11.phx.gbl...
(Type your message here)
Hi, I am trying to write a managed class tha expose
Multiple Indexers Properties To C#, I use the 'DefaultMemberAttribute' Attribute, but when i use the class from C# I get Strange Compiler Error.
Here Is The Managed C++:

[System::Reflection::DefaultMemberAttribute(S"It")]
public __gc class Dummy
{
public public:
__property Int32 get_It(Int32 I)
{
return str;
}
__property String* get_It(String* str)
{
return str;
}
};

When I Try This C# Client:
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Dummy.Dummy d = new Dummy.Dummy();
Console.WriteLine(d[4]);
}
}
it run OK, But When I try This:
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Dummy.Dummy d = new Dummy.Dummy();
Console.WriteLine(d["HH"]);
}
}
The Compiler Give this error:
"error CS1546: Property, indexer, or event '$Item$' is not supported by the language; try directly calling accessor method
'Dummy.Dummy.get_It(string)'"
I Don not if something that i have done is Wrong, Or Something in the
Managed C++ Compiler.

Thanks in Advance.

--------------------------------
From: ahmed alhamed

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>191+phbvWEq2cxiMJB/FQA==</Id>

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
1
by: lolomgwtf | last post by:
I have a managed C++ method that wraps unmanaged code and creates a managed object holding data retrieved form an unmanged one. I want create an instance of this managed class in C#, pass it to...
16
by: Ekim | last post by:
hello, I'm allocating a byte-Array in C# with byte byteArray = new byte; Now I want to pass this byte-Array to a managed C++-function by reference, so that I'm able to change the content of the...
2
by: asanford | last post by:
We use StackWalk(StackWalk64) from dbghelp.dll to walk our callstacksas needed, using the various Sym* methods (SymGetSymFromAddr, SymGetLineFromAddr) to resolve source file, function name, and...
4
by: William F. Kinsley | last post by:
My understanding is that when I re-compile a existing MFC application with the /clr switch, that the code generated is managed(with some exceptions) but that the data isn't, i.e. not garbage...
9
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for...
12
by: DaTurk | last post by:
Hi, I have a rather interesting problem. I have a unmanged c++ class which needs to communicate information to managed c++ via callbacks, with a layer of c# on top of the managed c++ ultimatley...
3
by: Klaus | last post by:
Hi, I have an existing VC 6 MFC application which communicates asynchronly with a VC 2005 managed code dll. I use an unmanaged base class with virtual functions to access methods in the MFC...
8
by: Varangian | last post by:
Hello, was wondering of how to dispose of managed resources? or referencing every member of a class to null will release resources...? http://www.marcclifton.com/tabid/79/Default.aspx...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.