Linked Questions

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 ...
user5426405's user avatar
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(); ...
João Sequeira's user avatar
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 { ...
Adibe7's user avatar
  • 3,539
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 ...
Caleb Libby's user avatar
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)] ...
George Autry's user avatar
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 ...
Chris's user avatar
  • 91
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."); ...
mngeek206's user avatar
  • 5,227
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 ...
Lazlo's user avatar
  • 8,732
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 ...
Mohammad Gorji's user avatar
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 ...
colosso's user avatar
  • 2,523
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($_) } [...
M.Y. Babt's user avatar
  • 2,941
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....
battech's user avatar
  • 833
-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</...
Kamil Turowski's user avatar
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 ...
nohros's user avatar
  • 327
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 ...
pm100's user avatar
  • 50.6k

15 30 50 per page