[Mono-list] can we add kernel32 dll in mono

Dallman, John john.dallman at siemens.com
Wed Jul 15 10:08:34 EDT 2009

Bharti Mishra wrote:

>   how can I add kernel32 dll in mono.
>   and can you explain me this error.

Windows is an operating system, as is Linux (OpenSUSE is just one 
of many distribution of Linux, and most of them are much the same 
in this respect). Windows is very different indeed from Linux. 

Kernel32.dll is one of the main Windows DLLs, a fundamental part of 
the operating system: it provides system calls that are used by many 
native code programs on Windows. Linux can do most of the same things 
as Windows, but its system calls have different names, do subtly 
different things and are found in libraries that have entirely 
different names. 

The Windows API and the Linux API are not very much like each other. 
In terms of human languages, they might be as similar as English 
and Hindi, in that they share some ideas about grammar, but trying 
to look for the one word in English that means exactly the same 
thing as a Hindi word is usually futile. It's perfectly possible to 
be fluent in both, but it takes skill and intelligence, something 
that computer programs notably lack. 

Because the Windows API isn't as well-designed as it might be, .NET
provides a new set of APIs. Those don't have a one-to-one 
correspondence to the Windows APIs: they are more general, and are
not tied to Windows. They mostly can be, and largely have been, re-
implemented on Linux and similar OSes, and that's a large part of 
what the Mono project provides: an API that works the same way on 
both Windows and Linux. 

Unfortunately, this .NET program you have, written in VB.NET, is not 
a "clean" .NET program. It bypasses the proper ways for a .NET program
to behave and calls the Windows API directly. It may be that this is 
really unavoidable, because it needs to use some piece of obscure 
Windows functionality that isn't available through the .NET API. But 
it is far more likely that it was written that way because it seemed
easier to somebody who was used to writing old-style pre-.NET VB, 
where you had to use the Windows API a lot.

If you really need to get this program working on Mono, it is going
to have to be changed to be a pure .NET program. You really don't 
want to start trying to write an emulation of kernel32.dll; that would
be a huge and very difficult project. Mono doesn't attempt that, and 
that seems a very wise decision to me. Copying the kernel32.dll from 
a Windows system won't do you any good, because the DLLs it relies on 
won't be present, and if you copy them, the problem just gets worse. 

If you simply need to get this VB.NET program running on a Linux system,
you might want to try the Wine Windows emulator for Linux, or running 
Windows under some virtual machine system of your choice. 

John Dallman

More information about the Mono-list mailing list