StaWho
StaWho

Reputation: 2488

Windows Mobile 6.5 - TypeLoadException on Process.Start()

In the solution I have several .exe files that sit in the same directory. One of them is a Master Menu, which looks up all the other executables' path (within the same dir) and assigns to buttons in the form. When the button is clicked it's underlying exe is launched via Process.Start().

Each exe is packed in separate installation CAB. After initial install, I run the Master Menu, then pick any of the buttons and underlying app launches successfully. I quit it, then run again the same or any other app but this time it crashes with:

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 is an UserControl which has TextBox.Focus() in its constructor. I tried to move it out to 'Validated' event handler but the outcome is the same, with one difference that this time it crashes on Form.Load() when trying to set its own visibility.

The cycle can be repeated after device reset. Most importantly, if I run any of the child executables directly those launch and work fine all the time.

The same code set works fine on WinMo 6.1. I also use OpenNETCF's Application2 class - tried to replace it with standard Application class with the same result. Tried to set Process.StartInfo.WorkingDirectory and UseShellExecute but again no joy. When looking at Process() object in the "Master Menu" app - it behaves as expected (creates process, returns 'true' on .Start() etc).

No assemblies are installed to GAC, all files reside in the same dir.

Any clues?

[Edit]

After I get the error and device is left untouched for about 10 minutes it all gets back to start: I can again run sub-app once etc. Giving that I tried wiping reference to current process from my Master Menu, killing the process, calling GC.Collect() with no result.

[Edit]

Loader log looks ok up to this point (this is where app starts failing):

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]

After copying System.SR.dll to app installdir:

Loading module [\windows\en\System.SR.resources.dll]
Attempt to load [\windows\en\System.SR.resources.dll] has failed (err 0x80001001)

Installed System_SR_ENU.CAB and NETCFv2.wm.armv4i.cab but now log says that one of the device specific dlls (ITCScan.DLL) can't be loaded, which I believe to be .NET 3.5 assembly. As far as I know System.SR is used only in .NET2, is it not that some other exception is trying to surface and manifests itself like this?

Upvotes: 2

Views: 1477

Answers (2)

EduLopez
EduLopez

Reputation: 721

I had the same problem and I couldn't resolve it. I had to look for another way to call the apps.

What I did is put parameters in the constructor of the form B and then call it from A. Those parameters are the same as the arguments of the .exe of the B app.

Calling code:

MyAppNameSpace.MyForm _B = new MyAppNameSpace.MyForm(UserID,Date,this);
F.Show();

Constructor:

public MyForm(string _U, DateTime _d, Form _PrevForm)
{
   Form A = _PrevForm;
   string U = _U;
   DateTime d = _d;
   InitializeComponent();
}

App B has an extra parameter in the constructor that is the form A. I use that form to manage the application.exit(). Calling that function will close the whole system( APP A and B). Instead of that you should use the A.show();

public void BackToAppA()
{
   A.show();
}

Upvotes: 1

user153923
user153923

Reputation:

My guess is that the first executable you are running (call it Exe A) is still running.

When someone clicks the button that corresponds to Exe A on your menu, look at all of the running processes to see if it is already running. If so, just pull Exe A to the front.

This may not be the solution to your problem, but it is the first thing that comes to my mind when I read what you describe. Under Windows Mobile, an application does not necessarily close when someone closes it unless the creator of that app ensures that it does.

I hope this helps.

Upvotes: 0

Related Questions