sâmbătă, 17 septembrie 2011

Res2Res Error Adding Resources

Upon compiling a new OS design for the Device Emulator, the following error may occur during Sysgen:

ERROR: Res2Res: Res2Res:  ERROR: Line: 267  File: c:\ce1\tools\ostools\wincetools\rescommon\checksum.cpp
ERROR: Res2Res: Res2Res:  ERROR: Line: 267  File: c:\ce1\tools\ostools\wincetools\rescommon\checksum.cpp
Res2Res: Error adding resources (-1)
NMAKE : fatal error U1077: 'res2res' : return code '0xffffffff'
NMAKE : fatal error U1077: 'C:\WINCE600\sdk\bin\i386\nmake.exe' : return code '0x2'


The same issue may provide the following error code: Res2Res: Error adding resources (110) NMAKE : fatal error U1077: 'res2res' : return code '0x6e' Stop. NMAKE : fatal error U1077: 'C:\WINCE600\sdk\bin\i386\nmake.exe' : return code '0x2' Stop.

To solve the res2res related error, I have opened the project property pages and chose not to localize the build. I have also cleared all locales and only selected the English(United States) locale.

atls.lib Error when Building Device Emulator OS

When building a Device Emulator OS design project, it is common to receive an error in the build process that refers to atls.lib. Visual Studio simply writes BLDEMO: There was an error in the build process. The true cause of the error is found in the build.log file, typically located in C:\WINCE600.
At the end of the build.log file, the following lines point to the error cause:
NMAKE : fatal error U1073: don't know how to make 'C:\WINCE600\OSDesigns\OSDesign1\OSDesign1\Wince600\DeviceEmulator_ARMV4I\cesysgen\oak\lib\ARMV4I\retail\atls.lib'
NMAKE : fatal error U1077: 'C:\WINCE600\sdk\bin\i386\nmake.exe' : return code '0x2'
To solve the build error, the Active Template Library needs to be included in OS using the  Catalog view. Just type ATL in the Catalog view search bar and check the "Active Template Library(ATL)" entry.
After adding the reference to ATL, run the Sysgen build command to generate the OS image.

joi, 15 septembrie 2011

Debug Windows CE Applications Via TCP/IP

It is sometimes required to debug application on Windows CE devices without an ActiveSync connection, but over TCP/IP. In order to enable debugging using Visual Studio 2005, a few setup steps are required.
1. Create a OS image or copy the files listed below in the \Windows folder. It is more convenient to create a OS image in the case that Windows CE is loaded in RAM and the copied files would be deleted upon a subsequent restart. These files can be typically found in C:\Program Files\Common Files\Microsoft Shared\CoreCon\1.0\Target\wce400\<Target CPU>, where target CPU can be for instance armv4i. There you will need to find these files:
- clientshutdown.exe
- ConmanClient2.exe
- eDbgTL.dll
- TcpConnectionA.dll

2. In Visual Studio, navigate to Tools|Options|Device Tools|Devices. Select the "Windows CE 5.0 Device" from the list of devices and click Properties.
3. In the Properties window, select TCP Connect Transport under Transport and then click Configure.
4. Under Configure TCP/IP Transport, select the IP address of the device. In my case this is Click OK to close this window and the other windows and return to Visual Studio.
5. On the device side, open the command prompt, change the directory to \Windows were you have already copied the files specified on step 1 and execute ConmanClient2.exe. After that, execute CMAccept.exe. Alternatively, you can open the Windows folder using Explorer and double click on these files in the specified order.
6. Within three minutes of performing these steps, connect to the device using Visual Studio - that is, start debugging your application against the Windows CE environment.

That's it, you are ready to go!

miercuri, 7 septembrie 2011

Activate and Configure RNDIS for Windows CE Based Devices

To activate RNDIS and communicate over TCP/IP with the Windows CE based device from Windows 7, I had to follow these steps:
1.      Modify the key [HKEY_LOCAL_MACHINE\Drivers\USB\FunctionDrivers\DefaultClientDriver] to RNDIS.

2.      Save the registry modifications and restart the module.

3.      In Windows, ActiveSync will no longer work and a generic RNDIS device will be listed in Device Manager,under Unknown Devices.

4.      Right click the generic device and select to install a driver.

5.      In the next window, select “Browse my computer for driver software”:

6.      In the next window, select “Let me pick from a list of device drivers on my computer”:

7.      In the next window, select Network Adapters from the Common Hardware Types list and click Next.

8.      In the Select Network Adapter window, select Microsoft Corporation and from the list on the right, Remote NDIS Compliant Device. Click Next.

9.      You will get a warning message; you need to ignore it and install the new driver. After installation the RNDIS device will be listed under Network Adapters in Device Manager.

10.      On the PC side, in Network Connections, right click on the new adapter and assign it a new IP address, typically: with mask Leave the other fields blank.

11.      In Windows CE, open Settings->Network and Dial-Up Connections and double click on the RNDIS adapter. Assign a new IP address, typically with mask Leave the other fields blank.

12.      Now test communication between the PC and the Windows CE device by pinging the device’s address.

            Important Note: In this setup, Active Sync will no longer work. It can only be restored by modyfing the [HKEY_LOCAL_MACHINE\Drivers\USB\FunctionDrivers\DefaultClientDriver] back to its original value (Serial_Class).

marți, 6 septembrie 2011

Exception messages in .NET Compact Framework

The .NET Compact Framework team decided not to include libraries that contain error message strings by default since these would occupy more space and are in most cases not meant for the end users.
As developers, we need to these messages for debugging purposes, specially when we are not using Visual Studio. Whenever an exception occurs, the log entry for it would look like this: "An error message cannot be displayed because an optional resource assembly containing it cannot be found". This post of the .NET Compact Framework team explains what we need to do in order to enable descriptive exception messages on our Windows Mobile/ CE based device.
Basically what you need to do is copy the System_SR_[Language].CAB  file from your computer to the device and then double click it to install the .cab. If your language of choice is English, you need to copy the System_SR_ENU.cab, installed by default in C:\Program Files\Microsoft.NET\SDK\CompactFramework\v2.0\WindowsCE\Diagnostics.
After installing this .cab file on the mobile device, you will start seeing descriptive exception messages, that are far more helpful.

Learn more on overall Compact Framework development in C# from Programming .NET Compact Framework 3.5 (2nd Edition) by Paul Yao and David Durant.