开发者论坛

 找回密码
 注册 (请使用非IE浏览器)
查看: 3828|回复: 2

求助 Linux 下使用Wine 运行 Winform 成功,但带上Dev就不行?

[复制链接]

0

精华

0

贡献

25

赞扬

帖子
9
软币
165
在线时间
12 小时
注册时间
2015-8-26
发表于 2023-2-13 20:11:59 | 显示全部楼层 |阅读模式
本帖最后由 wukongabc_123 于 2023-2-14 08:38 编辑

国产操作系统:银河麒麟。
自带一个CrossOver  :这玩意似乎就是基于Wine的一个商用版本
在Windows 下,创建一个Winform 项目,就是拖放几个控件。
生成 exe 后,将相关的 dll exe config 等文件,全部拷贝到 Linux的特定目录
此时,可以运行,弹出页面,可以进行正常操作。


以上是使用的微软原生的控件,例如 Button DataGrid 等。
但是,一旦拖放了 DevExpress 之后,则立即不行了。
初始化时就报错了。——当然在Windows 下测试打开运行,完全成功之后,才移动过去的。


把异常使用try catch 包了之后,打印出来,大概是下面这段:

System.Exception: Error occurs ---> System.TypeInitializationException: The type initializer for 'DevExpress.Utils.Text.FontGuard' threw an exception. ---> DevExpress.Utils.Helpers.NativeField+NativeFieldFallbackError: There is no get-method found for the Font.NativeFont property! Please check the actual sources.
  at DevExpress.Utils.Helpers.NativeField`1[T].EmitAccessor (System.Reflection.FieldInfo f_nativeField, System.Reflection.Emit.DynamicMethod accessor, System.String fallbackProperty) [0x00082] in <7e3a0e08bccd4c25baf24ed0c8b99fb6>:0
  at DevExpress.Utils.Text.FontGuard.EmitNativeFontAccessor () [0x0004b] in <7e3a0e08bccd4c25baf24ed0c8b99fb6>:0
  at DevExpress.Utils.Text.FontGuard..cctor () [0x00000] in <7e3a0e08bccd4c25baf24ed0c8b99fb6>:0
   --- End of inner exception stack trace ---
  at DevExpress.Utils.Text.FontCache..ctor (System.Drawing.Graphics graphics, System.Drawing.Font font) [0x00013] in <7e3a0e08bccd4c25baf24ed0c8b99fb6>:0
  at DevExpress.Utils.Text.ConstDpiFontsCache.AddFontCache (System.Drawing.Graphics graphics, System.Drawing.Font font) [0x00000] in <7e3a0e08bccd4c25baf24ed0c8b99fb6>:0
  at DevExpress.Utils.Text.ConstDpiFontsCache.GetFontCacheByFont (System.Drawing.Graphics graphics, System.Drawing.Font font) [0x00012] in <7e3a0e08bccd4c25baf24ed0c8b99fb6>:0
  at DevExpress.Utils.Text.ConstDpiFontsCache.get_Item (System.Drawing.Graphics graphics, System.Drawing.Font font) [0x00000] in <7e3a0e08bccd4c25baf24ed0c8b99fb6>:0
  at DevExpress.Utils.Text.FontsCache.GetFontCacheByFont (System.Drawing.Graphics graphics, System.Drawing.Font font) [0x0002d] in <7e3a0e08bccd4c25baf24ed0c8b99fb6>:0
  at DevExpress.Utils.Text.FontsCache.get_Item (System.Drawing.Graphics graphics, System.Drawing.Font font) [0x00000] in <7e3a0e08bccd4c25baf24ed0c8b99fb6>:0
  at DevExpress.Utils.Text.FontsCache.GetStringSize (System.Drawing.Graphics graphics, System.String text, System.Drawing.Font font, System.Drawing.StringFormat stringFormat, System.Int32 maxWidth, System.Int32 maxHeight, DevExpress.Utils.Text.IWordBreakProvider wordBreakProvider, System.Boolean& isCropped) [0x00000] in <7e3a0e08bccd4c25baf24ed0c8b99fb6>:0
  at DevExpress.Utils.Text.TextUtils.GetStringSize (System.Drawing.Graphics g, System.String text, System.Drawing.Font font, System.Drawing.StringFormat stringFormat, System.Int32 maxWidth, System.Int32 maxHeight, DevExpress.Utils.Text.IWordBreakProvider wordBreakProvider, System.Boolean& isCropped) [0x00012] in <7e3a0e08bccd4c25baf24ed0c8b99fb6>:0
  at DevExpress.Utils.Text.TextUtils.GetStringSize (System.Drawing.Graphics g, System.String text, System.Drawing.Font font, System.Drawing.StringFormat stringFormat, System.Int32 maxWidth, System.Int32 maxHeight, System.Boolean& isCropped) [0x00000] in <7e3a0e08bccd4c25baf24ed0c8b99fb6>:0
  at DevExpress.Utils.Paint.XPaintMixed.CalcTextSize (System.Drawing.Graphics g, System.String s, System.Drawing.Font font, System.Drawing.StringFormat strFormat, System.Int32 maxWidth, System.Int32 maxHeight, System.Boolean& isCropped) [0x00026] in <a8c98f2242764251bbc83a0d5f6453ef>:0
  at DevExpress.Utils.Paint.XPaintMixed.CalcTextSize (System.Drawing.Graphics g, System.String s, System.Drawing.Font font, System.Drawing.StringFormat strFormat, System.Int32 maxWidth) [0x00000] in <a8c98f2242764251bbc83a0d5f6453ef>:0
  at DevExpress.Utils.AppearanceObject.CalcTextSize (DevExpress.Utils.Drawing.GraphicsCache cache, System.Drawing.StringFormat sf, System.String s, System.Int32 width) [0x0001a] in <a8c98f2242764251bbc83a0d5f6453ef>:0
  at DevExpress.Utils.Drawing.HeaderObjectPainter.CalcCaptionTextSize (DevExpress.Utils.Drawing.GraphicsCache cache, DevExpress.Utils.Drawing.HeaderObjectInfoArgs ee, System.String caption) [0x000ee] in <a8c98f2242764251bbc83a0d5f6453ef>:0
  at DevExpress.Utils.Drawing.HeaderObjectPainter.CalcObjectMinBounds (DevExpress.Utils.Drawing.ObjectInfoArgs e) [0x00023] in <a8c98f2242764251bbc83a0d5f6453ef>:0
  at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcMinColumnRowHeight (System.Int32 headerHeight) [0x000cb] in <e8493ff178184ee3aee9a8dc3263b2a0>:0
  at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRectsConstants () [0x00024] in <e8493ff178184ee3aee9a8dc3263b2a0>:0
  at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcRects (System.Drawing.Rectangle bounds, System.Boolean partital) [0x0006e] in <e8493ff178184ee3aee9a8dc3263b2a0>:0

at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.CalcCore (System.Drawing.Graphics g, System.Drawing.Rectangle bounds) [0x00097] in <e8493ff178184ee3aee9a8dc3263b2a0>:0
  at DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo.Calc (System.Drawing.Graphics g, System.Drawing.Rectangle bounds) [0x00025] in <e8493ff178184ee3aee9a8dc3263b2a0>:0
  at DevExpress.XtraGrid.Views.Base.ColumnView.DoInternalLayout () [0x0000d] in <e8493ff178184ee3aee9a8dc3263b2a0>:0
  at DevExpress.XtraGrid.Views.Grid.GridView.DoInternalLayout () [0x00000] in <e8493ff178184ee3aee9a8dc3263b2a0>:0
  at DevExpress.XtraGrid.Views.Base.ColumnView.CalculateLayout () [0x00084] in <e8493ff178184ee3aee9a8dc3263b2a0>:0
  at DevExpress.XtraGrid.Views.Grid.GridView.LayoutChanged () [0x00000] in <e8493ff178184ee3aee9a8dc3263b2a0>:0
  at DevExpress.XtraGrid.Views.Base.BaseView.EndUpdateCore (System.Boolean synchronized) [0x00024] in <e8493ff178184ee3aee9a8dc3263b2a0>:0
  at DevExpress.XtraGrid.GridControl.EndUpdate (System.Boolean synchronized) [0x0002f] in <e8493ff178184ee3aee9a8dc3263b2a0>:0
   --- End of inner exception stack trace ---
  at DevExpress.XtraGrid.GridControl.EndUpdate (System.Boolean synchronized) [0x0006b] in <e8493ff178184ee3aee9a8dc3263b2a0>:0
  at DevExpress.XtraGrid.GridControl.EndUpdate () [0x00000] in <e8493ff178184ee3aee9a8dc3263b2a0>:0
  at DevExpress.XtraGrid.GridControl.OnLoaded () [0x00087] in <e8493ff178184ee3aee9a8dc3263b2a0>:0
  at DevExpress.XtraEditors.Container.EditorContainer.OnVisibleChanged (System.EventArgs e) [0x0002f] in <8a4fc9ca11d84fb7b54aa1864593db72>:0
  at DevExpress.XtraGrid.GridControl.OnVisibleChanged (System.EventArgs e) [0x00000] in <e8493ff178184ee3aee9a8dc3263b2a0>:0
  at System.Windows.Forms.Control.OnParentVisibleChanged (System.EventArgs e) [0x0000d] in <2736a4f873604bfea9e5f3a0d64b37d6>:0
  at System.Windows.Forms.Control.OnVisibleChanged (System.EventArgs e) [0x000c4] in <2736a4f873604bfea9e5f3a0d64b37d6>:0
  at System.Windows.Forms.ScrollableControl.OnVisibleChanged (System.EventArgs e) [0x0001a] in <2736a4f873604bfea9e5f3a0d64b37d6>:0
  at System.Windows.Forms.Form.OnVisibleChanged (System.EventArgs e) [0x00020] in <2736a4f873604bfea9e5f3a0d64b37d6>:0
  at System.Windows.Forms.Control.WmShowWindow (System.Windows.Forms.Message& m) [0x000d4] in <2736a4f873604bfea9e5f3a0d64b37d6>:0
  at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m) [0x0071b] in <2736a4f873604bfea9e5f3a0d64b37d6>:0
  at System.Windows.Forms.ScrollableControl.WndProc (System.Windows.Forms.Message& m) [0x00043] in <2736a4f873604bfea9e5f3a0d64b37d6>:0
  at System.Windows.Forms.ContainerControl.WndProc (System.Windows.Forms.Message& m) [0x0001a] in <2736a4f873604bfea9e5f3a0d64b37d6>:0
  at System.Windows.Forms.Form.WmShowWindow (System.Windows.Forms.Message& m) [0x00013] in <2736a4f873604bfea9e5f3a0d64b37d6>:0
  at System.Windows.Forms.Form.WndProc (System.Windows.Forms.Message& m) [0x00290] in <2736a4f873604bfea9e5f3a0d64b37d6>:0
  at System.Windows.Forms.Control+ControlNativeWindow.OnMessage (System.Windows.Forms.Message& m) [0x00001] in <2736a4f873604bfea9e5f3a0d64b37d6>:0
  at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x000b3] in <2736a4f873604bfea9e5f3a0d64b37d6>:0
  at System.Windows.Forms.NativeWindow.Callback (System.Windows.Forms.Message& m) [0x00025] in <2736a4f873604bfea9e5f3a0d64b37d6>:0



大概意思是,在Font 中找不到一个 NativeFont 的属性。
我直接在 windows 下的dnspy 打开看了一下,是有的
但是,并不确保Linux 下的有没有。
于是,又得去找Linux 下的 dll 在哪里,拷贝过来。
发现,这玩意是在 Mono 的目录下找的。
找到了
System.Drawing.dll
打开 Font 发现,确实没有 NativeFont
但是却有另一个 NativeObject (印象中是这个命名),看属性的类型,感觉就是微软改名了。


然后,对比了Windows 中的,以及从Linux 的Mono 目录下拷贝出的 两个不同 System.Drawing.dll 发现
两个文件的版本似乎不同。
Windows中的那个:4.8.x :这个有NativeFont
Linux -Mono :4.6.x:这个没有NativeFont


于是,最简单粗暴的方式,就是将这个 有 NativeFont 的 dll 拷贝到 那个 Linux-Mono对应的文件夹下。
然而,问题还是一样的,没有任何变化。
因此,赶紧来问问大神。有没有谁做过类似的工作,是怎么解决的。


对了,Dev 使用的是 22.2


后来,为了降版本,专门又装回 Visual Studio 2019 再安装 DevExpress 18.1
问题还是一模一样。


请大神们给点建议吧。
——
2023/02/13 21:52
Mono里的说明:
History
There were two previous attempts to implement System.Windows.Forms in Mono. These initial attempts were done on top of other toolkits: first Gtk, then Wine. Each one had its share of problems, causing it to be abandoned.
The Gtk effort had the following problems:
  • Mapping one toolkit’s semantics to another was very hard.
  • It would be very cumbersome to map all events into WndProc events, the messaging system at the core of Windows.Forms.
  • The development effort happened early in the Mono life, with this very sporadic development effort, the code quickly became obsolete or bit-rotted.
  • Using this on other systems required a Gtk+ installation on the target system (macOS and embedded devices would have suffered the most).
The Wine effort could have been a successful approach, however there were several technical obstacles:
  • Multithreading support. Wine has a specific thread setup that is not compatible with Mono. While this was solvable, it would have required larger patches to Wine.
  • Dependencies. To have Mono and Wine interoperate, a glue library was required. This library required to know where Wine was installed to (we had a Wine patch that eased this requirement, but it was not accepted into Wine).
  • Moving target. Key functions in Wine changed often enough that with every Wine release we had to start over making our glue code work again, sometimes becoming incompatible with previous Wine versions.
  • Wine/Gdi+ interactions: The way System.Drawing had to be made compatible with Wine was extremely inefficient. Wine uses the GDI model (raster painting), while our System.Drawing implementation, built on top of Cairo, uses the GDI+ model (compositing model). Making them both talk was extremely inefficient as every transition from one model to the other required the bitmaps to be copied.
The current approach is to implement all controls fully in managed code, and uses an abstract theme interface to paint the widgets. The default theme interfaces renders the widgets using System.Drawing.


看来问题,就是出现在这个 System.Drawing.dll中。这个是跨平台的一个关键。




评分

参与人数 1赞扬 +1 收起 理由
miniprince + 1

查看全部评分

回复

使用道具 举报

0

精华

10

贡献

91

赞扬

帖子
11
软币
202
在线时间
10 小时
注册时间
2020-12-11
发表于 2024-3-24 19:20:31 | 显示全部楼层
老兄,你的问题解决了吗,我也遇到同样问题了,UOS系统 dev18.1 带Dev的控件的窗口就报错,没有Dev控件的窗口就可以。
回复

使用道具 举报

0

精华

7

贡献

307

赞扬

帖子
51
软币
593
在线时间
26 小时
注册时间
2020-11-7
发表于 2024-10-20 04:27:12 | 显示全部楼层
DevExpress v24.1.6 的跨平台是不是好很多。用DevExpress v24.1.6 的winform 可以在ubuntu 的wine 环境下正常运行吗?
回复

使用道具 举报

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文教育信息咨询有限公司

GMT+8, 2024-12-22 02:54

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表