Hi
I hope I make sense here.
I want to be able to obtain the name of the method that calls a method
within my class.
So If I have my class that has a method LogInfo()
And my client code has a method ProcessRequest( )
that makes a call to myClass.LogInfo (data)
then I want to be able to obtain the name 'ProcessRequest ' from within
the LogInfo() method, without having to pass the method name across.
I'm assuming it's some form of reflection, but really just guessing.
thanks for any info.
Martyn 5 2057
Hi,
Try this:
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Call f()
End Sub
Sub f()
Dim o As New StackTrace()
MsgBox(o.GetFra me(1).GetMethod .Name)
End Sub
--
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers: http://www.mztools.com
"OneFang" <ma***********@ hotmail.com> escribió en el mensaje
news:11******** **************@ g44g2000cwa.goo glegroups.com.. . Hi
I hope I make sense here.
I want to be able to obtain the name of the method that calls a method within my class.
So If I have my class that has a method LogInfo()
And my client code has a method ProcessRequest( ) that makes a call to myClass.LogInfo (data)
then I want to be able to obtain the name 'ProcessRequest ' from within the LogInfo() method, without having to pass the method name across.
I'm assuming it's some form of reflection, but really just guessing.
thanks for any info.
Martyn
many thanks Carlos; that did it.
M
Unfortunately code like this breaks when run on an assembly that has been
obfuscated.
:(
I have not found a way around that yet... I used to use code like this in my
debug statements until I found that out.
"Carlos J. Quintero [.NET MVP]" <ca*****@NOSPAM sogecable.com> wrote in
message news:e6******** ******@TK2MSFTN GP12.phx.gbl... Hi,
Try this:
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load Call f() End Sub
Sub f() Dim o As New StackTrace() MsgBox(o.GetFra me(1).GetMethod .Name) End Sub
--
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA You can code, design and document much faster. Free resources for add-in developers: http://www.mztools.com
"OneFang" <ma***********@ hotmail.com> escribió en el mensaje news:11******** **************@ g44g2000cwa.goo glegroups.com.. . Hi
I hope I make sense here.
I want to be able to obtain the name of the method that calls a method within my class.
So If I have my class that has a method LogInfo()
And my client code has a method ProcessRequest( ) that makes a call to myClass.LogInfo (data)
then I want to be able to obtain the name 'ProcessRequest ' from within the LogInfo() method, without having to pass the method name across.
I'm assuming it's some form of reflection, but really just guessing.
thanks for any info.
Martyn
Yes, that's the job of an obfuscator...
--
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers: http://www.mztools.com
"Ray Cassick" <rc******@nospa m.enterprocity. com> escribió en el mensaje
news:ei******** ******@TK2MSFTN GP10.phx.gbl... Unfortunately code like this breaks when run on an assembly that has been obfuscated.
:(
I have not found a way around that yet... I used to use code like this in my debug statements until I found that out.
I know, just pointing out the fact that it becomes harder to use these
automatic methods of getting caller name for debug purposes when using an
obfuscator. It was something that my original code had not taken into
account and I wanted to save them the time of finding that out latter.
Not sure why I thought it would be different but the fact that the metadata
in the assembly gets munged by obfuscation did not seem to enter into my
mind..
"Carlos J. Quintero [.NET MVP]" <ca*****@NOSPAM sogecable.com> wrote in
message news:uT******** *****@TK2MSFTNG P10.phx.gbl... Yes, that's the job of an obfuscator...
--
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA You can code, design and document much faster. Free resources for add-in developers: http://www.mztools.com
"Ray Cassick" <rc******@nospa m.enterprocity. com> escribió en el mensaje news:ei******** ******@TK2MSFTN GP10.phx.gbl... Unfortunately code like this breaks when run on an assembly that has
been obfuscated.
:(
I have not found a way around that yet... I used to use code like this
in my debug statements until I found that out. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alex Vinokur |
last post by:
=========================================
Windows 2000
CYGWIN_NT-5.0 1.3.22(0.78/3/2)
GNU gcc version 3.2 20020927 (prerelease)
=========================================
Here is some program which is compiled and works fine.
############################################
|
by: Gnanaprakash Rathinam |
last post by:
Hi Expert,
Is there a way to obtain assembly name in an unmanaged call? During Interop
call between managed to unmanaged, I would like to know in unmanaged code
about the caller of assembly file name?
Thanks,
GP.
|
by: jaden10001 |
last post by:
I have read that the function.caller method is now depricated. I see
alot of browsers still support it but Opera 7 does not. Is there a way
to get the name of the caller of a function in Opera 7?
|
by: 2pac |
last post by:
in this scenario
foo1 ---calls---> foo2
is it possible for me to print out - when the control is within foo2 -
the caller of foo2
the information is obviously there in the stack - am wondering if by
some combination of assembly and pointer manipulation - I can print
the name of the caller of the method
Thanks for any suggestions
|
by: Steve |
last post by:
Hello --
I've been struggling with this problem for over a day now. I'd like to
know (without passing parameters) which class, and preferably, which
method of that class has called my function.
I can get the calling assembly rather easily, but let's say within
Assembly X I have
class A
| |
by: Patient Guy |
last post by:
The code below shows the familiar way of restricting a function to be a
method of a constructed object:
function aConstructor(arg)
{
if (typeof(arg) == "undefined")
return (null);
this.property1 = arg;
this.property2 = aConstantDefinedGlobally;
this.method1 = function (anArg) {
|
by: pamelafluente |
last post by:
Hi guys,
How do I get the full name of the current (overload) function or sub
(whatever it be) ?
Sub SomeFunction()
Dim FullNameOfThisFunction = ???
msgbox(FullNameOfThisFunction )
|
by: ME |
last post by:
How would one obtain the parameter VALUES of a method that has already run?
I can find the method using the StackTrace and StackFrame classes but once I
find the method I would like to obtain the value of one of the parameters
that were passed to the method. Is this possible? Even if I have to use
PInvoke to do so?
I can currently find the parameter TYPEs using reflection but I can not
figure out to obtain the values.
Thanks,
|
by: jackchang1 |
last post by:
It's not difficult getting the function name of the caller but if the
caller is an object's method, how do you get the method name?
<html>
<head>
<script type="text/javascript">
function displayCallStack(func){
var caller = func.caller;
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |