I'm trying to get the field info of an array value from within a struct. So far I have the following, but I dont see how to get the infomration I want.
[StructLayout(LayoutKind.Sequential)]
public struct Test
{
public byte Byte1;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=3)]
public Test2[] Test1...
Hi
Looking for advice on the net but not getting very far, so I thought I would ask for some advice. I've seen it done, so know what I want to do, but looking I can work out how it was done
What I want to do, is allow users to modify the layout of an ASPX file, so that they can use it as a letter template, moving address lines, format ...
Given the path of an aspx page on my site that's been precompiled, how can get the path to compiled version (dll or other) from a second page on my site so that I can examine its properties, methods and classes via reflection?
Or some other way to generate method/property lists from aspx pages?
...
What is the proper way to load a .NET assembly into a seperate AppDomain so you can have access to its Types/Classes but still be able to unload it (and reload it).
This is a tangent of this previous discussion:
http://stackoverflow.com/questions/1137781/c-correct-way-to-load-assembly-find-class-and-call-run-method
...
We're using JUnit 4 to test: we have classes that don't are a subclass of TestCase, and they have public methods annotated with @Test. We have one file with many @Test methods. It would be nice to be able to run a subset of them via Ant from the command line, in the style of this recipe for JUnit 3:
ant runtest -Dtest=MyTest -Dtests=tes...
I have several strongly typed datasets throughout my application. Writing methods to update the data is getting tedious as each has several tables. I want to create one generic function that I can update all of the tables easily. I don't mind if I have to create one of these for each DataSet but if one function could handle all of them, ...
Hello.
I am trying to use Cecil to inspect the attributes associated with a given method. It seems to find it, but I cannot get its name using the following code:
AssemblyDefinition assembly = AssemblyFactory.GetAssembly(pathBin);
assembly.MainModule.Types[0].Methods[1].CustomAttributes[0].ToString()
I know this must be the attribute...
I would like to modify the way my C#/.NET application works internally. I have dug into the .NET framework with Reflector and found a pretty good place where I could use a different implementation of a method. This is an internal class in the System.Windows.Forms namespace. You obviously cannot alter the code of this class with the usual...
Consider this example :
import java.lang.reflect.Field;
public class Test {
public static void main(String[] args) {
C c = new C();
try {
Field f = C.class.getDeclaredField("a");
f.setAccessible(true);
Integer i = (Integer)f.get(c);
System.out.println(i);
} catch (Exception e) {}
}
}
cl...
Hello. I'd like to know how does .maxstack really work. I know it doesn't have to do with the actual size of the types you are declaring but with the number of them. My questions are:
does this apply just for the
function, or to all the functions
that we are calling for?
even if it's just for the function
were .maxstack is being declar...
Hi all,
I have encountered a small problem when trying to resolve an interface in castle using reflection.
Lets say I have an interface IService, and can resolve it like this:
var service = wc.Resolve<IService>();
This works as expected, but I want to call the method through reflection and can do so like this:
MethodInfo method = ...
I would like to use reflection in .NET to get access to the object that invoked my method. I assume it is somehow possible to view up the stacktrace. I know it's not safe for a variety of reasons, but I just need to grab and catalog some property values.
How do I do this?
Update: I'm an idiot, I forgot to say this was in C#
...
Hello. I am using Cecil to try to read my attributes properties:
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class TraceMethodAttribute : Attribute {
public TraceMethodAttribute() {
MethodStart = true;
MethodReturn = true;
MethodMessages = true;
}
...
I have a class like this:
class ItemList
{
Int64 Count { get; set; }
}
and when I write this:
ItemList list = new ItemList ( );
Type type = list.GetType ( );
PropertyInfo [ ] props = type.GetProperties ( );
I get an empty array for props.
Why? Is it because GetProperties doesn't include automatic properties?
...
I see the signature is:
public virtual void SetValue(object obj, object value, object[] index)
Wouldn't this method cause the parameters to be boxed and unboxed?
Why wasn't this method designed to be generic? Then it could even be inferred by the compiler with no boxing/unboxing penalty at runtime.
...
Have I stumbled upon implementation-defined behavior?
Here is the context:
public class GenericClass<T>
{
public class NestedGenericClass<U>
{
public void GenericMethod<K>()
{
}
}
}
Here's the behavior. This unit test passes as written. My actual questions are listed as the comment before the "wack...
Is there any way the .NET 4.0 (or earlier) reflection API to resolve a generic type parameter? See the two lines after my ArgumentException comment for my current attempt.
[TestMethod]
public void TestGenericParameterTokenResolution()
{
Type genericParameter = typeof(List<>).GetGenericArguments()[0];
Assert.IsTrue(genericParamet...
I have an app which is opening a series of DLLs on the filesystem and in the GAC, and which is holding a lock on those files. How can I release these handles explicitly so I can rebuild them in Visual Studio without closing my app?
Code follows:
private void BuildTabPage_AssemblyTree(string filename, string foldername)
{
Assembly a...
As C# operators e.g. +, +=, == are overridable. It lets me think they are sort of methods, thus wonder if there is a way to call them using reflection, on Int32 for instance.
...
Hello,
I am calling a function from a .NET assembly which returns a byte[]
how do I capture the return value of that function ?\
I tried doing this
byte[] byteData = (byte[])obj.GetType().GetMethod("methodname").Invoke(obj, new object[] { buffer});
but I get a null value back in byteData ..
Can anybody help ?
...