reflection

Need a tool to dump the referenced types and members for an assembly

I need a tool that can dump the referenced types used by an assembly in a machine readable format. e.g. this Code in assembly 'dummy.exe' static void Main() { Console.WriteLine("Hello World"); } would produce something like <references assembly="dummy.exe"> <mscorlib> <System.Console> <WriteLine/> ... Can you do this...

Blanking fields with Reflection

Hello I am writing a Junit test framework to test web services. There is a requirement for the input values to come from many different sources, eg an earlier web service call or literals within the class. To achieve this I have constructors that accept the different inputs in different ways; all simple so far. The problem is the web...

object created with "new" keyword and created with reflection

I came to know that using Reflection we can create objects without using "new" keyword. So I wanted to know are there any differences in them or any particular scenarios to use Reflection. Because till now i didnt create or seen any of the code creating object with reflection. Why using 'new' became so used and reflection not. ...

Remoting: Finding client AppDomain / Assembly from server AppDomain

Hello, I have an application with a server "AppDomain", which accepts calls from separate AppDomains (which host plugins, developed by other people and not trustworthy). From the server AppDomain, I need to know which "Plugin" (AppDomain) is actually making the call, so that I can ensure that this plugin has access to the resource. I ...

problem with using java reflection

Suppose I want to write a function, which will create a HashMap from some specified type T to String, for example, a HashMap from Integer to String as follows: HashMap<Integer, String> myHashMay = new HashMap<Integer, String>(); I want to have flexibilty to specify the type T. So I write a function as: void foo(Class<?> myClass) { ...

the internals of System.String

I used reflection to look at the internal fields of System.String and I found three fields: m_arrayLength m_stringLength m_firstChar I don't understand how this works. m_arrayLength is the length of some array. Where is this array? It's apparently not a member field of the string class. m_stringLength makes sense. It's the le...

Scala equivalent to C#'s Expression API

Is their an equivalent to C#'s Expression API in scala? For example, I would like to have a lambda like this: (Foo) => Foo.bar and be able to access "bar" in the function it is passed to. ...

WPF Binding to properties of an object with specific attributes

I have a listbox to which I have bound the data context to an object. This object has a number of properties some of which will have a particular attribute. What I want to do from this is to have the items source set to the properties of the object but to only display those properties that have a particular attribute set. Can anyone he...

How to get the properties of the Details tab in a file.

You should all have noticed if you right click a file in the windows explorer, there is a tab named Details. Is there any trick to get these properties, and specifically the product name, whether this is a .NET file or not, over C#? Thank you. ...

Using .Net, is it possible to get the list of all "running/active" instances from a specific type?

I would like to know if it is possible to get all the objects running from an application/assembly/appdomain of a specific type... I don't think reflection would help in this case as I need an object before hand. However, I want to got the other way: from a type I want all the objects created from it. Is this possible with .Net? ...

C# getting its own class name

If I have a class called MyProgram is there a way of retrieving "MyProgram" as a string? ...

In java how do I serialize a class that is not marked Serializable?

There is a specific class in a third party library that I want to serialize. How would I go about doing this? I'm assuming I will have to write a method that takes in an object of the class and uses reflection to get the private member values. Then for deserialization I would use reflection to put the values back. Would this work...

Testing properties with reflection using attributes

I'm trying to create a nUnit test to do the following: 1) Load the DLL to test. 2) Iterate among the various types. 3) Find the ones that have a certain custom attribute. 4) Instantiate these types and make sure that all their public properties aren't null. Here's what I wrote so far: Assembly assembly = Assembly.LoadFile("MyLib.dll...

java: get all variable names in a class

Hi. I have a class and i want to find all of it's public variables (not functions). how can i do so? thanks! ...

Invoke a method via MethodInfo Problem

Hi Everyone, I get the class name and method name as well as parameters via query string. I don't know what is coming so I can't say lets create this instance or that instance to pass it MethodInfo Invoke method so I need a generic solution. Here is the problem : string className = Request.QueryString["className"]; string actionMethod...

Loading/Unloading assembly in different AppDomain

Hey there I need to execute a method in an assembly loaded during runtime. Now I want to unload those loaded assemblies after the method call. I know that I need a new AppDomain so I can unload the libraries. But here, the problem arises. The assemblies going to load are plugins in my plugin framework. They have no entry point at all. ...

Reflecting over all properties of an interface, including inherited ones?

I have an instance of System.Type that represents an interface, and I want to get a list of all the properties on that interface -- including those inherited from base interfaces. I basically want the same behavior from interfaces that I get for classes. For example, given this hierarchy: public interface IBase { public string Base...

C# Reflection - Can I check if one method makes a call to another.

I'm looking for a way to ensure that method 'A' calls method 'B'. So roughly, the deal is.. class one { internal static void MethodA() { //Do Something here. SHOULD be calling B. } void MethodB() { //MUST be called by MethodA. } } class two { internal void MethodA() { //Test t...

Retrieve a MethodInfo on an int

Is it possible to retrieve the MethodInfo for * operator on an Int32? I've tried this code but without success (it returns null): MethodInfo mi = typeof(System.Int32).GetMethod("op_Multiply"); Thanks! ...

Attribute, interface, or abstract class

I'm wondering what the general recommendation would be (attribute, interface, abstract class, or combination thereof) for the following implementation: /// <summary> /// Loads class specific information into a list for serialization. The class must extend PlugIn. /// The filenames parameter is passed from a FileDialog. /...