小朱

Hello

I'm creating an application on Windows Mobile 5 using c#. This application uses the WebBrowser control to show a specific website.

The problem that i am having occurs when the app runs on the device. (Motorola Q). For some strange reason the application shuts down as soon as it gets to the line :

this.webBrowser1 = new System.Windows.Forms.WebBrowser();

which is in the InitializeComponent() method. It does this without an exception. When i connect the device and debug from VS.net 2005. The app shut off and i get a cannot connect to this device message.




Re: .NET Compact Framework Having Trouble With WebBrowser Control

СÖì

Hi all~

I wrote an application on Pocket PC 2003 SE and .NET Compact Framework 2.0 (with SP1).
This application will consume a Web Service to download photo file and instant authentication.
The Pocket PC has a RFID reader for authentication.

But, when I execute this application at RFID reader readed data and authenticated by Web Service and show photo, it closed unexpectedly, and no any message.

Something for my Pocket PC Application:

  • I read data from RFID reader via System.IO.Serial.SerialPort class.
  • I keep the Web Service Proxy Reference in the Global.PocketService variable.
  • Photo will be downloaded from Web Service using base64 string format, and restore to binary format at Pocket PC Application with the following code:

try
{
string imageStrData = null;

if (Global.CurrentMode == Global.Mode.Arrival)
{
this._parentTable = Global.PocketService.GetStudentParentList
(Global._currentAttendanceDataPackage.ProfileID).Tables[0];

imageStrData = Global.PocketService.GetStudentPhoto(Global._currentAttendanceDataPackage.ProfileID);
}
else
{
this._parentTable = Global.PocketService.GetStudentParentList
(Global._currentDeparturePackage.ProfileID).Tables[0];

imageStrData = Global.PocketService.GetStudentPhoto(Global._currentDeparturePackage.ProfileID);
}

this.cboParentList.DataSource = this._parentTable;
this.cboParentList.DisplayMember = "Name";
this.cboParentList.ValueMember = "ParentID";

if (imageStrData != null)
{
// load student photo.
byte[] data = Convert.FromBase64String(imageStrData);
MemoryStream ms = new MemoryStream();
ms.Write(data, 0, data.Length);
ms.Flush();
ms.Position = 0;

Bitmap bmp = new Bitmap(ms);
this.picStudent.Image = bmp;
ms.Close();
ms = null;
data = null;
}

GC.Collect();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

I can't get any error message and application terminated unexpectedly...
Please help me to troubleshoot this problem, or, let me know how to diagnostic the problem point.

Thanks a lot.






Re: .NET Compact Framework Having Trouble With WebBrowser Control

Steven Bone

I'd try these two things:

1. You could try hooking the AppDomain.CurrentDomain.UnHandledException event, and see if you get anywhere.

2. It is also possible that the OS is trying to free memory and posting a quit message. I can't recall how to hook that one at a lower level than setting a breakpoint in the Form.Closing event and see if it gets called from somewhere.





Re: .NET Compact Framework Having Trouble With WebBrowser Control

СÖì Jeff Chu

Thanks for your answer.
But I tried to catch AppDomain.CurrentDomain.UnHandledException event, it still can't catch any exception.
Have I any check point to catch this problem




Re: .NET Compact Framework Having Trouble With WebBrowser Control

Steven Bone

Have you tried to see if the Closing event on your form gets called That is the only other place I can think of to see what is going on....



Re: .NET Compact Framework Having Trouble With WebBrowser Control

СÖì Jeff Chu

I tried to handle Form.Closing event, but it still not any message (I think application is not called the event and terminated unexpectedly...)






Re: .NET Compact Framework Having Trouble With WebBrowser Control

Ilya Tumanov

I've couple questions:

1. Is your application or NETCF or any other component you're using installed on to storage card ot internal storage

2. Before application terminates, is it go through sleep/wake cycle

The reason for these questions is described here.






Re: .NET Compact Framework Having Trouble With WebBrowser Control

СÖì Jeff Chu

1. My application and .NET CF Runtime is stored into internal storage.
2. No, the process has not any sleep and wake cycle.

However, the process has a long task (5-6 seconds) to download the image and restore to binary format. The terminated unexpectedly action is occured after the process completed (and form displayed).






Re: .NET Compact Framework Having Trouble With WebBrowser Control

Ilya Tumanov

Could you please provide a cut down, but complete and compliable repro code You can post it here or e-mail it to me (remove ¡°online¡± form e-mail). Thanks.






Re: .NET Compact Framework Having Trouble With WebBrowser Control

Al Morris

Hey Im having the same problem

Im using the motorola q with .net cf 2.0. When i reach line :

this.webSummary = new System.Windows.Forms.WebBrowser();

the application terminates unexpectedly. I've tried hooking ApDomain.CurrentDomain.UnHandledException and nothing happend. It even seems to ignore the form1_closing event.

Sorry for crashing your thread. I've created my own thread about this subject and no-one responded





Re: .NET Compact Framework Having Trouble With WebBrowser Control

Ilya Tumanov

You'd need to be more specific (way more). There are many applications with line like this and they are doing OK. What is so special about yours Is NETCF installed on to storage card If you know the line, does that mean it happens under debugger Only after debugger






Re: .NET Compact Framework Having Trouble With WebBrowser Control

Al Morris

Sorry about that,

Im a writing a simple application that shows a WebBrowser control on a form. When i run my program in the emulator it works fine. When i run the program on my device , which happends to be a motorola q, it crashes at the line

this.webBrowser1 = new System.Windows.Forms.WebBrowser();

in the InitializeComponent function. This crash comes without warning. I've tried exception handling and hooking the UnkownException object and it still terminates.

When i call System.Environment.Version it tells me that im running 2.0.6.129.0.

I have NETCF running on the device memory and not on the storage card

thanks for the response.





Re: .NET Compact Framework Having Trouble With WebBrowser Control

Ilya Tumanov

How do you know it "crashes" in this specific line If you use NETCF V2 RTM instead of SP1, does that work






Re: .NET Compact Framework Having Trouble With WebBrowser Control

Al Morris

I know it crashes at this specific line because i surrounded it between two message boxes ie:

private void InitializeComponent()

{

MessageBox.Show("Program is about to break grrrr!!!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);

this.webSummary = new System.Windows.Forms.WebBrowser(); // crash line

MessageBox.Show("Program Didn't break yeah!!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);

this.SuspendLayout();

.

the first message box fires but the second one does not

also how do install NETCF V2 RTM.

one last thing i installed the same application on a friends pocket pc () and it work fine

Thanks





Re: .NET Compact Framework Having Trouble With WebBrowser Control

Ilya Tumanov

I see... What happens if you remove these message boxes and run this code under debugger step by step What would happen if you create another empty project with just web browser control and nothing else

NETCF V2 RTM comes with VS 2005. Undo whatever you've done to install SP1 to get RTM back (e.g. if you have installed a patch, remove it via ARP or remove entire MSI and reinstall RTM from your VS 2005 disk). You would also have to remove NTECF V2 SP1 from device via "Remove programs" since VS won¡¯t downgrade device to older version.

Also, there was an update for the Q issued by Motorola. Do you have it installed