The Microsoft .NET framework has been with us in one form or another since the millennium, and though it has remained largely the preserve of the Microsoft universe, it has found its way since then through a variety of implementations to other platforms including MacOS and GNU/Linux. In Microsoft terms though its history goes back only as far as Windows 98, earlier MS operating systems remain off-limits.
Just a glimmer of .NET in DOS and Windows 3.11 comes courtesy of [Michal Strehovský], who has successfully compiled .net C# code for both Windows 3.11 and DOS. An in-depth explanation comes courtesy of [Scott Hanselman], and it involves some tricks spanning the decades since the early 1990s. The .NET Core compiler’s object files can be fed into the linker that shipped with an ancient version of Microsoft’s C++ compiler, which when used with Microsoft’s Win32s compatibility layer that brought some of Windos NT’s APIs to the 16-bit OS, allows C# from 2020 to run as though it were 1992 again. Meanwhile the DOS version uses .NET Core’s ability to produce self-contained executables along with some very significant tricks to pare down the size of the finished program from many megabytes to an eventual DOS-suitable 27k. Remember the apocryphal Bill Gates quote, that “640k should be enough for anyone“, that refers to the maximum memory available to DOS without extra memory-extending tricks.
Neither piece of software is especially useful, and we can’t see a rush of C# coders to these new platforms. But we applaud him for his ingenuity, and getting old hardware to do new tricks is right up our alley. It’s certainly dredged up a few memories from back in the day for us. Meanwhile we’ve featured .NET in a few projects over the years, most recently on an FPGA.
Apparently it works for F#, too. Noice ;p
FUCK C#. All my homies HATE C#.
This post was made by C++ gang
C# is great. C++ has become a hellish clusterfuck
What exactly about c++ has become a clusterfuck? Nobody is forcing you to use new features.
#define true false
Show a powerful language that doesn’t allow you to shoot yourself in the foot, and I will show you that it comes at a cost.
Which is fine if you want to write every tiny little piece of code yourself, from scratch. But as soon as you want to use a library made by someone else, you’re headed straight for dependency hell.
Isn’t this true of any language? If you stick to STL you should be good almost anywhere.
The almost-backwards comparable parts of C.
Like classes? References? Inheritance? Polymorphism? I’ve got several dangling pointers and segmentation faults that would like a word with you.
C side is the best!
So where’s the DOS part?
I suspect the point is that 3.11 runs on top of DOS, so it’s there, invisible in the background. :P
The DOS is what gives an application its power. It’s an energy field that created by all running things. It surrounds us and penetrates us, it binds the System together.
I feel penetrated each time I have to use any Microsoft product.
He didn’t do a DOS version. Michal Strehovský created a 8176 byte Windows Console application and Scott Hanselman called it a DOS application.
I’d like my refund then! (In case it’s not obvious, this is also sarcasm.)
Win32 CLI and simple GDI/DDraw applications technically can be run under pure DOS, though.
By using HX Extender, for example. DOSBox is kinda popular here. It can run on DOS itself that way.
Partially true. MIchal achived this by using 16-bit part of the PE file that typically prings “This program can not be run in DOS mode” by injecting his own binary into this section. If you know that 32/64 bit PE file contains 16-bit section then you are back in the game to inject your 16-bit binary into this section. Michal is using https://github.com/Baron-von-Riedesel/Dos64-stub to inject his 16-bit payload there.
MIchal Strehovsky actually achieved this by injecting 16-bit code in the PE section that typically displays error message “This program can not be run in DOS mode'” when user attempts to run Windows EXE in DOS. Leveraging information that 32/64 bit PE file contains 16-bit section puts him back in the game with compiler and linker. He is using https://github.com/Baron-von-Riedesel/Dos64-stub project to inject his 16-bit payload that then switches CPU to 64-bit mode and executes 64 bit code compiled with C#/IL.
MS/PC DOS is still a very important component of industry computers.. why? It is a RTOS. Apps have full access to hardware, no such thing as hardware abstraction layer. Win 3.11 [Windows for Playgroups] played an important transition to the disaster known as Windows 95… I successfully booted Win 3.1 off a Linux server, never could netboot 3.11, or Win 95, oh well it was fun trying
Can you please provide a link to where this “very important” product can be purchased.
Yes N MS-Dos was marketed thru a very difficult system, where you had to submitt and pay for the “upgrades” to the next level, if iheard it it 7.11, only accesible to military
Here you go:
https://www.freedos.org/
Oooh, you probably forgot that while your DOS is running, the industrial machine can still be running something in the System Management Mode interrupt if it has 386SL or newer. And it probably does, because most hardware power controls are or at least used to be accessed this way. In some embedded x86 processors, some functions/peripherals may be emulated by the SMI – the processor may have memory windows corresponding with the peripheral space registered to SMI. Then, trying to access that memory triggers the SMI which secretly emulates the peripheral without you knowing. And this may make the DOS non-RTOS system. There was a processor which emulated a SoundBlaster (not very well) this way. Was it VIA C5?
I cut my teeth learning the 8085 on an SDK-85, no assembler, hand coded everything, moved easily the 8088 on the PC using debug. This stuff out since Intel moved to cheap,low power laptops,etc is a truly bane to anyone ever trying to stay up with the herd. I only own old fashioned PC’s that have P5’s and such, but I never had problems reading the 8254 timer registers in realtime, or bitbanging out the parallel port to get stuff done
C still working fine on all platforms. Never did warm up to C#. We support C/C++, Python, Perl, some Fortran in my area. Between them we have everything we need. On the ‘other side’ (IT) they do quite a bit of C# programming. But then they have M$ marked on their backs :) . However that is changing. We see glimmers, that they are slowing coming around to using some open source tools though… Slowly…..
Never saw the need for ‘yet another language’ by M$ when it was created, but M$ followers seemed to glom onto it.
I learned C# a couple of years ago and let’s just say it’s not my language of choice. It feels like they basically took the good parts of C++, then removed pointers, then added hundreds of little workarounds to solve the problem that you can’t use pointers.
If you are desperate to use pointers, investigate the “unsafe” keyword https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/unsafe
The best way to think of C# is that it’s a less psychotic Java with a healthy dose of MS platform lock-in. Personally I like working with it, it’s great for throwing together business applications quickly, but if it’s performance or optimization that you’re after there are better tools in the shed.
MS lock in? I develop Android and ios apps at the same time with c# and xamarin.
Object oriented programming for DOS seems a little like sacrilege. Give me some asm, batch and qbasic any day. So much waste in the aftermath of the demo scene.
I’ll settle for Borland Turbo Pascal/ Turbo C and Tasm :) .
I sense a great disturbance in the force. As if millions of voices had shrieked in panic at the concept of the C# virus now infecting an even larger set of previously pure computing platforms.