It seems that you're using an outdated browser. Some things may not work as they should (or don't work at all).
We suggest you upgrade newer and better browser like: Chrome, Firefox, Internet Explorer or Opera

×
Suppose I have a .NET program .EXE that I want to give to someone to run on a different computer, but that computer happens to be a Macintosh of some sort (I don't know the specific details). How could I do this?

I don't personally have a Macintosh so I'm not particularly knowledgeable about compatibility issues concerning Macintosh computers, and I have no way of testing it at all, but I'd just have to hope that it works.

Is there some reliable .NET interpreter or otherwise emulator that I could include with the program and just say, "Install this first"? The person who will receive this program .EXE file isn't a programmer, and isn't super-knowledgeable about technology, so it would be best it it's just a simple installer file to run and then some easy way to run the program after that.

I've looked around a bit, and supposedly it might be possible to run the regular .NET stuff if you just happen to have the interpreter for MacOS, but how compatible is it? I think the program .EXE file might be from something like Visual Studio 2012 or 2013 or something.

There's also something called Wine, but I don't know how easy that is to install and use, and I don't think that it's specifically for .NET programs, but just regular programs (though I suppose it might be able to run a .NET interpreter, which could then run the .NET program, right?).

There's another thing called PlayOnMac, which may be more simplified than Wine, but I'm not sure how compatible it is, especially with .NET.

Are any of these good options or is there a better one? Really, simplicity and compatibility are the main concerns.

Thanks a bunch in advance!
No posts in this topic were marked as the solution yet. If you can help, add your reply
the "traditional" .NET framework is only compatible with windows. I use the term "traditional" because microsoft have stolen the terms "standard" and "core" for their new versions. If you're referring to an application built using a version such as .net 4.7 then it cannot run default on a mac. If it's got a comparable version in .NET core, then that should be cross platform.

In terms of emulators and containers, I'll admit to little knowledge of that. My understanding is that you need a windows OS, and that you'd need to go for a complete windows OS in a VM in order to run it, I might be wrong about this, maybe Wine or similar has managed it.
avatar
HeresMyAccount: Are any of these good options or is there a better one? Really, simplicity and compatibility are the main concerns.
Well, there's Mono I believe, and there’s the info from MS themselves that it should work on mac from 2016, but I personally don't have/use a mac so I can't confirm that.
https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/intro#macos
https://code.visualstudio.com/docs/languages/dotnet

But, if you're really concerned with compatibility across OS's; don't use .NET at all XD

Use f.ex C/C++, Python (or even Java if you must) instead.
Post edited July 27, 2019 by sanscript
This is an already existing program; I can't just not use .NET at all. It is what it is. And yes I know about Mono (didn't I mention that one?) but from briefly glancing at the documentation, I may be wrong but it seems like it might be rather complicated to get to work, especially for the person who will be using it, who as I mentioned, isn't extremely great with computers (just average in that respect).

Or is Mono easy enough to install and run that anyone could do it?
avatar
HeresMyAccount: This is an already existing program; I can't just not use .NET at all. It is what it is. And yes I know about Mono (didn't I mention that one?) but from briefly glancing at the documentation, I may be wrong but it seems like it might be rather complicated to get to work, especially for the person who will be using it, who as I mentioned, isn't extremely great with computers (just average in that respect).

Or is Mono easy enough to install and run that anyone could do it?
You can't run a .NET application on Mono, the developer needs to actually compile it for Mono. I'm afraid it sounds like the answer to your question is that it's not possible.
Many seem to not know that here doesn't exist any emulator for Windows (at least not yet), and Wine is not an emulator, it is purely a POSIX translator on-the-fly.

If you have the source material then you need to either re-write and/or compile like wpegg mentioned. (Besides, there’s also the issue about the use of external libraries which can make it difficult in wine.)

