79730885

Date: 2025-08-09 21:21:36
Score: 3.5
Natty:
Report link

Anyone arriving here in the future with a similar issue where you must support multiple frameworks and one of those is framework 4.0 (for very old vendor supplied application running on Windows XP in my case), the link to Thomas Levesque solution (https://thomaslevesque.com/2012/06/13/using-c-5-caller-info-attributes-when-targeting-earlier-versions-of-the-net-framework/) provided by others above works perfectly and seems to be the most straight forward solution to me since both newer and older frameworks can now use the attributes with no code differences.

I put his stub definitions into its own class file and surrounded it with the #if NET40 compiler directive so those stubs will only be used on a NET40 version compile (since I support multiple frameworks). A framework 4.0 version of each app can now access the [Caller...] attributes (I am only using [CallerMemberName], but I have no doubt the other stubs function too) and the expected values are populated into your variables. Thanks to Thomas and the others that left the link!

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • RegEx Blacklisted phrase (2): I have no doubt
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Ron Landon