Hi all,
I am relatively new to C# and the CF, as a whole I have about 8 months
experience with then so not a great deal. I come from a VB6 back ground so
my OOP and Threading are also new to me. I am having a problem with an
application I am trying to write and you seem to be some what of a guru on
the topic of CF development, so I would be very great full for any help or
advice you could give me.
What I am trying to do is write an application that will automat UAT tests
for my company. We tend to develop high volume user applications for
warehouses and proof of delivery systems. These are all running on Windows
Mobile devices from Symbol.
The problem is trying to run suitable load and regression tests on 800 units
at a time is virtually imposable. So what I am trying to write is a small
application that can drive the main application from a simple text file,
like a test script.
I found what I thought was a fantastic solution to my problem at this
website.
http://msdn.microsoft.com/msdnmag/issues/03/01/UITestAutomation/default.aspx
I ported the 2 Applications in the article to CF2 applications.
However I seem to have come up against a few hurdles to do with the loading
of the the application I am trying to test. In CF7 applications there is a
Static Program class that is the entry point with a private method Main.
I have tried a number of different ways of invoke this method to get the
application to load up but I keep getting errors. I have even tried exposing
a public method in the application I am trying to test and calling the main
method from with in that but still no luck.
Any help would be fantastic.
Thanks,
Ink
PS below is some of the code I have tried.
private void button1_Click(object sender, EventArgs e)
{
//First load the application
testAssembly = Assembly.LoadFrom("\\Program
Files\\WM_Automation_Test\\WM_Automation_Test.exe");
//Type t = testAssembly.GetType("Mnetics.CEApp.Splash");
//testForm = (Form)testAssembly.CreateInstance(t.FullName);
//Mnetics.CEApp.Forms.Splash
//ChangeForm("Mnetics.CEApp.Forms.Splash");
//Type t = testAssembly.GetType("WM_Automation_Test.Program");
//t.GetMethod("AutomationEntry").Invoke(null, new object[] { });
Type t = testAssembly.GetType("WM_Automation_Test.Program");
t.GetMethod("AutomationEntry").Invoke(null, new object[] { });
//object x = (object)testAssembly.CreateInstance(t.FullName);
//InvokeMethod(x, "Main");
//ThreadPool.QueueUserWorkItem(new WaitCallback(RunApp),
testForm);
}
private void ChangeForm(string NewForm)
{
Type t = testAssembly.GetType(NewForm);
testForm = (Form)testAssembly.CreateInstance(t.FullName);
}
//private delegate void RunAppDelegate(object state);
static void RunApp(object state) // Need this function to pass into
WaitCallback().
{
//if (this.InvokeRequired)
//{
// // we were called on a worker thread
// // marshal the call to the user interface thread
// this.Invoke(new RunAppDelegate(RunApp), new object[] {
state });
// return;
//}
// this code can only be reached
// by the user interface thread
//Start the application
Application.Run((Form)state);
}
dbgrick - 09 Aug 2007 22:08 GMT
ink,
I had a large cf application that required monitoring and remote execution
of code. Initially I considered using .NET remoting, but instead wrote a
telnet client that would stream results and allowed the user to send script
type messages to the app. This would allow you to execute your test code and
retrieve results from your Mobile application. Here is an article that gives
you an idea of how to create the client on the Mobile Device. I hope this
helps.
http://www.codeproject.com/useritems/WiMoTelnetClient.asp
Rick D.
Contractor
> Hi all,
>
[quoted text clipped - 91 lines]
>
> }
ink - 10 Aug 2007 08:53 GMT
Hi dbgrick,
Thanks for your help. This is a very interesting article and I intend on
playing with it a bit.
And my apologies for not making my problem very clear.
The problem I am having is trying to load up a Dot.net application in the
same thread as the calling application so that I can use reflection to call
into the procedures of that application.
Thanks,
ink
> ink,
> I had a large cf application that required monitoring and remote execution
[quoted text clipped - 122 lines]
>>
>> }
<ctacke/> - 10 Aug 2007 13:20 GMT
You can't load 2 applications into 1 thread (as I explained in the other NG
thread you started). If you simply want to call methods in the other
application then you can use Reflection to create instances of classes.
However this is not going to get you the results you want of a separate UI
running since there can't be 2 message pumps running in a single
application.
If you need to launch some other app and affect its UI - clicking buttons,
entering text, etc then you need to simulate user input by calling
mouse_event/SetCursorPos/keybd_event/PostKeyboardMessage and things like
that.

Signature
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
> Hi dbgrick,
> Thanks for your help. This is a very interesting article and I intend on
[quoted text clipped - 136 lines]
>>>
>>> }
ink - 10 Aug 2007 14:43 GMT
Hi,
I see. i am just not understand how come the application on the Microsoft
website seems to do what i need it to do.
Will this only work with a single form application?
So that you can create the instance of the form your self rather than
letting the application do it. And then call its methods.
http://msdn.microsoft.com/msdnmag/issues/03/01/UITestAutomation/default.aspx
thanks,
ink
> You can't load 2 applications into 1 thread (as I explained in the other
> NG thread you started). If you simply want to call methods in the other
[quoted text clipped - 154 lines]
>>>>
>>>> }