Jaa


TypeLoadException thrown whenever Microsoft.WindowsMobile.Telephony is used in Windows Mobile 5.0 Smartphones.

Hello, the following bug exists today in Windows Mobile 5.0 Smartphone. I wrote a KB article that has this information, but I figured I would write a blog entry here as well. If you are developing for Smartphone and using Microsoft.WindowsMobile.Telephony, Visual Studio will deploy the Microsoft.WindowsMobile.Telephony.dll to the device when you deploy, so you might not realize that this problem occurs until you write a CAB that deploys only your application.

Steps to reproduce:

Create an application that uses the Microsoft.WindowsMobile.Telephony as follows:

1.- Add a reference to Microsoft.WindowsMobile.Telephony.dll

2.- Call the Microsoft.WindowsMobile.Telephony, for example:

 Phone myPhone = new Microsoft.WindowsMobile.Telephony.Phone();
myPhone.Talk("555-0100 \0");

3.- Build the application, copy it to the Smartphone and run it from the smartphone.

Resolution:

The following two entries need to be added to the registry:

Location: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETCompactFramework\Installer\Assemblies\Global]
Type: Multi-String
Name:
Microsoft.WindowsMobile.Telephony, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

Value: "\Windows\GAC_Microsoft.WindowsMobile.Telephony_v1_0_0_0_cneutral_1.dll","Microsoft.WindowsMobile.Telephony.dll"

Location: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETCompactFramework\Installer\Assemblies\ROM]Type: Multi-StringName: Microsoft.WindowsMobile.Telephony, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Value: "\Windows\GAC_Microsoft.WindowsMobile.Telephony_v1_0_0_0_cneutral_1.dll","Microsoft.WindowsMobile.Telephony.dll"

T

hese entries may be added manually to a Smart Device CAB Project using Microsoft Visual Studio 2005 or they may be added by including them in the RegKeys section of an .inf file that produces a CAB file as follows:

[RegKeys]
"HKLM","Software\Microsoft\.NETCompactFramework\Installer\Assemblies\ROM","Microsoft.WindowsMobile.Telephony, Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35","0x00010000", "\Windows\GAC_Microsoft.WindowsMobile.Telephony_v1_0_0_0_cneutral_1.dll","Microsoft.WindowsMobile.Telephony.dll"
"HKLM","Software\Microsoft\.NETCompactFramework\Installer\Assemblies\Global","Microsoft.WindowsMobile.Telephony,
Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35","0x00010000",
"\Windows\GAC_Microsoft.WindowsMobile.Telephony_v1_0_0_0_cneutral_1.dll","Microsoft.WindowsMobile.Telephony.dll"

The problem has been fixed for future releases already.

- Luis Eduardo Cabrera

Comments

  • Anonymous
    February 15, 2006
    Thanks for the tip! :-)

    I am working in a company in Norway that make mobile applications  (on Symbian and Windows Mobile). We have had quite some challenges with using ATDT-commands (the "phone modem") on Windows Mobile.  This is not yet possible to do with .Net, and we have had to use unmanaged/native code for this, with all the challenges that can give you (and there also seems to be some differences on the different hardware around this from out experience, even from same vendor...we have only tested on HTC models, but have found some different behaviour).

    Anyway, with Windows Mobile 5 and .Net CF 2.0 there was a lot of great improvements, and things like accessing contacts/appointments, so forth is unbelievable easy to do now.

    The telephone API is fairly simple/minimal at the current version (don't get me wrong, I just luuuv VS 2005, and .Net in general...there just is always room for improvements in everything we do, right!?).

    So here is finally my question; Can you give out any information on any roadmap for expanding the phone API in .Net CF, and specifically if you are planning on making ATDT calls 100% accessible through managed/.Net CF?

    ...hopefully that is one of you next focus areas...!? ...pleeeeease!!!! :-)

  • Anonymous
    February 15, 2006
    We would like to increase the functionality of the Managed APIs we provide to ISVs. Unfortunately currently I cannot disclose specific plans for release of more managed APIs. But I will make a note that adding ATDT commands is something there is demand for.

    Tussen Takk!

    -Luis E. Cabrera
    SDE -Microsoft.

  • Anonymous
    February 16, 2006
    "Tusen takk", right back at yah! :-)

    ...for the non-scandinavians..."tusen takk" is "thanks"...or actually "a thousand thanks" in Norwegian! :-)

  • Anonymous
    February 22, 2006
    Hi. It is straightforward to make a call - but I was hoping someone could point me in the right direction to trap the digits dialled when a smartphone user hits the talk button. I want to be able to perform an operation based on the digits dialled.

  • Anonymous
    March 06, 2006
    So Luis, are you going to answer my email? ;-)

  • Anonymous
    March 07, 2006
    If by email, you mean the comment on Feb. 23...

    I don't know of an ISV Public API to trap phone numbers from the dialing application.

    I guess you could write your own dialer if you wanted to add extra functionality, and then use the TAPI functions to make the call without showing the dialer application, but I really don't have too much experience with TAPI.

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tapi/tapi2/phone_device_functions.asp

  • Anonymous
    June 05, 2006
    We have had to add this PublicKeyToken to most of the Microsoft.WindowsMobile.* assembly registry keys on our latest build of WM 5.0 in order to be able to call any method in Microsoft.WindowsMobile.Status or else we receive this error. I believe the problem exist in WM 5.0 and possibly in CE 5.0 also. Does your KB article only report this as an issue with WM 5.0 Smartphones?

  • Anonymous
    June 06, 2006
    Non windows mobile 5.0 devices do not include Microsoft.WindowsMobile assemblies, so this issue is specific to windows mobile 5.0 smartphones.

    Thanks.
    -Luis E. Cabrera

  • Anonymous
    November 13, 2006
    I have a similar problem When I use "Microsoft.WindowsMobile.Status". Does it also need to be added to any registry key??

  • Anonymous
    November 13, 2006
    I'm sorry. "Microsoft.WindowsMobile.Status" ->"Microsoft.WindowsMobile.Utilities"

  • Anonymous
    November 15, 2006
    You should not have the problem with Microsoft.WindowsMobile.Status.dll. Could you ellaborate on the problem you have:

  1. Device type. (and version)
  2. At what point in your code do you get the TypeLoadException? Thanks! -Luis Cabrera
  • Anonymous
    April 07, 2007
    Thanks for creating this blog entry.  It should fix the problem that we are experiencing.  I made this change to a VB project that does a wireless sync for a Windows Mobile 5.0 smartphone and am trying to intall the CAB file on the emulator.  When I do that, I get a systems permission error.  This only occurs when I try to install the CAB file that has the code to add the HKLM registry keys.  Any ideas on how to modify the permissions/security to fix this problem?  I have not been able to find anything yet. Thanks, Jim Dionne

  • Anonymous
    April 15, 2007
    Stupore! Amo questo luogo!:)))))))