I have written earlier in C/C++ but currently, I need it to convert into C#.
Can anyone tell me the code/way How to write drivers in C#?
Actually currently I have some problems with my old application written in C++ and we have to write the drivers of our LPT1,COM Printers and other USB drivers in C#.
Actually, you can write some drivers in C# if you use UMDF because it runs in usermode (see Getting Started with UMDF). But my recommendation is to use C/C++.
Simply you can't. C# produces intermediate language that is interpreted by a virtual machine (.NET). All these stuff runs in user mode and WDM drivers run in kernel mode.
There is a DDK but it is not supported in VStudio either (but you can make a makefile project for compilation though).
Driver development is complex, prone to blue screen and requires a good understanding of C , kernel structures and mem manipulation. None of those skills are required for C# and .NET therefore there is a long and painful training path.
You cannot write kernel mode drivers in C# (the runtime executes in user mode therefore you can't get into ring0). This SO Q/A provides some links you may find helpful:
C# driver development?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With