Arm64&Ubuntu 22.04环境运行.net 6.0 Winform程序
0、mono
framework 4.8 之前的form程序可以直接使用mono运行,但之后版本的.net程序就提示找不到库。
/usr/lib/mono$ ls
2.0-api 4.0 4.5 4.5.2-api 4.6.1-api 4.6-api 4.7.2-api 4.8-api gac mono-configuration-crypto xbuild
3.5-api 4.0-api 4.5.1-api 4.5-api 4.6.2-api 4.7.1-api 4.7-api aot-cache lldb monodoc xbuild-frameworks
只有4.6、4.8等等
1、编译安装wine-10.15
下载llvm-mingw
下载llvm-mingw-20250910-ucrt-ubuntu-22.04-aarch64.tar.xz, 解压到本地,并把bin目录添加到PATH
https://github.com/mstorsjo/llvm-mingw/releases/
export PATH=/opt/llvm-mingw-20250910-ucrt-ubuntu-22.04-aarch64/bin:$PATH
编译wine-10.15
wget https://dl.winehq.org/wine/source/10.x/wine-10.15.tar.xz
配置:
mkdir build && cd build
…/configure --enable-win64 --with-mingw --with-x
make
sudo make install
安装好的wine,可以运行arm版本的window执行程序(如notepad.exe)
aaa#file /usr/local/lib/wine/aarch64-windows/notepad.exe
/usr/local/lib/wine/aarch64-windows/notepad.exe: PE32+ executable (GUI) Aarch64, for MS Windows
aaa#wine /usr/local/lib/wine/aarch64-windows/notepad.exe
2、.net程序打包
dotnet publish -c Release -r win-arm64 --self-contained true
win-arm64:打包为windows的arm64版本;
self-contained:程序目录里面会包含很多的dll文件,这样wine主机上就不用安装.net的运行库
3、拷贝字体
把C:\Windows\Fonts下的文件都拷贝到linux上,然后创建链接
ln -s /home/test/ws/wine/fonts ~/.wine/drive_c/windows/Fonts
4、运行程序
wine myApp.exe
界面就出来了;界面有些卡,字体比较丑。
.net程序可能有些代码在wine上运行会异常(比如调用了某些加密库,数据库,直接调用dll等等),需要修改自己的代码

被折叠的 条评论
为什么被折叠?



