Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / August 2007

Tip: Looking for answers? Try searching our database.

CLI Reference Parameter used for CSharp

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ed - 08 Aug 2007 03:20 GMT
Hi, dear all,
Here are some questions when I was writing CLI code, which would be
used by C# Project.

1. Reference Parameter
If CLI method have % reference type parameter, which is ref class,
could C Sharp use it?

In CLI code:

ClassA::SetB(ClassB% classB);

In CSharp:

ClassA classA=new ClassA();
ClassB classB=new ClassB();

classA.SetB(ref classB);
// But the build was failed:
// error CS1501: No overload for method 'SetB' takes '2' arguments

So, how can I use this CLI method in CSharp project?
David Anton - 09 Aug 2007 15:22 GMT
Not sure about the "2 arguments" message, but your CLI code should have a hat
in there if ClassB is a ref class:
e.g.,
ClassA::SetB(ClassB ^%classB);
Signature

David Anton
http://www.tangiblesoftwaresolutions.com
Convert between VB, C#, and C++
Instant C#
Instant VB
Instant C++
C++ to C# Converter
C++ to VB Converter

> Hi, dear all,
> Here are some questions when I was writing CLI code, which would be
[quoted text clipped - 18 lines]
>
> So, how can I use this CLI method in CSharp project?
Ben Voigt [C++ MVP] - 09 Aug 2007 15:28 GMT
> Not sure about the "2 arguments" message, but your CLI code should have a
> hat
> in there if ClassB is a ref class:
> e.g.,
> ClassA::SetB(ClassB ^%classB);

I think the original notation is also possible, C# will just ignore the
modopt() attribute.

I suggest using .NET Reflector to view the public API generated by the
compiler.

>> Hi, dear all,
>> Here are some questions when I was writing CLI code, which would be
[quoted text clipped - 18 lines]
>>
>> So, how can I use this CLI method in CSharp project?
Ed - 09 Aug 2007 17:50 GMT
> > Not sure about the "2 arguments" message, but your CLI code should have a
> > hat
[quoted text clipped - 40 lines]
>
> >> So, how can I use this CLI method in CSharp project?

Thank you!
I will have a try. And if "the public API generated by the compiler."
means the assembly code generated by compiler?
If so, it seems more and more tricks should be searched from the
assembly code generated by compiler.
Ben Voigt [C++ MVP] - 09 Aug 2007 18:52 GMT
> Thank you!
> I will have a try. And if "the public API generated by the compiler."
> means the assembly code generated by compiler?

.NET Reflector can show the signature of each method in any language,
including, for example, C#.

> If so, it seems more and more tricks should be searched from the
> assembly code generated by compiler.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.