And if Wine doesn't work - your only option is also the most popular one - using a VM.
avatar
HeresMyAccount: Suppose I have a .NET program .EXE that I want to give to someone to run on a different computer, but that computer happens to be a Macintosh of some sort (I don't know the specific details). How could I do this?

I don't personally have a Macintosh so I'm not particularly knowledgeable about compatibility issues concerning Macintosh computers, and I have no way of testing it at all, but I'd just have to hope that it works.

Is there some reliable .NET interpreter or otherwise emulator that I could include with the program and just say, "Install this first"? The person who will receive this program .EXE file isn't a programmer, and isn't super-knowledgeable about technology, so it would be best it it's just a simple installer file to run and then some easy way to run the program after that.

I've looked around a bit, and supposedly it might be possible to run the regular .NET stuff if you just happen to have the interpreter for MacOS, but how compatible is it? I think the program .EXE file might be from something like Visual Studio 2012 or 2013 or something.

There's also something called Wine, but I don't know how easy that is to install and use, and I don't think that it's specifically for .NET programs, but just regular programs (though I suppose it might be able to run a .NET interpreter, which could then run the .NET program, right?).

There's another thing called PlayOnMac, which may be more simplified than Wine, but I'm not sure how compatible it is, especially with .NET.

Are any of these good options or is there a better one? Really, simplicity and compatibility are the main concerns.

Thanks a bunch in advance!
“Suppose I have a .net program”, this is a bit vague. .net core is available for Mac. .net is generally for windows systems. If you ant to run software built for one system on another then there will be hurdles, that is a fact of life. If your friend uses macOS then you have a couple of choices, you create a process which can compile to usable destinations (assumes you are the dev), or you rely on intermediary layers like wine. It’s a bit like asking if this play station disk will work in an Xbox.
If you're insane, you could look into the Dark Arts of mono, but even I know not what mysteries belie that.
avatar
wpegg: You can't run a .NET application on Mono, the developer needs to actually compile it for Mono. I'm afraid it sounds like the answer to your question is that it's not possible.
Well in that case, where can I get a Mono compiler that runs on Windows but compiles programs to run on Macintosh?
avatar
sanscript: If you have the source material then you need to either re-write and/or compile like wpegg mentioned. (Besides, there’s also the issue about the use of external libraries which can make it difficult in wine.)
Well this particular program uses no external libraries at all... I think. I mean, I use some imports for basic functions and stuff, but doesn't everyone? I know that I didn't put any DLLs into it or anything like that, and the .EXE has been placed on a thumb drive by itself and run on a different computer, so it shouldn't need any extra stuff, right?
avatar
sanscript: And if Wine doesn't work - your only option is also the most popular one - using a VM.
I know what a VM is, but if I understand what you're implying, do you mean to connect to a Windows PC online on some other computer and have it just display everything that you do on that computer, so that you can do the things on it that you can't do on your own because you're using a Macintosh? Well the problem is that in this case, it would create some HUGE security problems, so if that's what you mean then it's not an option. Or did you mean something else and I'm misinterpreting you?
avatar
nightcraw1er.488: “Suppose I have a .net program”, this is a bit vague. .net core is available for Mac. .net is generally for windows systems. If you ant to run software built for one system on another then there will be hurdles, that is a fact of life. If your friend uses macOS then you have a couple of choices, you create a process which can compile to usable destinations (assumes you are the dev), or you rely on intermediary layers like wine. It’s a bit like asking if this play station disk will work in an Xbox.
You're right, I suppose I should have been more specific. What I meant to say was: suppose I have a .NET program which was written and compiled in Windows to run on a Windows PC, but I want to run it on a Macintosh, either with emulation or just a different interpreter or whatever.



Well here's the thing that I don't quite understand, and bear with me because I've never really bothered to get into all of the technical details of the .NET framework (I never had the need), but as I understand it, since .NET is not compiled to machine language, but rather to a sort of byte code, and then interpreted after that, shouldn't it be somewhat universally compatible, the way that Java is? I mean correct me if I'm wrong, but doesn't it just need to have a version of the interpreter that will run on whichever computer is being used?



EDIT:
avatar
Darvond: If you're insane, you could look into the Dark Arts of mono, but even I know not what mysteries belie that.
Yes, I'm quite insane, but of what specific Dark Arts do you speak? Remember, the person who will be using this program does NOT have very much technical knowledge about computers and is essentially a layman, so I can get into technical details as long as it's something that I can do, and not have to rely on that person to do.



And if for any reason none of that works, I have one more potential idea: is it possible for me to somehow emulate a Macintosh and compile/run programs on my own computer? In a way, I'd prefer to avoid doing this and go with one of the other methods instead, only because this seems like it would be a hassle, and I really can't go reformatting my hard drive or anything like that (though I might be able to install an OS onto a thumb drive or something - is that even possible?), but the one advantage would be that at least this way I could test it.
Post edited July 28, 2019 by HeresMyAccount
avatar
HeresMyAccount: Well in that case, where can I get a Mono compiler that runs on Windows but compiles programs to run on Macintosh?
You can easily compile mono on windows, but you'll need one of their IDEs: such as here: https://www.mono-project.com/docs/getting-started/development-environments/

It should all be free, and if you've written pretty basic code it should just be a matter of re-compiling it with the new references. It's been a while since I played with Mono, so I may be wrong.

However... If you're going to recompile your app, .NET core would be a more sensible target. Mono is fading because .NET core is looking to replace it. It's worth a try just to fire up Visual Studio and see if you can build your app in it, it would have the advantage that while with Mono the end user would need to install the Mono runtime, for .NET core I think it can just run through xcopy deployment (i.e. the totally standalone setup you want).
avatar
HeresMyAccount: Well here's the thing that I don't quite understand, and bear with me because I've never really bothered to get into all of the technical details of the .NET framework (I never had the need), but as I understand it, since .NET is not compiled to machine language, but rather to a sort of byte code, and then interpreted after that, shouldn't it be somewhat universally compatible, the way that Java is? I mean correct me if I'm wrong, but doesn't it just need to have a version of the interpreter that will run on whichever computer is being used?
The original .NET framework was written for windows, and the assumption was that a large number of core libraries would not be copied with your application. This is the main reason why it's not cross platform, and .NET core is. When you "install" the .NET framework on windows, it registers a large number of libraries that can be accessed (you may not think you're using them, but you almost certainly are). This means that while your application is just "your code", it is therefore bound to the windows mechanism for resolving all the other dependencies. This is why you can't just shell the interpretter, it's bound to the OS very heavily, both in terms of its use of the libraries, and its interpretation of them.

