A .NET Compact Framework application may generate a System.TypeLoadException exception when the application uses the Microsoft.WindowsMobile.Telephony assembly on a Smartphone device (914793)



The information in this article applies to:

  • Microsoft Windows Mobile 5.0 software for Smartphone

Important This article contains information about how to modify the registry. Make sure to back up the registry before you modify it. Make sure that you know how to restore the registry if a problem occurs. For more information about how to back up, restore, and modify the registry, click the following article number to view the article in the Microsoft Knowledge Base:

256986 Description of the Microsoft Windows registry

SYMPTOMS

When you run a Microsoft .NET Compact Framework-based application that uses the Microsoft.WindowsMobile.Telephony assembly on a Smartphone device, the application may generate a System.TypeLoadException exception.

CAUSE

This problem occurs because the Microsoft.WindowsMobile.Telephony assembly is not correctly installed in the global assemble cache in Microsoft Windows Mobile 5.0 for Smartphone. A TypeLoadException exception occurs when the Microsoft.WindowsMobile.Telephony assembly is loaded.

RESOLUTION

Warning Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by using another method. These problems might require that you reinstall your operating system. Microsoft cannot guarantee that these problems can be solved. Modify the registry at your own risk.

To resolve this problem, you must add the following two entries 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-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"

You may also use Microsoft Visual Studio 2005 to manually add these entries to a Smart Device CAB project. Or you may add these entries by including them in the RegKeys section of an .inf file that produces a CAB file. To do this, use the following formatting:

[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"

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

This problem is scheduled to be fixed in Adaptation Kit Update (AKU) 3.0 for Windows Mobile 5.0 for Smartphone.

For more information about how to add registry entry to a CAB project, visit the following Microsoft Developer Network (MSDN) Web site:

Steps to reproduce the problem

  1. Make sure that you have the Windows Mobile 5.0 SDK for Smartphone installed.
  2. Start Visual Studio 2005.
  3. On the File menu, click New, and then click Project.
  4. Expand Visual C#, expand Smart Device, and then click Windows Mobile 5.0 Smartphone.
  5. Click Device Application, type DeviceApplication1 in the Name box, and then click OK.
  6. Add a new LinkLabel control that is named linkLabel1 to the Form1 form.
  7. Add a reference to the Microsoft.WindowsMobile.Telephony assembly.
  8. Add the following using statement to Form1.cs:
    using Microsoft.WindowsMobile.Telephony;
  9. Add the following code to the linkLabel1_click event handler in Form1.cs:
    Phone myPhone = new Phone();
    myPhone.Talk("555-0100\0");
  10. Create a new Smart Device CAB project, and then deploy the application on the Smartphone device.

Modification Type:MajorLast Reviewed:4/11/2006
Keywords:kbinfo kbfix kbBug kbprb KB914793 kbAudDeveloper kbAudITPRO