According to How the Runtime Locates Assemblies step 2 is Checking for Previously Referenced Assemblies.
However, in the code below you can see that this is definitely not happening. In the first line, an assembly is loaded (which should make it a "previously referenced assembly" for all future calls.)
However, a couple lines later wh...
I come from low level languages - C++ is the highest level I program in.
Recently I came across Reflection, and I just cannot fathom how it could be used without code smells.
The idea of inspecting a class/method/function during runtime, in my opinion, points to a flaw in design - I think most problems Reflection (tries to) solve could...
I have a Silverlight 3 tools library with a custom DataGrid user control. This grid has no direct access to the WCF RIA Services entity types so I'm using reflection to add a new item when the user clicks on the grid when it's empty:
private void InsertEmptyRecord()
{
if (this._dataGrid.ItemsSource == null)
return;
Type...
I am trying to create a generic list of objects using reflection. The below code throws an error Cannot create an instance of an interface. . I could change the IList to List and it works fine, but I was wondering if there is way to get this working with an IList.
var name = typeof (IList<T>).AssemblyQualifiedName;
Type type = ...
Hi Everyone
I am doing some reflection work and go to a little problem.
I am trying to print objects to some GUI tree and have problem detecting arrays in a generic way.
I suggested that :
object instanceof Iterable
Would make the job ,but it does not, (obviously applies only to Lists and Set and whoever implements it.)
So how ...
Hello,
I am trying to invoke a method via reflection with parameters and I get "object does not match target type". If I invoke a method without parameters it works fine. Based on the following code if I call the method Test("TestNoParameters") it works fine. However if I call Test("Run") I got an exception. Is something wrong with my c...
I have a class that stores a large number of int member variables, each defined as follows:
public final static int int1 = int1value;
public final static int int2 = int2value;
...
public final static int int106 = int106value;
There is a second class that needs to do a loop based on the number of ints in the first class. How would I go...
In a proof-of-concept project I'm working on, I have a generic abstract class that I expect to be extended by a number of child classes:
public abstract class Pet {
public abstract string PetTypeName {get;}
}
public class Dog : Pet {
public override string PetTypeName { get { return "Dog"; } }
}
I'd like to have a static coll...
Is there anyway to set a value of a static (private) variable without needing to initalize the object?
The SetValue method requires an instance, but I'm hoping there's a way to get around this.
Thanks!
...
Does anyone know the status of a fully-featured reflection API for Scala?
I know that you can use Java's reflection API to do simple things but this does not work well with Scala's language features. I found an interesting article describing an experimental Scala Mirroring API but as far as I know this is still experimental. I've als...
Is there a way of getting the assembly name from a namespace string? Eg, get "mscorlib" from "System".
The reason for my question is I'm creating Boo scripts method-by-method and am required to add namespaces programmatically. The resulting string in Boo would read:
import System from mscorlib
I could obviously pass in a collection...
Let's say I have the following enum:
public enum Colors
{
White = 10,
Black = 20,
Red = 30,
Blue = 40
}
I'm wondering if there is a way to iterate through all the members of Colors to find the member names and their values.
...
So in my case i am doing discovery of the structure of a class using reflection. I need to be able to find out if a property is an auto-implemented property by the PropertyInfo object. I assume that the reflection API does not expose such functionality because auto-properties are C# dependent, but is there any workaround to get this info...
For running all my test classes automatically, I look for all class files inside a dedicated directory, convert the path to a package name and check if this class implements the given interface:
try {
Class<? > myTestClass = Class.forName( constructedClassName );
if( myTestClass.isInstance( MyTestInterface.class ) ) {
te...
I'm having trouble wrapping my mind around how to calculate the normal for a moving circle in a 2d space. I've gotten as far as that I'm suppose to calculate the Normal of the Velocity(Directional Speed) of the object, but that's where my college algebra mind over-heats, any I'm working with to 2d Circles that I have the centerpoint, ra...
I am in need of some help here about doing a dynamic instantiation in C#. What I want to accomplish is to be able to use a string variable that is used as the name in the instantiation. I think you can use reflection or something, but I am lost on this one. Here is my test code snippet and hopefully someone has an answer.
Averages is ti...
All the examples I look at for reflection show creating a new instance of an unknown implementation, and casting that implementation to it's interface. The issue with this is that now you can't call any new methods (only overrides) on the implementing class, as your object reference variable has the interface type. Here is what I have:
...
I've heard a lot about the new/improved RTTI capabilities of Delphi 2010, but I must admit my ignorance...I don't understand it. I know every version of Delphi has supported RTTI...and I know that RTTI (Runtime Type Information) allows me to access type information while my application is running.
But what exactly does that mean? Is Del...
I have a marker interface something like this:
[AttributeUsage(AttributeTargets.Method, AllowMultiple=false, Inherited=true)]
public class MyAttribute : Attribute
{
}
And i want to apply it to methods on different classes in different assemblies...
Then I want to Get a MethodInfo for all methods that have this attribute applied. I ne...
Assume I have an Excel.PivotField, and I need to setHiddenItemsList on my object.
With VB.NET and Option Strict Off & Option Explicit Off this would result in:
Dim field as Excel.PivotField = MyFunctionCall()
field.HiddenItemsList = GetHiddenItems()
While this works with this security setting, it obviously doesn't work when you set O...