A feature of the CLR; a global function named .cctor—sometimes known as an inside static constructor—that is guaranteed to run before any other code in the module runs.
Questions tagged [clr-module-initializer]
7 questions
27
votes
6 answers
Module initializers in C#
Module initializers are a feature of the CLR that are not directly available in C# or VB.NET. They are global static methods named .cctor that are guaranteed to run before any other code (type initializers, static constructors) in an assembly are…

Einar Egilsson
- 3,438
- 9
- 36
- 47
7
votes
0 answers
C++/CLI Module Initializer for managed code
Is it possible to run managed initialization code for a c++/cli dynamic library?
I have a large collection of managed classes all wrapping underlying unmanaged functionality, used by many different solutions. I now need to call some managed code…

user2299700
- 101
- 1
- 2
2
votes
0 answers
Run code when Assembly is loaded
I have some code in my library that I want to run on the fly when the assemnly is loaded. Similar to how for example Owin auto inilitize itself.
Is this the way you do it?
.Net: Running code when assembly is loaded

Anders
- 17,306
- 10
- 76
- 144
1
vote
2 answers
Incorrect behavior of the [ModuleInitializer]?
I try to use [ModuleInitializer] in .net5 code. My test assembly
namespace TestAssembly
{
public class Class1
{
[ModuleInitializer]
public static void Init()
{
Console.WriteLine("ModuleInitializer");
…

Pavel Ivchenkov
- 55
- 4
1
vote
0 answers
Finding a Module Initializer in C# via Reflection
Is there any way to find a module initializer in c# via reflection? I'm loading in an assembly with completely unknown types, but there will definitely be a module initializer in the assembly, but there doesn't seem to be any way to find it using…

Mystborn
- 15
- 5
1
vote
0 answers
Is there a way to customize the default module initializer?
I am compiling an existing C++ library as a C++/CLI DLL. The C++ library has two initialization routines which need to be called to set up various lookup tables.
The C++ library originally used std::once_flag and std::call_once() from to…

Daniel Trebbien
- 38,421
- 18
- 121
- 193
1
vote
1 answer
my __init is called but not getting call for probe
I am enabling the pinctrl driver in the raspberry linux and I tried something and enabled it.
But what happened is, the __init is calling but the probe is not calling by the linux.
My code is
this is the probe
static int…

optimus prime
- 764
- 1
- 13
- 39