I think, with the new information you've provided, .NET core is your best point of investigation.
Post edited July 28, 2019 by wpegg
avatar
wpegg: You can easily compile mono on windows, but you'll need one of their IDEs: such as here: https://www.mono-project.com/docs/getting-started/development-environments/
Thanks for the link; I'll check it out.

avatar
wpegg: It should all be free, and if you've written pretty basic code it should just be a matter of re-compiling it with the new references. It's been a while since I played with Mono, so I may be wrong.

However... If you're going to recompile your app, .NET core would be a more sensible target. Mono is fading because .NET core is looking to replace it. It's worth a try just to fire up Visual Studio and see if you can build your app in it, it would have the advantage that while with Mono the end user would need to install the Mono runtime, for .NET core I think it can just run through xcopy deployment (i.e. the totally standalone setup you want).
OK then maybe I'll use .NET Core instead. Thanks for the advice. Though I don't necessarily mind the requirement to install something as long as it would be easy for anyone to do it (I could just provide a copy of the installer). Xcopy sounds vaguely familiar but I'm not sure what it is, and frankly the way you talk about .NET Core makes it seem like its own thing, but I had thought it just meant "the core of the .NET package... or framework... or whatever". I'm sorry if any of this sounds stupid or naive. I've actually been programming and using .NET for many years, but I rarely ever have to look at this side of things, because most of what I tend to do just involves writing code, code, code.

avatar
wpegg: The original .NET framework was written for windows, and the assumption was that a large number of core libraries would not be copied with your application. This is the main reason why it's not cross platform, and .NET core is. When you "install" the .NET framework on windows, it registers a large number of libraries that can be accessed (you may not think you're using them, but you almost certainly are). This means that while your application is just "your code", it is therefore bound to the windows mechanism for resolving all the other dependencies. This is why you can't just shell the interpretter, it's bound to the OS very heavily, both in terms of its use of the libraries, and its interpretation of them.
Damn it.

avatar
wpegg: I think, with the new information you've provided, .NET core is your best point of investigation.
That's what I'll try, but I just hope that the version that runs on Windows can compile for Macintosh, and it's still not ideal that I have no way of testing it, but there's nothing I can do about that. I know that the program runs on windows, so theoretically if the compilation for Macintosh is compatible then it should work on that too.

I'm not sure when I'll be able to get around to doing this because I have to do some research about this stuff first, which I'll do when I get time (none of this is urgent to do right now but I wanted to have the information ahead of time so that I could read it whenever, and make sure that I know what I need to when I need to know it), but I'll keep all of this stuff in mind.

Thanks a lot, and I consider your solution to be probably the most thorough one so far. I'll probably mark it as such, but not quite yet, because I'm still open to hearing anyone else's opinion, and getting as much information as I can, and I'm afraid that if I mark it as solved then people will stop bothering to read and reply to it.
UPDATE: I just checked Wikipedia to see what the hell this .NET Core thing is, and here's what I think, but please correct me if I'm wrong, because I want to be sure:

