reflection

Identifying ASP.NET web service references

At my day job we have load balanced web servers which talk to load balanced app servers via web services (and lately WCF). At any given time, we have 4-6 different teams that have the ability to add new web sites or services or consume existing services. We probably have about 20-30 different web applications and corresponding services. ...

C# Dynamic Event Subscription

How would you dynamically subscribe to a C# event so that given a Object instance and a String name containing the name of the event, you subscribe to that event and do something (write to the console for example) when that event has been fired? It would seem using Reflection this isn't possible and I would like to avoid having to use R...

Justification for Reflection in C#

I have wondered about the appropriateness of reflection in C# code. For example I have written a function which iterates through the properties of a given source object and creates a new instance of a specified type, then copies the values of properties with the same name from one to the other. I created this to copy data from one auto-g...

Use-cases for reflection

Recently I was talking to a co-worker about C++ and lamented that there was no way to take a string with the name of a class field and extract the field with that name; in other words, it lacks reflection. He gave me a baffled look and asked when anyone would ever need to do such a thing. Off the top of my head I didn't have a good ans...

Change Attribute's parameter at runtime

Hi, I am not sure whether is it possible to change attribute's parameter during runtime? For example, inside an assembly I have the following class public class UserInfo { [Category("change me!")] public int Age { get; set; } [Category("change me!")] public string Name { get; ...

Getting a list of assemblies needed by application

Is there a way of getting all required assemblies (excluding the .net framework) for a .net project into a folder ready to be packaged into an nsis as setup file? I've tried writing a small console app that uses reflection to get a list of dlls but have got stuck with finding a foolproof way of determining if a dll is from the .net fram...

Determining if an assembly is part of the .net framework

How can I tell from the assemblyName, or Assembly class (or others like it), whether an assembly is part of the .net framework (ie System.windows.Forms)? So far I've considered the PublicKeyToken, and CodeBase properties, but these are not always the same for the whole framework. Edit: The reason I want this info is to get a list of ...

C#: How do I get the path of the assembly the code is in?

Is there a way to get the path for the assembly in which the current code resides? I do not want the path of the calling assembly, just the one containing the code. Basically my unit test needs to read some xml test files which are located relative to the dll. I want the path to always resolve correctly regardless of whether the tes...

creating an object without knowing the class name at design time

using reflection , I need to investigate a user DLL and create an object of a class in it. what is the simple way of doing it ? ...

How can I evaluate a C# expression dynamically?

I would like to do the equivalent of: object result = Eval("1 + 3"); string now = Eval("System.DateTime.Now().ToString()") as string Following Biri s link, I got this snippet (modified to remove obsolete method ICodeCompiler.CreateCompiler(): private object Eval(string sExpression) { CSharpCodeProvider c = new CSharpCodeProvid...

What are the performance characteristics of 'is' reflection in C#?

It's shown that 'as' casing is much faster than prefix casting, but what about 'is' reflection? How bad is it? As you can imagine, searching for 'is' on Google isn't terribly effective. ...

Loading different versions of the same assembly

Using reflection, I need to load 2 different versions of the same assembly. Can I load the 2 versions in 2 different AppDomains in the same process? I need to do some data migration from the old version of the app to the new version. Please let me know if this is possible or should I use 2 separate processes. ...

How Do I Load an Assembly and All of its Dependencies at Runtime in C# for Reflection?

I'm writing a utility for myself, partly as an exercise in learning C# Reflection and partly because I actually want the resulting tool for my own use. What I'm after is basically pointing the application at an assembly and choosing a given class from which to select properties that should be included in an exported HTML form as fields....

Using reflection to call an ASP.NET web service

Say I have an ASMX web service, MyService. The service has a method, MyMethod. I could execute MyMethod on the server side as follows: MyService service = new MyService(); service.MyMethod(); I need to do similar, with service and method not known until runtime. I'm assuming that reflection is the way to go about that. Unfortuna...

.NET Introspection VS Reflection

What is the difference between Introspection and Reflection in .NET ...

Obtain parameter values from StackFrame in .NET?

I would like to be able to obtain all the parameter values from the StackFrame in .NET. A bit like how you're able to see the values in the CallStack when in the VS debugger. My approach has concentrated on using the StackFrame class and then to reflect over a ParamaterInfo array. I've had success with reflection and properties, but this...

PropertyGrid, DefaultValueAttribute, dynamic object, and enumerations

Note: I am using .Net 1.1, although I am not completely against answer that use higher versions. I am displaying some dynamically generated objects in a PropertyGrid. These objects have numeric, text, and enumeration properties. Currently I am having issues setting the default value for the enumerations so that they don't always appear ...

Calling base.Dispose() automatically from derived classes

Edit - New Question Ok lets rephrase the question more generically. Using reflection, is there a way to dynamically call at runtime a base class method that you may be overriding. You cannot use the 'base' keyword at compile time because you cannot be sure it exists. At runtime I want to list my ancestors methods and call the ancestor...

Getting all types in a namespace via reflection

How to get all the classes in a namespace through reflection in C# ...

Implementations of interface through Reflection

How to get all implementations of an interface through reflection in C# ...