Home Dashboard Directory Help
Search

Evaluation of named by-ref arguments in C# by Louis.fr


Status: 

Active


6
1
Sign in
to vote
Type: Bug
ID: 716017
Opened: 12/30/2011 2:46:22 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
1
Workaround(s)
view
1
User(s) can reproduce this bug

Description

Passing a field of a struct by ref doesn't work when using named arguments. A copy of the structure is made before the address of the field is taken, the original structure's field is therefore left unchanged.

It looks like it happens only with reference-type fields.
Details
Sign in to post a comment.
Posted by Microsoft on 4/29/2014 at 12:24 PM
Thank you for reporting this issue. This issue has been fixed in Visual Studio 2013. You can install a trial version of Visual Studio 2013 with the fix from: http://go.microsoft.com/?linkid=9832436
Posted by Microsoft on 4/12/2013 at 4:13 PM
Hi. We fixed this, thanks for bug report.

bill
Posted by Louis.fr on 1/5/2012 at 3:14 AM
I mistyped my example program. I uploaded a Program.cs which I tested. It shows the issue.
Posted by MS-Moderator09 [Feedback Moderator] on 1/1/2012 at 6:33 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by Alan Pretre on 12/30/2011 at 3:20 PM
I just reproduced it in 60 sec. on a different computer. Take the WinForm source in the forum link and completely replace the Form1 source with that one. Take cae to match the namespace though. When it is working correctly, there will be no message box and the form will appear. If you execute the #else, it will display a message box saying that the dictionatry is null before the form is displayed. -- Alan
Posted by aljodAv on 12/30/2011 at 2:09 PM
I cannot reproduce the bug, following the *steps-to-reproduce*. Please, upload a full compilable VS solution demonstrating the issue, and don't forget the Foo(...) method.
Thanks.
Posted by Alan Pretre on 12/30/2011 at 7:17 AM
Original source file at http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/6a8b6fbf-43b9-4f19-934b-695053b7d60d/#6a8b6fbf-43b9-4f19-934b-695053b7d60d
Posted by MS-Moderator01 on 12/30/2011 at 3:42 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Alan Pretre on 12/30/2011 at 7:09 AM
Use a class instead of a struct. Not an issue with a class.
File Name Submitted By Submitted On File Size  
Form1.cs 12/30/2011 1 KB
Form1.cs 12/30/2011 1 KB
Program.cs 1/5/2012 1 KB