|
I am not too sure if StackFrame will give you the access to the instance. The list of properties and methods in the class clearly should that it is not straightforward. I do not think it will be possible even via reflection.
BTW, why do want to know which instance called the method? You may get replies with alternate approach.
|
|
|
|
|
Thanks for the reply.
I actually don't care which instance called the method, I just need to know it is a subclass of TestBase. I only called out the specific instance information here for clarity.
|
|
|
|
|
So you already have that code then isn't it? Although it can be done without StackFrame as well.
|
|
|
|
|
I have the code in place to use stack frames to determine if the caller, at some point in the stack frame, was a subclass of TestBase...but, I've failed to figure out how to access the object's TestProperty value.
|
|
|
|
|
That's what I have replied. I am not sure if it is possible at all. It tells the type but never gives you access to that very instance. If you just want to access that property information, this should help:
Type t = oStackFrame.GetMethod().ReflectedType;
PropertyInfo property = t.GetProperty("property name here");
|
|
|
|
|
I got to the point where I can create a PropetyInfo instance, but I cannot figure out how to use the PropertyInfo instance get the TestProperty string value.
Can you continue the code you sent to show accessing the actual property value (instead of just creating a PropertyInfo instance)?
Thanks
|
|
|
|
|
It's simple.
propertyInfo.GetValue(objectInstance, null);
|
|
|
|
|
I got that far too
But, I could never figure out how to access the object instance - i.e. what do you set the objectInstance to?
|
|
|
|
|
You cannot access that. I had told that in my first reply itself.
There is no way you can access oTest1 in Method2 through this approach.
|
|
|
|
|
You can't. The stack frame is not the object instance.
|
|
|
|
|
Any know how I can pull this off? Or, is this not possible in any manner?
|
|
|
|
|
Your Method3 should either take in a parameter of type Test1 or a parameter with type same as that of property you want to access.
|
|
|
|
|
Hi,
I have a simple javascript on my asp.net page where i have
document.getElementById("txtFirstName").value;
which gives a runtime error : object required.
can anyone please help. here txtFirstNa
me is the id of as:textbox control.
Thanks
|
|
|
|
|
Try
document.getElementById('<%= txtFirstName.ClientID %>').value
|
|
|
|
|
thanks karl.. it worked.
many thanks.
|
|
|
|
|
|
I apologize if this the wrong for this question.
I have a C# app, more of a framework really that does calculations on a large set of proprietary data, the data in its raw form is unreadable, it has to be processed by the framework. I'm wondering if there is a way to create a driver so that applications can query the framework much like you would query a database? I can put the data into datatables and datasets, but I'm not sure how to make it accessible. Any suggestions are appreciated.
|
|
|
|
|
You might consider using/creating a Domain Specific Language (DSL).
General description[^].
Microsoft's take[^].
For more information just google domain specific language.
That's all I know about them though, except that there are some articles here on The Code Project about them. (Use the Articles|Search menu at the top of the page).
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
|
|
|
|
|
We have a remote electricity meter device with a serial to Ethernet converter; I want to catch the data from this meter on a PC using C#. I have a fairly good understanding of the COM port and how to parse a data stream (have done my bit in VB6) in C#, but I have no way how to do it from Ethernet. I do not want to send any data back - it is read only. Any guidance would be welcome. Thanks
"the confused are confused beyond confusion" - Pik Botha (1990)
|
|
|
|
|
Try some of these links[^] for information on how to use sockets in C#. Assuming that you know the protocol to talk to this meter it should not be too difficult a problem.
I must get a clever new signature for 2011.
|
|
|
|
|
pierrecor wrote: We have a remote electricity meter device with a serial to Ethernet converter
Several steps - first you need to refine exactly what "ethernet connector" means.
That by itself doesn't tell you what functionality is available, how to access it nor anything at all about the protocol.
Second presuming that it really means some sort of IP then you would need to learn about UDP and TCP (which ever is relevant) and the appropriate conventions in C# to access each.
|
|
|
|
|
Is it a Current Cost meter? If so, it's not an Ethernet connection, even though the socket on the meter is an RJ45. It's actually an RS232 serial connection through an RJ45 to USB cable, with a "serial to USB" driver needed on the PC. Then you talk to it like a normal COM port.
|
|
|
|
|
hi guys
i want to switch between program run in windows such as alt+tab
but use c#
|
|
|
|
|
You want your application to simulate alt-tab? That will make for a very confusing user experience because you are hijacking system functionality in a way they won't be expecting.
|
|
|
|
|
i have a script in mql4 language in metatrader software that run this url:
http://aaaa.com/Default.asmx/methodname?S=+S+&d=+T;
i want to make a asp.net page(web service) and insert this parameters('s' and 'd')in database.
how can i make this url?
Regards
|
|
|
|