I'm trying to get some information from an msi file
I used:
Type installerType = Type.GetTypeFromProgID("WindowsInstaller.Installer");
object installerInstance = installerType.CreateInstance(installerType);
i'm well aware of the option to add reference to the file C:\windows\system32\msi.dll, and cast installerInstance to WindowsInst...
I've seen quite a few questions related to how do I invoke a method like this and that. What I haven't found is a listing of the different options of how to invoke a method via reflection or any other means in csharp.
Can someone explain in detail the different ways of dynamically invoking a method in csharp? From reflection to emitting...
Hello all!
I have a method which in essence converts a datatable to a list of objects which I call 'Bags'. This code is called many times per session, with many sessions concurrently running and with sometimes thousands of rows. Because of this I need it to be as quick as possible. I have an xml file which contains the DataColumn to ...
I have some code that references an outside DLL which in production will be loaded by a factory. The DLL shouldn't be referenced directly by my assembly, it will be loaded at runtime using Assembly.Load().
This all works just fine, but when it comes to debugging, I want to be able to step through the library as if I'd referenced it usi...
As in this example:
switch ( myObj.GetType ( ) )
{
case typeof(MyObject):
Console.WriteLine ( "MyObject is here" );
break;
}
...
I am trying to do the following:
Given TypeInfo after reflecting on a LINQ-to-SQL object with various EntitySet<> child collections, retrieve the collection
Do some operations on the collection
The code below does not compile, obviously - just looking for another way to do this [Note, "Facade" is the L2S object in question). The thi...
I'm trying to write a Compare method to compare properties in some POCOs using Reflection to ensure that they've been persisted to the database correctly. For example, let's say I have this POCO:
public class NoahsArk
{
public string Owner { get; set; }
public ICollection<Animal> Animals { get; set; }
}
What I want to do is th...
Given this class
public partial class Default : Page
{
private IRepository repo;
...
}
I want to find and set the private repo field. Is that possible?
UPDATE
I tried using the GetFields(BindingFlags.NonPublic), it returns {System.Reflection.FieldInfo[0]}.
UPDATE II
I tried using the GetFields(BindingFlags.NonPublic | Bin...
Lets say I have some random .cs file containing a class with some properties and methods of all sorts.
How can I iterate the names (as strings) of all these public string properties?
Example.cs:
Public class Example
{
public string FieldA {get;set;}
public string FieldB {get;set;}
private string Message1 {get;set;}
public int some...
I want to understand why the protocol buffers solution for .NET developed by Marc Gravell is as fast as it is.
I can understand how the original Google solution achieved its performance: it pre-generates optimized code for object serialization; I've written some serialization by hand and know that it is possible to write pretty fast co...
Hi folks,
I need a way to check out all namespaces used by a type via reflection.
namespace My.Program.BaseTypes
{
using System;
using System.Text;
using My.Program.Extenders;
using My.Program.Helpers;
using My.Program.Interfaces;
public class MyTypeBase
{
public MyTypeBase()
{
}
...
Lets say I have a inheritance tree of interfaces:
IParent > IChild > IGrandChild
How would I:
Find a class that implements IParent
Determine the closest ancestor of the class that is also a child of IParent.
For example:
var myClass = FindImplementor<IParent>();
var myInterface = ClosestAncestor<IParent, myclass>();
I'm not look...
I have a broken Assembly that I want to reflect over, its not broken badly, it just cannot find a referenced assembly, so it does fail a PEVerify. But....Assembly.LoadFrom() will still load it and GetTypes() will throw a ReflectionTypeLoadException, the .LoaderExceptions array shows me what referenced assembly cannot be found. At this po...
This seems like a really basic thing that I'm doing, yet I'm tearing my hair out trying to make it work.
My situation is this: I have a project which contains a large number of lookup tables, and I have all of these lookup tables represented in a single typed DataSet, which contains TableAdapters for each lookup. I've designed an edito...
I need to convert all DateTime values to String, though out my project, all of my code at the end follows 1 function, where I have 4 different Hashtables (actually XmlRpcStruct Object of CookComputing xmlrpc library).
is there any way that without iterating on each hash table - I can convert the values of hashtable having datetime -> st...
Hi...i need to execute a method "FindAll" in my page, but can be with any class. This method return a list of the object.
This is my method that i execute "FindAll". FindAll requires an int and returns an List of these class.
public void ObjectSource(int inicio, object o)
{
Type tipo = o.GetType();
obje...
var property = obj.GetType().GetProperty(blockName);
if (property == null)
{
var method = obj.GetType().GetMethod(blockName);
if (method == null)
return "[" + blockName + "]";
else
return method.Invoke(obj, null).ToString();
}
el...
I'm trying to do something like this:
class A {
public function foo() {
$b = new B;
$b->invokeMethodFromAnotherObject(new ReflectionMethod($this, 'bar'));
}
public function bar() {
}
}
class B {
public function invokeMethodFromAnotherObject(ReflectionMethod $method) {
$method->invoke(?);
}
}
But...
I'm writing a content management system in ASP.NET/C# which the template of the site is defined in a html file. I am passing parameters to the html file with blocks. A block starts with [ and ends with ]. An example for a template with some simple blocks:
<html>
<head>
<title>[Title]</title>
<meta name="description" content="[De...
Hey
I have an array of MyType s in an object similar to the setup below, I want to be able to set the value of an index on myObject as it is, I cannot change the declaration of MyFunction.
/*...*/
MyType [] myTypedArray = new MyType[100];
MyFunction(myTypedArray);
/*...*/
function MyFunction(object myObject)
{
myObject[0] = new My...