What you ask is not quite straightforward. The source code exists nowhere
but in your sourcecode files. It does not exist in the final bytes
(disassemblers of course out of this discussion).
So, first off it needs to be a debug build (a release build wont work), you
will need a symbol file reader (you can do this through the framework 2.0)
as well as all of the original source code files in the location that they
existed in when you compiled the code. Then at runtime, showcode needs to
walk the stack (not difficult either) to determine the caller and then parse
the symbol file for the code location of that caller. I guess the next
question is.. why?


----- Original Message -----
From: "Franklin Gray" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, August 31, 2005 12:16 PM
Subject: [ADVANCED-DOTNET] Code to view code


I would like to write a function in my Examples project that I could call
in all my example code that could show the code from the calling function
and display that code in a new form.


   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
       Dim d As Date
       d = CType(Me.txtGMT.Text, Date)
       Me.txtLocal.Text = d.ToLocalTime.ToString
       If Me.chkShowCode.Checked = True Then
               ShowCode() ' this is the function I want to write that
shows the lines in this sub.  Possible without hardcoding the display
value?
       End If
   End Sub

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com


===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to