I am trying to save an Assembly to a file using System.Reflection.Emit.AssemblyBuilder but it's not working.
I've got a variable to hold an assembly that is running perfect when I load and run it.
System.Reflection.Assembly dll = GetAssembly(resource);
Is there anyone who can help me to save this "dll" into a file like "name.dll"?
...
I'm using RMI to allow access to my Java application via MATLAB, which runs in another JVM. MATLAB has a nice interface to print the methods of a Java object. But it fails with RMI, because the object it gets is a proxy.
So I would like to add my own method to extract/print the capability of a remote interface (RMI obviously can't direc...
Is it possible to reflect on an explicit interface implementation from the call stack? I want to use this info to look up an attribute on the interface itself.
Given this code:
interface IFoo
{
void Test();
}
class Foo : IFoo
{
void IFoo.Test() { Program.Trace(); }
}
class Program
{
static void Main(string[] args)
...
I want to determine whether MyBindingSource.DataSource is assigned to the designer-set Type, or if it has been assigned an object instance. This is my current (somewhat ugly) solution:
object result = MyBindingSource.DataSource;
if(result.GetType().ToString() == "System.RuntimeType")
return null;
return (ExpectedObjType) result;
...
Here is the Context :
I try to code a mapper for converting my DomainModel Objects to ViewModel Ojects dynamically. The problem I get, it's when I try to invoke a method of generic class by reflection I get this error :
System.InvalidOperationException : Late bound operations cannot be performed on types or methods for which ContainsGe...
Im trying to launch a dialog by invoking several methods from a windows forms assembly. My app is a console app. All the execution logic goes well and without exceptions, but the window is not launched. Is it a known issue that you cant launch a windows form from a console app?
...
I have three classes: SomeThing, SomeOtherThing, and YetAntherThing. All three have an identical member called Properties. In each class, it is a key/value pair such that I can reference obj1.Name, obj1.Value, obj2.Name, obj2.Value, obj3.Name, and obj3.Value. I'd like to pass these three objects into a single method that could iterate th...
I would like to get a list of classes that are available at runtime and that match a simple name.
For example:
public List<String> getFQNs(String simpleName) {
...
}
// Would return ["java.awt.List","java.util.List"]
List<String> fqns = getFQNs("List")
Is there a library that would do this efficiently, or do I have to manually g...
I have specified an interface (though I can change it to an abstract class if that helps), say T. The users of my API will pass me a Class<? extends T> on which I will call newInstance() (I cannot change that part). How can I ensure that classes that extend T have a constructor which takes no parameter?
...
class ParentClass
{
public function list()
{
foreach ($this as $property => $value)
{
if (is_public($this->$property))
echo 'public: ';
else if (is_protected($this->$property))
echo 'protected: ';
echo "$property => $value" . PHP_EOL;
}
...
Given the a class with the following structure. I am trying to determine the type of the parameter T assigned by the caller of the generic method.
public class MyClass{
public <T> Boolean IsSupportable() {
Class typeOfT; // Need to determine Class for generic parameter T
// Business Logic goes here
retu...
Hello, i'm a bit confused about modules, namespace and reflection.
$obj = new default_Model_foo();
$obj->bar();
The code above runs properly, but i need to add reflection;
I've got these variables:
$moduleName = "default";
$modelName = "foo";
$function = "bar";
I would like to instantiate a class at runtime, how can do it?
Tha...
Im running a console app that loads a dll and calls a method from that dll that creates a WPF form. So I'm just calling to Program.Execute() method and it does all the creation of the form. All reflection business goes well, but the form does not appear.
I've been told that this is because a console app does not have a windows message ...
Here is the code from the dll:
public static bool SendCommand(string command)
{
KillTeraTerm();
try
{
SerialPort portToUse = new SerialPort("COM2");
portToUse.Open();
portToUse.WriteLine(command);
portToUse.Close();
StartTeraTerm();
...
Hello,
I have this little piece of code :
private Dictionary<string, IList<KeyValuePair<int, string>>> EnumsCollection = new Dictionary<string, IList<KeyValuePair<int, string>>>();
// ...... Dictionary is filled, fine
// ... outer loop
foreach (var enumNameAndValue in EnumsCollection[enumName])
{
var code...
I am trying to hook Up a Delegate Using Reflection. This is what I have done so far
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Data;
using System.Threading;
using System.IO;
using System.Reflection;
using System.Windows;
namespace ChartHelper
{
public class I...
I have a 32 bit .NET class library having a simple public class and a simple public method. I have a 64 bit .NET console application where using reflection, I wish to load the 32 bit assembly and consume its method.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using Host....
If I have a Type, is there some easy way to tell that it represents a nullable value type using Reflection? Ideally something a little cleaner (and more correct) than:
static bool IsNullable(Type type)
{
return type.IsValueType && type.Name.StartsWith("Nullable");
}
...
I am trying to create a List of properties for objects. I can create a list for basic objects just fine, but if I have a situation where type object A contains a property of type object B which contains a property of type object A.... well.. then I get infinite recursion.
What I've done is added a static property to all of my objects ca...
In a unit test I need to test whether alias methods defined by alias_method have been properly defined. I could simply use the same tests on the aliases used for their originals, but I'm wondering whether there's a more definitive or efficient solution. For instance, is there a way to 1) dereference a method alias and return its original...