Tutorials: C#

Programming with C#

C# – dynamic loading of a C DLL at run-time

The Problem I am working on a C# project which needs to load one of a set of DLLs at run-time. Indeed, it needs to be able to load and unload them, possibly then loading a different one. The problem … Continue reading

C# – building a dynamic DLL loader

Following on from the previous C# article – dynamic loading of a C DLL at run-time, the next step is to make the dynamic loading functions into a class. The class will be in global scope for this example – … Continue reading

C# – calling C functions – marshalling parameter types

The Problem I am using a DLL provided for me, written in C and I want to call its functions from C#. I have explained in a previous post how to dynamically load a function from a DLL and map … Continue reading

C# – calling C functions – marshalling structs

A Previous Post explained how to marshall simple parameters so that C# code can call C functions. The marshalling ensures that all the conversions to get from C# to C types on calling the function, then back to C# types … Continue reading

C# – calling C functions – C# callbacks

The final tutorial in this series on calling C functions from C# covers the problem of how to pass a C# callback function to a C function. This is needed if you are using a C DLL and there are … Continue reading