473,396 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Reflection, line numbers & filenames

Hi,

I hope somebody can help me out, Im looking for a way to retreive the
original filename & line number of a Reflection.MemberInfo instance. Ill
provide some background on what it is that im doing:

I have an attribute defined as follows:

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Constructor |
AttributeTargets.Enum | AttributeTargets.Interface | AttributeTargets.Method
| AttributeTargets.Property | AttributeTargets.Struct,AllowMultiple=true)]
public class CodeAttribute : Attribute
....

This attribute is a base for a few others, but that is not important. The
important part is that derivatives of this attrtibute can be attached to
almost all elements within code.

I am using reflection to recursively look for these attributes on items in
an assembly, when one is found some business logic takes place, and the end
result is that events are raised to the client application. This event
contains an instance of Reflection.MemberInfo (so that would be a Type,
ConstructorInfo, MethodInfo - all derivatives of MemberInfo).

What I really need is the original filename (c:\path\file.cs) and line
number of that MemberInfo. as I am adding results of the events to the
VS.NET tasklist. I understand that this could only possible with pdb output,
and that is no problem for me whatsoever.

I have managed to do this, but in an entirely unacceptable way. I achieved
this by using EnvDTE to write a Solution wrapper class which looked through
the code in the IDE and stored each class/method/property etc in a type-safe
collection. I then developed the hack of all hacks to convert a
MemberInfo --> formetted string --> lookup Solution wrapper.

What i'd like is a way to use StackTrace or StackFrame for this, so far ive
only found examples of getting line number and file for exceptions.

TIA

JamieC
Nov 15 '05 #1
0 1451

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Edward K. Ream | last post by:
Am I reading pep 277 correctly? On Windows NT/XP, should filenames always be converted to Unicode using the mbcs encoding? For example, myFile = unicode(__file__, "mbcs", "strict") This...
6
by: Edd Dawson | last post by:
Hi. I have a strange problem involving the passing of command line arguments to a C program I'm writing. I tried posting this in comp.programming yesterday but someone kindly suggested that I'd...
11
by: Ken Varn | last post by:
I want to be able to determine my current line, file, and function in my C# application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___ macros for getting this, but I cannot find a...
8
by: Arun Bhalla | last post by:
Hi, I'm developing an Explorer bar using VS.NET 2003 (C#) on Windows XP. For some time, I've noticed that I don't have filenames and line numbers appearing in my exceptions' stack traces. On...
9
by: QQ | last post by:
I am trying to use reflection to access the private property of OpenFileDialog fileNames property. I have the following code : filedlg.InitialDirectory = directory.Text; filedlg.Filter = "xml...
4
by: Ken Swanson | last post by:
Hi, In VB.NET, how do I determine what filename has been dropped into a ListView? In my ListView's DragEnter() event, I am trying this, which according to the Help, should work: MyFilename...
4
by: Doug Handler | last post by:
Ok, I think this is my last one - in my app, the user can select via a dialog box the dll's they want to load. I use a checkbox to track this (no worries there), but, once a dll has been bound,...
12
by: IamIan | last post by:
I searched the archives but couldn't find anyone else with this problem. Basically I'm grabbing all ASCII files in a directory and doing geoprocessing on them. I need to calculate a z-factor based...
11
by: jo3c | last post by:
hi everybody im a newbie in python i need to read line 4 from a header file using linecache will crash my computer due to memory loading, because i am working on 2000 files each is 8mb ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.