When running a C# application under mono with the "mono " command, the following works:
var fileName = System.Reflection.Assembly.GetExecutingAssembly().Location;
But after packaging the assemblies into a single file using mono's mkbundle2, the line above does not return the expected result.
...
Assmbly.GetTpes() gets the types in the assembly but if I also wants nested class (OrderLine) how do I do that? I only know the name of the assembly, not the class names so GetType(Order+OrderLine) will not work.
public class Order
{
public class OrderLine
{
}
}
...
Is there any way to using reflection in .net to get a property's value using a path like so...
type t {
id : int
name : string
}
type s {
id : int
st : t
{
let a = {id = 1; {id = 2; name = "foo"}}
a.getType().getProperty("st.name")
Sorry for the F#. This doesn't work obviously but it illustrates what I'm trying to ...
A lot of Java projects use reflection. I wonder if is there a reflection library which make the use of java.lang.reflect easier.
We could use it like:
Reflected object = new Reflected( new Object() {
String name="Oscar";
String lastName="Reyes";
String reverseName(){
return new StringBuilder(nam...
Hello, i need to build a program that load older versions of a COM DLL file and performs some operations. I've created a DLL project for each version and set the reference to the correspondent COM. After that in the main program i'm trying to load the needed assembly that load and use itself its COM.
The problem is that the DLLs have Int...
Hello :)
I'd like to write a method which obtains the name of the calling method, and the name of the class containing the calling method.
Is such a thing possible with C# reflection?
Billy3
...
I have a C# wraper class with a series of methods accepting various data types:
public class MyClass
{
public void ProcessString(string Value) { // implementation }
public void ProcessInt(int? Value) { // implementation }\
public void ProcessOther(MyClass Value) { // implementation }
}
I now want to add a generic ProcessOb...
I want to create a Delegate of a reflected method, but the Delegate.CreateDelegate requires the Type of delegate be specified. Is it possible to dynamically create a 'Delegate' that matches whatever function is reflected?
Here is a simple example:
class Functions
{
public Functions()
{
}
public double GPZeroParam()
...
In a Rest Service using the JAX-RS specification, I can define a generic service like
@GET
@Path("something")
@Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public List<MyPojo> getMyPojoList() {
...
}
Something magic happens in Jersey because when invoking
javax.ws.rs.ext.MessageBodyWriter#writeTo(T t,
...
I was reading an article at msdn about reflection but i was not able to understand it even 10% about its benifit, its usage.
Could you please provide some brief overview what is reflection and how can i take benefit from it.
...
I have some old C# plugin code that was implemented strictly with Reflection. In fixing some C# 2.0 -> 4.0 compatibility issues ("Load from Remote Source") I've decided to get rid of the old reflection code and replace it with an interface. The interface is needed because the Plugins now need to be loaded into their own AppDomain and t...
I want to make a command-line utility that does some operations based on reflection of external class files. I would pass in a path to .class files or source files(possibly wildcards). At some point during the execution, I need to get Class objects for each class, not knowing their package names beforehand. What would it take to do th...
The MSDN Documentation: MemberInfo.GetCustomAttibutes Method (Type, Boolean) states in the remarks:
This method ignores the inherit parameter for properties and events. To search the inheritance chain for attributes on properties and events, use the appropriate overloads of the Attribute.GetCustomAttributes method.
This basically m...
I was going over a Joel Pobar's Dodge Common Performance Pitfalls to Craft Speedy Applications article on Reflection and I was looking at a particular piece of code that isn't compiling (slightly modified to narrow down to the specific error, because his example had more errors):
MethodInfo writeLine = typeof(Console).GetMethod("WriteLi...
Without working on the source, just on the basis of a binary, is there a way (there sure must be using CodeDom, but it'll be nice if it is possible without CodeDom) to tell if a method's body has an if construct, using reflection?
...
Is it possible to load the CodeDOM from a .NET binary created using C#?
...
using System;
interface IAnimal
{
}
class Cat: IAnimal
{
}
class Program
{
public static void Main(string[] args)
{
IAnimal cat = new Cat();
// Console.WriteLine(cat.GetType());
// This would only give me the type of
// the backing store, i.e. Cat. Is there a
// way I can get...
I know that .NET apps are difficult to protect. I use RedGate Reflector and know that generally speaking you can get source code from many .NET dlls.
however my question is - is it actually feasible to decompile the whole application?
I mean - create a workable VS solution so the pirate can just press F5 and get the exactly same result...
I want to replace one line of code in 3d party API with my own code.
I mean this is questionable practice but I need to fix their bug (the idiots call ResolveDNS on every method call which writes to TCP socket - what they were going to achieve with it?) which results in untolerable lags. I want to cache DNS name in static field and scr...
I want a function exactly like PHP's compact function.
i.e., if I pass in a list of variable names:
compact('var1','var2')
it returns me back a dict:
{'var1':var1, 'var2':var2}
...