Older versions of Visual Studio use the .NET Framework, and newer versions automatically include and use the .NET Core instead. The only difference is that when you compile using a newer version of Visual Studio, the .EXE file is automatically made compatible with operating systems other than Windows, as long as they have the .NET interpreter compatible with that version installed.

Is that correct, or have I made an error, or overlooked anything important? Does this also imply that the .NET Core includes everything in the .EXE or in some folder to go with it, so that distribution is easier and more compatible? Or does it mean that each version of the interpreter has been made to have compatible library files for each operating system, so that it will just use whichever files it needs based on whatever's installed on that computer?

If I'm way off with any of this please say so, and in what way - and in that case I'm not sure exactly what to do about compatibility. But I hope that I'm right about this!


EDIT: I just downloaded Visual Studio 2019 Community version from https://visualstudio.microsoft.com/downloads/ and the installer is only 1.28 MB! That can't be right, is it? I tried to install it to test it on this computer, but it says it's not a compatible version of Windows (it's Vista). That's alright, because I plan to put it on the other computer anyway (which has Windows 7, but the error message said that it would require Service Pack 1 for Windows 7, which I'm not sure that I have, but I suppose I could get that).

But the real problem is that since the .EXE is so small, I suspect that it might try to download the stuff that it needs to install, which would NOT work on the other computer because it must remain air-gapped! Please tell me that it doesn't try to download while installing? Or if it does, then where can I get an earlier version of Visual Studio which contains .NET Core but does not require downloading while installing? Supposedly .NET Core is available as early as Visual Studio 2015 (I think the one that I have installed currently is Visual Studio 2012 or 2013).

But then after I typed that, I also found the .NET SDK for Visual Studio 2017 and 2019, and the files are more like 100+ MB. Is that what I need? Frankly, it's been a few years since I had to install any of this sort of stuff, so I'm a bit rusty, and I just want to make sure that I have the right stuff. I may want to go with Visual Studio 2015 if I can find it, but I didn't see an SDK for that.
Post edited July 28, 2019 by HeresMyAccount
avatar
HeresMyAccount: UPDATE: I just checked Wikipedia to see what the hell this .NET Core thing is, and here's what I think, but please correct me if I'm wrong, because I want to be sure:

Older versions of Visual Studio use the .NET Framework, and newer versions automatically include and use the .NET Core instead. The only difference is that when you compile using a newer version of Visual Studio, the .EXE file is automatically made compatible with operating systems other than Windows, as long as they have the .NET interpreter compatible with that version installed.

Is that correct, or have I made an error, or overlooked anything important? Does this also imply that the .NET Core includes everything in the .EXE or in some folder to go with it, so that distribution is easier and more compatible? Or does it mean that each version of the interpreter has been made to have compatible library files for each operating system, so that it will just use whichever files it needs based on whatever's installed on that computer?

If I'm way off with any of this please say so, and in what way - and in that case I'm not sure exactly what to do about compatibility. But I hope that I'm right about this!

EDIT: I just downloaded Visual Studio 2019 Community version from https://visualstudio.microsoft.com/downloads/ and the installer is only 1.28 MB! That can't be right, is it? I tried to install it to test it on this computer, but it says it's not a compatible version of Windows (it's Vista). That's alright, because I plan to put it on the other computer anyway (which has Windows 7, but the error message said that it would require Service Pack 1 for Windows 7, which I'm not sure that I have, but I suppose I could get that).

But the real problem is that since the .EXE is so small, I suspect that it might try to download the stuff that it needs to install, which would NOT work on the other computer because it must remain air-gapped! Please tell me that it doesn't try to download while installing? Or if it does, then where can I get an earlier version of Visual Studio which contains .NET Core but does not require downloading while installing? Supposedly .NET Core is available as early as Visual Studio 2015 (I think the one that I have installed currently is Visual Studio 2012 or 2013).

But then after I typed that, I also found the .NET SDK for Visual Studio 2017 and 2019, and the files are more like 100+ MB. Is that what I need? Frankly, it's been a few years since I had to install any of this sort of stuff, so I'm a bit rusty, and I just want to make sure that I have the right stuff. I may want to go with Visual Studio 2015 if I can find it, but I didn't see an SDK for that.
Yes, the vs2019 is a stub from which you can install many components. .net code sounds like the best option for you. .net cli is not on Mac so you need some sort of layer for that to work. What code is it you want to move across, for more important projects perhaps a good idea to build a pipeline for it. Perhaps a web process or javascript version?
Vs2019 is all you need and would not recommend earlier versions.
avatar
HeresMyAccount: UPDATE: I just checked Wikipedia to see what the hell this .NET Core thing is, and here's what I think, but please correct me if I'm wrong, because I want to be sure:

