Ubuntu – Running .Net 4.0 application with Wine

14.04monowindowswine

I'm attempting to run a simple program in Wine, under Ubuntu 14.04 LTS, however it complains that

fixme:mscoree:parse_supported_runtime sku=L".NETFramework,Version=v4.0" not implemented
fixme:mscoree:parse_probing privatePath=L"assemblies" not implemented
The entry point method could not be loaded

Trying to manually install .Net 4.0 yields an error in the installer, saying that .Net 4.0 is already installed.

Running winetricks forcemono

------------------------------------------------------
You are using a 64-bit WINEPREFIX. If you encounter problems, please retest in a
clean 32-bit WINEPREFIX before reporting a bug.
------------------------------------------------------
Executing w_do_call forcemono
Executing load_forcemono
Using native override for following DLLs: mscoree
Executing winetricks_early_wine regedit C:\windows\Temp\_forcemono\override-dll.reg
Using override for following DLLs: mscorsvw.exe
Executing winetricks_early_wine regedit C:\windows\Temp\_forcemono\override-dll.reg

Then trying to start the same application again will still fail with

err:module:import_dll Library mscoree.dll (which is needed by L"Z:\\home\\<user>\\tmp\\saveedit_r237\\Gibbed.Borderlands2.SaveEdit.exe") not found
err:module:LdrInitializeThunk Main exe initialization for L"Z:\\home\\<user>\\tmp\\saveedit_r237\\Gibbed.Borderlands2.SaveEdit.exe" failed, status c0000135

I have tried Wine 1.6 and 1.7.30 and both fail. Is .Net 4.0 actually implemented? Or partially implemented? Is there a way to make this .Net 4.0 app work?

Update

Winetricks complains that dotnet40 cannot be installed on a 64-bit system. So, how do I install it?

Best Answer

First things first, note this very noticeable warning:

------------------------------------------------------
You are using a 64-bit WINEPREFIX. If you encounter problems, please retest in a
clean 32-bit WINEPREFIX before reporting a bug.
------------------------------------------------------

This indicates you need to create a 32bit Wineprefix, as Wine works better with 32bit stuff - this can be done simply by running telling wine what architecture to use before running its commands (this can I think can also be done by uninstalling Wine x86_64 and installing Wine i386/i686 - anyway, keep the terminal open for the other wine commands after running this):

export WINEARCH="win32"

This sets the environment variables wine reads before it launches (see man wine).

It would also be a good idea to get it to create it's own WINEPREFIX (where the Wine virtual drive is stored). By default this is ~/.wine, but you can create individual ones for each architecture & program - so to create a WINEPREFIX in directory /home/USERNAME/.wine-PROGRAM-NAME/:

export WINEPREFIX=~/.wine-PROGRAM-NAME/

The directory doesn't have to exist (ideally it shouldn't exist so stuff doesn't have to be overwritten), but the parent directories probably should - you should also have permission to read & write to it, and I don't think the wineprefix can be on a FAT/NTFS drive for technical reasons (it won't work).

So to setup a 32bit wine prefix for a program:

export WINEARCH="win32"
export WINEPREFIX=~/.wine-PROGRAM-NAME/
wineboot -u

You can replace PROGRAM-NAME with the name of the program to make it easier to identify the program later. Just make sure it only includes the letter and numbers as punctuation often has a special function in various command shells.

You should then get a window like this:

the wineprefix is being updated....

Then you are ready to go. Now you can install NET 4.0 using winetricks (you might want to get the latest version from here first):

winetricks dotnet40

This should be in the terminal after the export WINEPREFIX=... command, or by placing it just before the wine command as so (useful for app launchers that one command line):

env WINEPREFIX=~/.wine-PROGRAM-NAME/" winetricks dotnet40

You may also want to use winetricks to install some other stuff it might need - e.g. fonts (using the options corefonts,lucida,tahoma). To list winetricks' options, use winetricks list-all.

You can then install the program using wine "~/Downloads/PATH/TO/INSTALLER.exe". Yet again (copy the file, then 'Paste Filenames' into terminal, so it looks like '/home/wilf/Desktop/name spaces/installer.exe' not file:///home/wilf/Desktop/name spaces/installer.exe').

You should make sure the WINEPREFIX has been exported before running this command (especially if you closed the terminal), or in the same line. After getting it to work (or not work) you might want to do a report on how well it works here (including what you did etc so you can help other people). If you have issues, and noticeable errors appear in the output you can report a bug.

Once installed, it should make the launcher of the app appear on the Dash/Menu and sometimes on the Desktop. Otherwise in future to run the app you may need to run the app with the export WINEPREFIX=... and wine .... (or env WINEPREFIX=... wine .....) again, unless you create a launcher (comment below or somewhere if you need to know how to do so....)


More info, troubleshooting etc

How do I install winetricks?

You can a version from the Ubuntu repositories using this command (or installing Winetricks from the Software Center):

sudo apt-get install winetricks

You can then use winetricks OPTIONS to do stuff.

For the latest version, you can use these commands to download and use the latest version:

wget  https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
chmod +x winetricks 

Note you will have to run it as ./winetricks <OPTIONS>, unless it's directory is in the shell's $PATH.

I don't want to use terminal, what can I do?

The app you want to use may be runnable under PlayOnLinux (it should be if you can find it here) - this is pretty much all GUI and automatically does most of the steps for you.

Otherwise, you can use the terminal to do it very easily (you usually have much more control than if a GUI program is doing it), just be careful what you put in (especially if it includes the commands sudo, rm, etc). Try to understand what is going on with each command first.

Also, some of these steps can be done in other ways - both winecfg and winetricks open GUIs through which you can do some steps, but again what you can do is limited.

How do I install the latest Wine version?

The newer wine versions are more up to date, so may be able to run the program better (unless there is a regression which impacts it). To install the current latest version (Wine1.7) you can use the offical Wine PPA:

sudo apt-add-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.7

If it can't find the package wine1.7, try running the install command again but with wine instead of wine1.7

For installing and configuring Wine generally, you can also try this question.

The program I want to use is designed for a newer version of Windows, what can I do?

Wine by default replicates Windows XP, which some programs don't support as it is EOL (which I supposes in handy as you probably can run programs for WinXP under Wine under Linux, and you can 'nuke WinXP from orbit' :)

Anyway, first open up the Wine configuration window:

export WINEPREFIX=~/.wine-PROGRAM-NAME/
winecfg

Where ~/.wine-PROGRAM-NAME/ is the WINEPREFIX you created earlier.

And select the Windows version to replicate at the bottom of the 'Applications' tab. Then try installing the app again.

WINDOWS VIRUSES UNDER WINE?!?!

Quite possibly. Don't install random software of the internet, try to ensure it is from a trusted site.