【发布时间】:2012-05-20 01:51:55
【问题描述】:
在解决方案中,我有几个位于同一目录中的 .exe 文件。其中之一是主菜单,它查找所有其他可执行文件的路径(在同一目录中)并分配给表单中的按钮。单击按钮时,它的底层 exe 将通过 Process.Start() 启动。
每个exe 都打包在单独的安装CAB 中。初始安装后,我运行主菜单,然后选择任何按钮并成功启动底层应用程序。我退出了它,然后再次运行相同的应用程序或任何其他应用程序,但这次它崩溃了:
TypeLoadException
at System.Windows.Forms.Control.OnGotFocus(EventArgs e)
at System.Windows.Forms.Control.WnProc(WM wm, Int32 wParam, Int32 lParam)
at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
at Microsoft.AGL.Forms.WL.SetFocus(IntPtr hwnFocus)
at System.Windows.Forms.Control.Focus()
at myApp.Login..ctor()
at myApp.Form_UnderApp1.InitializeComponent()
at myApp.Form_UnderApp1..ctor()
at myApp.Program.Main()
myApp.Login 是一个 UserControl,它的构造函数中有 TextBox.Focus()。我尝试将其移至“已验证”事件处理程序,但结果是相同的,不同之处在于这次它在尝试设置自己的可见性时在 Form.Load() 上崩溃。
设备复位后可以重复循环。最重要的是,如果我直接运行任何子可执行文件,它们会一直启动并正常工作。
相同的代码集在 WinMo 6.1 上运行良好。我还使用 OpenNETCF 的 Application2 类 - 尝试用标准的 Application 类替换它,结果相同。尝试设置Process.StartInfo.WorkingDirectory 和UseShellExecute,但又没有任何乐趣。在“主菜单”应用程序中查看 Process() 对象时 - 它的行为符合预期(创建进程,在 .Start() 等处返回“true”)。
没有程序集安装到 GAC,所有文件都位于同一个目录中。
有什么线索吗?
[编辑]
在我收到错误并且设备保持不动大约 10 分钟后,一切都会重新开始:我可以再次运行子应用程序一次,等等。
假设我尝试从主菜单中擦除对当前进程的引用,终止进程,调用 GC.Collect() 没有结果。
[编辑]
到目前为止,加载程序日志看起来还不错(这是应用程序开始失败的地方):
Redirecting [Microsoft.WindowsCE.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC] to [Microsoft.WindowsCE.Forms, Version=3.5.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC]
Loading module [\windows\GAC_Microsoft.WindowsCE.Forms_v3_5_0_0_cneutral_1.dll]
Loaded [Microsoft.WindowsCE.Forms, Version=3.5.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC] from [\windows\GAC_Microsoft.WindowsCE.Forms_v3_5_0_0_cneutral_1.dll]
Loading module [\Program Files\MyApp\System.SR.dll]
Attempt to load [\Program Files\MyApp\System.SR.dll] has failed (err 0x80001000).
Loading module [\Program Files\MyApp\System.SR.exe]
Attempt to load [\Program Files\MyApp\System.SR.exe] has failed (err 0x80001000).
Loading module [\windows\System.SR.dll]
Attempt to load [\windows\System.SR.dll] has failed (err 0x80001000).
Loading module [\windows\System.SR.exe]
Attempt to load [\windows\System.SR.exe] has failed (err 0x80001000).
Failed to load [System.SR, Version=3.5.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC]
将System.SR.dll 复制到应用安装目录后:
Loading module [\windows\en\System.SR.resources.dll]
Attempt to load [\windows\en\System.SR.resources.dll] has failed (err 0x80001001)
已安装 System_SR_ENU.CAB 和 NETCFv2.wm.armv4i.cab 但现在日志显示无法加载设备特定的 dll (ITCScan.DLL) 之一,我认为这是 .NET 3.5 程序集。
据我所知,System.SR 仅在 .NET2 中使用,难道不是其他一些异常正试图像这样浮出水面并表现出来吗?
【问题讨论】:
-
您是否尝试过打开日志记录并查看加载程序日志以查看可能发生的情况? (msdn.microsoft.com/en-us/library/ms229650%28v=VS.90%29.aspx)
-
@ctacke Loader 日志让我更加困惑(更新后),我会继续寻找
-
仅供参考:ITCScan 不是 .NET 3.5 程序集。它是来自 Intermec 的本地库。
-
@pdriegen 这就是我所说的:'设备特定':)
标签: .net-3.5 compact-framework windows-mobile-6.5 opennetcf typeloadexception