WPF通过wine适配统信uos系统

环境准备

环境准备 直接安装wine7

wine安装参考

#开启 32 bit 架构支持
sudo dpkg --add-architecture i386
#下载添加仓库密钥
sudo wget -nc https://dl.winehq.org/wine-builds/winehq.key
sudo apt-key add winehq.key
#添加源
sudo chmod 777 /etc/apt/sources.list
sudo echo 'deb https://dl.winehq.org/wine-builds/debian/ buster main'>>/etc/apt/sources.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 76F1A20FF987672F
#网络环境不好尝试https://mirrors.tuna.tsinghua.edu.cn/help/wine-builds/
#sudo echo 'deb [arch=amd64,i386 signed-by=/usr/share/keyrings/winehq-archive.key] https://mirrors.tuna.tsinghua.edu.cn/wine-builds/debian/ buster main'>>/etc/apt/sources.list
#sudo wget -nc -O /usr/share/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key

#更新软件仓库
sudo apt update -y

#安装 wine稳定版,需要安装开发版的可在wine官网查找安装命令
sudo apt install --install-recommends winehq-stable -y
wine --version

#uos TCP问题
#net.ipv4.tcp_tw_recycle=1
sudo setcap 'cap_net_admin,cap_net_raw+ep' /opt/wine-stable/bin/wineserver

离线方式安装
稳定版:Wine 7.0 (shortlog)
https://dl.winehq.org/wine/source/7.0/wine-7.0.tar.xz

#安装依赖
sudo apt install flex -y
sudo apt install bison -y
sudo apt install xserver-xorg-dev -y
#解压
tar -xvJf wine-7.0.tar.xz
./configure --enable-wine64
make  #机器配置差巨慢
make install

DMSkin运行效果

准备打包的程序

Desktop Entry 文件
destop快捷方式
control介绍

#1、WINEARCH=后面写win32,即表示新建一个32位的容器,如果写win64,即表示新建一个64位的容器
#2、WINEPREFIX=是指定的容器路径
#WINEARCH=win32 WINEPREFIX=~/.wine wine 

#安装winetricks
sudo apt-get install winetricks
#安装winetricks gui
sudo apt-get install zenity
#gui方式运行winetricks
WINEARCH=win32 winetricks --gui
#中文字体乱码问题
sudo apt-get install winetricks -y
WINEARCH=win32 WINEPREFIX=~/.wine winetricks corefonts
WINEARCH=win32 WINEPREFIX=~/.wine winetricks fakechinese
WINEARCH=win32 WINEPREFIX=~/.wine winetricks wenquanyi

#将目标容器C盘(即drive_c)下面的users文件下面当前用户名(也就是你自己的用户名)文件夹改为@current_user@
cd ~/.deepinwine/you-soft/drive_c/users
mv admin @current_user@
#批量修改注册表里的当前用户名
cd ~/.deepinwine/you-soft
sed -i "s#$USER#@current_user@#" ./*.reg
#将需要打包的程序拷贝到~/.wine/drive_c/Program Files目录下
cd ~/.deepinwine/you-soft
7z a -t7z -r files.7z ~/.deepinwine/you-soft/*
#解压 7z x -t7z -y files.7z
mkdir -p ~/Downloads/package/{files,entries,build}

#依赖
#deepin-wine6-stable:amd64 (>= 6.0.0.19-1)
#deepin-wine-helper (>= 5.1.30-1)

卸载脚本

#!/bin/bash
for username in `ls /home`  
    do
      echo /home/$username
        if [ -d /home/$username/.deepinwine/you-soft ]  
        then
        rm -rf /home/$username/.deepinwine/you-soft
        fi
done

打包deb

参考

命令行打包修改arch

#提取包的內容到文件夾 extract/ 下
dpkg -X com.you.soft_1.0.0.0_amd64.deb extract/
#提取的控制信息到文件夾 extract/DEBIAN 下
dpkg -e com.you.soft_1.0.0.0_amd64.deb extract/DEBIAN   
#修改 \extract\DEBIAN\control 文件中 
#Architecture: amd64  =>  Architecture: i386
#修改 \extract\opt\apps\com.you.soft\info 文件
#"arch": ["i386"]  =>  "arch": ["amd64"]
mkdir build
dpkg-deb -b extract/ build/
ls build/

问题

异常信息缺少 System.Windows.Controls.Ribbon.dll 拷贝到程序目录即可

Unhandled Exception:
System.Windows.Markup.XamlParseException: Set property 'System.Windows.ResourceDictionary.DeferrableContent' threw an exception. ---> System.Xaml.XamlObjectWriterException: Provide value on 'MS.Internal.Markup.StaticExtension' threw an exception. ---> System.IO.FileNotFoundException: Could not load the file 'System.Windows.Controls.Ribbon'.

Native Crash Reporting

类似这样的错误

错误信息依赖的wpf皮肤库 HandyControl 报出错误,下载HandyControl4.6.1运行就是就是这里无法正常运行,后面的PE错误无法继续定位(功力不够只能考虑换皮肤)

HandyControl库具体异常位置,等有缘人来解决。

    [SecurityCritical]
    [SuppressUnmanagedCodeSecurity]
    [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
    internal static extern short RegisterClass(InteropValues.WNDCLASS4ICON wc);

Tcp请求问题

#uos TCP问题提权解决
sudo setcap 'cap_net_admin,cap_net_raw+ep' /opt/wine-stable/bin/wineserver

串口问题

更新wine-mono
wine7默认安装的wine-mono版本是7.0.0,由于7.0.0未实现 SerialPortBase.DataReceived += new SerialDataReceivedEventHandler(SerialPortDataReceived); 未实现之前的解决方法,更新wine-mono至7.2.0及以上版本即可解决。

MetaCom 串口调试工具基于WPF收发效果如下

弹窗周边黑框

设置KDE混成器渲染更改为OpenGL3.1
设置后弹窗前后对比

软件自主适配测试

安装适配工具 pmonitor_1.2-1_amd64.deb

安装包规范检测

#安装包规范检测输文件(eg:com.you.soft_2022-10-13.pdf)
/opt/apps/pmonitor/files/bin/results/包名_yyyy-MM-dd.pdf

设备环境检测

#设备环境检测输文件
/opt/apps/pmonitor/files/bin/results/device_environment.pdf

后续

目前,Mono 项目中的任何团队都没有计划将 Windows Presentation Foundation API 实现为项目的一部分。
wpf原生跨平台可通过 AvaloniaUIUno Platform这样的产品实现。
uos服务器版本对标的是centos8,可直接上docker部署服务。

参考连接:
https://ccifra.github.io/PortingWPFAppsToLinux/Overview.html

posted @ 2022-11-11 21:18  ddrsql  阅读(1822)  评论(0编辑  收藏  举报