Showing posts with label net cf. Show all posts
Showing posts with label net cf. Show all posts

Thursday, 15 July 2010

Compact Framework Network Printing

As usual a lot of time without posting but I had no time. I am really excited about the beta tools of WP7 (2 days ago I felt asleep while installing the beta cause the only time I have is after 11 p.m.). I also did some improvements on the Sqlite port but I will post it as soon as it will be usable (I plan to compare the performance with Perst even if it's a different approach).
I am posting this because I lost almost two days and maybe someone that needs it will find it right away. My task was some labeling process using MC9090 devices and Zebra S4m printers. I decided to go for in-memory parameterized forms. The client application uses two method for connecting to the printer:
1) Some of the printers have ethernet port and it is quite simple to communicate with the printer as you will open a socket to 9100 port and send the commands to the printer. This is simple
2) Other printers are connected as shared printers from pc's. This one should also be simple but it gave me a lot of headaches and mainly from my fault. I have two approaches:

a. The classic one that you would also do on Windows applications is to invoke CreateFile with the UNC name of the shared printer. My mistake with this approach was that I set the main window as TopMost and when calling the CreateFile windows mobile it will pop up a networking window where you have to insert the user name and password to use for authentication (this even if Guest access is enabled on the shared printer). So this approach was working but as I did not see the pop up window I thought it doesn't work

b. The second one is a little bit more complex. I am invoking WNetAddConnection3 to map the printer as a local resource (when using this method you can also pass the username and the password) and than using CreateFile on the local resource. After sending everything to the printer I call WNetCancelConnection2 to remove the resource (not really optimized but works). The second one seems more stable

The only annoying thing in this moment is the POCKET PC networking pop-up that tells me that the job has finished printing. I want to disable it (I think that it's something to do with the registry) but didn't find the way yet.

I am attaching 2 files Print.cs and Networking.cs. Print.cs has two methods one with authentication and another without.

Hope someone will find it useful


Namaste


Wednesday, 17 March 2010

WP7 Emulator Build 7.0.0.6077

Tonight I start looking how the new emulator is integrated in Visual Studio 2010. Using Process Explorer I saw that VS launches this command:
"C:\Program Files\Microsoft XDE\1.0\XDE.exe" "C:\Program Files\Microsoft SDKs\WindowsPhone\v7.0\Emulation\Images\WM70C1.bin"

So the new Device Emulator changed name in XDE (version 10.0.30128.39) and we have the bin file that contains the emulator image. I then remembered that you can extract the files from a bin image, but the guys at XDA were already ahead. They made a dump of the ROM files. A lot of people are digging up and we might see some interested things in the next couple of days.

This is what I've found out. The new OS, build 7.0.0.6077, has NET CF 3.7 embedded. I then remembered that there was a CF 3.7 cab version that was running on WM 6.5 and I got this "crazy" idea that I have to try... What if we could run the Silverlight applications that we compile for WP 7 on WM 6.5? I'm gonna dig this up tomorrow.

Anyway in the dump files I could find the Silverlight assemblies:
GAC_System.Windows.Browser_v2_0_5_0_cneutral_1.dll 129.328
GAC_System.Windows.RuntimeHost_v2_0_5_0_cneutral_1.dll 35.120
GAC_System.Windows_v2_0_5_0_cneutral_1.dll 1.038.640
that might just work on WM 6.5

and also the XNA assemblies:
GAC_Microsoft.Xna.Framework.GamerServices_v4_0_0_0_cneutral_1.dll 112.088
GAC_Microsoft.Xna.Framework.Game_v4_0_0_0_cneutral_1.dll 71.128
GAC_Microsoft.Xna.Framework.Graphics_v4_0_0_0_cneutral_1.dll 189.912
GAC_Microsoft.Xna.Framework.Input.Touch_v4_0_0_0_cneutral_1.dll 34.264
GAC_Microsoft.Xna.Framework_v4_0_0_0_cneutral_1.dll 382.424
XnaFrameworkCore.dll 357.848

XnaFrameworkCore.dll it's a native file so I think we would need one from a real device not emulator.

There is also SQL Ce Compact 3.5
GAC_System.Data.SqlServerCe_v3_5_1_0_cneutral_1.dll the version is 3.5.5722.1

And more managed assemblies:
GAC_Microsoft.Devices_v2_0_5_0_cneutral_1.dll
GAC_Microsoft.Phone.Controls.Navigation_v2_0_5_0_cneutral_1.dll
GAC_Microsoft.Phone.Controls.WebBrowserInterop_v2_0_5_0_cneutral_1.dll
GAC_Microsoft.Phone.Controls.WebBrowser_v1_0_0_0_cneutral_1.dll
GAC_Microsoft.Phone.Controls_v1_0_0_0_cneutral_1.dll
GAC_Microsoft.Phone.Execution_v1_0_0_0_cneutral_1.dll
GAC_Microsoft.Phone.Info_v1_0_0_0_cneutral_1.dll
GAC_Microsoft.Phone.License_v2_0_5_0_cneutral_1.dll
GAC_Microsoft.Phone.Notification_v2_0_5_0_cneutral_1.dll
GAC_Microsoft.Phone.Shell.Interop_v2_0_5_0_cneutral_1.dll
GAC_Microsoft.Phone.Shell_v1_0_0_0_cneutral_1.dll
GAC_Microsoft.Phone.TaskModel.Interop_v2_0_5_0_cneutral_1.dll
GAC_Microsoft.Phone.Tasks_v2_0_5_0_cneutral_1.dll
GAC_System.Device.Location_v2_0_5_0_cneutral_1.dll
GAC_CaptureApiManaged_v1_0_0_0_cneutral_1.dll


It's a start...We can look a little under the hood of WP 7 and see how it is designed. Pretty interesting, right?