Linked Questions
16 questions linked to/from Call static method with reflection
0
votes
1
answer
2k
views
call method from all classes within namespace [duplicate]
I'm sure there's a word for this but have had no luck finding anything on it. I have several classes within 'Namespace.Objects' and i want to run a static function called 'RunThis' on all the classes ...
0
votes
2
answers
466
views
Run a base class method from a derived class on another assembly dynamically [duplicate]
I'm trying to call from another assembly a base class static method from it's derived class dynamically, using the following code:
Assembly executingAssembly = Assembly.GetExecutingAssembly();
...
1
vote
2
answers
189
views
Calling a static function given a type name [duplicate]
I have a string holding a type name. I want to get the type in reflection, and call a static method.
I want to keep the code simple as possible.
something like this:
public class MyClass {
...
1
vote
1
answer
81
views
How do I use Type.GetMethods inside a static class? [duplicate]
I have a list of "commands" for a console-line application that I'm developing. One of them is a method that prints all available commands for the player to use. I've tried calling Type.GetMethods on ...
0
votes
0
answers
40
views
Calling method from C# dll [duplicate]
how could i call a static method from a dll (wrote in c#) from my main program (also wrote in C#)?
public static class Entry
{
[DllImport("User32.dll", CharSet = CharSet.Unicode)]
...
0
votes
0
answers
32
views
Access static class of dynamic (not known at compile time) type? [duplicate]
I want to access a static class of a name that I don't know at compile time - that's not a good description so let me elaborate.
Imagine: 3 static classes that all inherit from an interface,
Now a ...
3
votes
5
answers
10k
views
C# "Inheriting" Static Methods?
Here's an example of what I want to accomplish:
abstract class DoSomething
{
static void DoWhateverItIsThatIDo()
{
Console.WriteLine("You asked the abstract class to work. Too bad.");
...
14
votes
1
answer
6k
views
Static classes can be used as type arguments via reflection
When trying to use a static class as a type parameter, the C# compiler will throw an error:
var test = new List<Math>();
error CS0718: `System.Math': static classes cannot be used as generic ...
1
vote
1
answer
2k
views
How to call static method of static generic class with C# Reflection?
I have many classes with these implementations:
internal static class WindowsServiceConfiguration<T, Y> where T : WindowsServiceJobContainer<Y>, new() where Y : IJob, new()
{
internal ...
0
votes
2
answers
767
views
Invoke Method, pass object as type
I am working with the following class:
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
And I have a string containing following:
public class ...
1
vote
1
answer
468
views
CAKE: Unsafely load assembly
I use CAKE 0.21.1.0.
I want to add a task that performs the equivalent of this PowerShell operation:
$dlls = @(${dll1}, ${dll2})
$dlls | % { [Reflection.Assembly]::UnsafeLoadFrom($_) }
[...
0
votes
1
answer
298
views
Casting Enumerator type with reflection
I am trying to replicate a functionality with reflection but end up getting
CreateFormatMethod.Invoke(typDbFormatClass, null)' threw an exception of type 'System.Reflection....
-1
votes
2
answers
127
views
How to execute static methods by name
I have an XML file with classes name like this:
<ActiveMonitorsList>
<MonitorName>CertificatesMonitor</MonitorName>
<MonitorName>ServicesMonitor</...
2
votes
1
answer
123
views
Execute method on persisted assembly from dynamic assembly
It is possible to call a method that resides on a "Normal" assembly from a dynamically constructed assembly?
For example, assembly B is dynamically constructed(via Emit) from assembly A and assembly ...
0
votes
1
answer
70
views
calling static methods on a class after discovering that it supports it
This question was going to be "defining static interfaces' but I realized that was
already asked (answer from Skeet = No)
presupposed the answer
So the question is. I have a method that accepts a type ...