Older versions of Visual Studio use the .NET Framework, and newer versions automatically include and use the .NET Core instead. The only difference is that when you compile using a newer version of Visual Studio, the .EXE file is automatically made compatible with operating systems other than Windows, as long as they have the .NET interpreter compatible with that version installed.

Is that correct, or have I made an error, or overlooked anything important? Does this also imply that the .NET Core includes everything in the .EXE or in some folder to go with it, so that distribution is easier and more compatible? Or does it mean that each version of the interpreter has been made to have compatible library files for each operating system, so that it will just use whichever files it needs based on whatever's installed on that computer?

If I'm way off with any of this please say so, and in what way - and in that case I'm not sure exactly what to do about compatibility. But I hope that I'm right about this!
With the caveat that I've never actually tried it on a mac, I think you're basically correct. You just need to download vs2019 (as nightcrawler said, it's just a stub and depending on the features you install, it will in fact download several GB), then make sure you select the .NET core runtime (vs2019 can build 3 different types of .NET, so make sure you select Core, I'm not certain that is the default). All dependencies are copied to your bin directly (they aren't bundled into the exe, but you'll have it all in one folder), then you can xcopy deploy your application, or if you want you can even publish your application so that it has a basic installer (depending on project type).

It's not identical to .NET, the libraries are different, and the apis can have different interfaces, but it's pretty mature now, so should be good enough for your purposes (depending on what they are, you haven't, to my knowledge, told us what kind of project you're compiling, I think WPF might need the full fat framework still).

I also think there might be a few more hoops to jump through, this article may give some insight: https://www.michaelcrump.net/part3-aspnetcore/

I still think it's your best bet though.
avatar
wpegg: You can't run a .NET application on Mono, the developer needs to actually compile it for Mono. I'm afraid it sounds like the answer to your question is that it's not possible.
Not a professional, but I run a small .net application (http://www.divip.de/tvm_page.html) to program my tv-shows on a mac via mono without any problem. Also the mac version of Fiddler (https://www.telerik.com/download/fiddler) is the .net application running with mono. Maybe there are some problems and developers need to adjust their .net applications to run better on linux and macOS with mono, but for smaller and simpler applications (at least for .net Framework 2.0) it seems possible witout any changes.

About the configuration itself, as I said I'm not a tech professional but would call me at some point an experienced user that also uses the terminal from time to time. It took me some time to get my application running mostly I needed to force mono to run in 32bit. There is a special command for it and it took me some time to figure that out. As example for my tv-program above i wrote following little script (replaced my username with XXX):

#!/bin/bash
/Library/Frameworks/Mono.framework/Versions/Current/bin/mono-sgen32 "/Users/XXX/bin/tvm2otr-mac/tvm2otr.exe" "$@"

So theoretically if your friend could figure out how to start the .net program he could also write a script. Unfortunately with the upcoming macOS update Catalina in fall the 32bit support will be removed, including for mono (you get at the moment a warning when running 32bit apps, including mono). This should maybe also be kept in mind.

Edit: Btw, I installed mono via Homebrew (https://brew.sh), a package manager for mac.


Edit2: Did a quicksearch about that topic and found following in an kind of FAQ on Stackoverflow (https://stackoverflow.com/questions/37738106/net-core-vs-mono#39740592
):

Question: "I found a statement on the official site that said, "Code written for it is also portable across application stacks, such as Mono"."
Answer: "As long as that code doesn't rely on WinAPI-calls, Windows-dll-pinvokes, COM-Components, a case-insensitive file system and doesn't have directory separator issues, that's correct. However, .NET Core code runs on .NET core, and not on mono. So mixing the two will be difficult. And since mono is quite unstable and slow, I wouldn't recommend it anyway. Try image-processing on .NET core, e.g. WebP or moving GIF or multipage-tiff or writing text on an image, you'll be nastily surprised."

Again, not a professional, but from my understanding it means easier .net programs can run with mono. If more .net special stuff is involved it needs adjustments.
Post edited July 29, 2019 by DukeNukemForever