BUG: The Regasm Tool Registers the Type Library with the Decimal Value Instead of the Hexadecimal Value (816970)



The information in this article applies to:

  • Microsoft .NET Framework SDK 1.0
  • Microsoft .NET Framework SDK 1.1

SYMPTOMS

When you use the Regasm (assembly registration) tool to register the information of a Primary Interop Assembly in the registry, the Primary Interop Assembly is registered in the HKEY_CLASSES_ROOT\TypeLib key. The decimal value of the type library version is used instead of the hexadecimal value. For example, if the version number of your type library is 10.0, then you may find the version number as 10.0 instead of a.0. This occurs at the location that follows:

HKEY_CLASSES_ROOT\TypeLib\{typelib_guid}\version number\PrimaryInteropAssembly

CAUSE

A Primary Interop Assembly must be registered under the TypeLib key with the hexadecimal value of the version of the type library. The Regasm tool incorrectly generates the registry information. The Regasm tool uses the decimal value for the version of the type library. Therefore, the Primary Interop Assembly is incorrectly registered with a decimal value.

RESOLUTION

To resolve this problem, you can use the /Regfile option together with the Regasm command. Use /Regfile and Regasm to generate the .reg file that has the required registry information. Then, you must:
  • Manually edit the decimal value of the version number.
  • Change the decimal value of the version number to the corresponding hexadecimal value.
  • Run the .reg file.
Note When you use the Regasm tool with the /RegFile option, the registry information for the Primary Interop Assembly is not updated in the registry. This occurs because the Regasm tool depends on Oleauto32.dll to register the type library. The registry information that is added by Oleauto32.dll is not written to the .reg file when you run the Regasm tool and you use the /Regfile option. Therefore, you must run the Regasm tool one time without using the /Regfile option. This updates the details to the registry. Then, run the Regasm tool again with the /Regfile option. This permits you to access the .reg file. You can edit the .reg file to make your modifications and then run the .reg file.

For example, assume that the library name is Test.dll. To resolve the problem, follow these steps:
  1. Move to the Microsoft Visual Studio .NET command prompt.
  2. Change the directory to the folder where Test.dll exists.
  3. Type this command to add the information to the registry: regasm Test.dll.
  4. Type this command and then press ENTER: regasm Test.dll /regfile:Test.reg

    This creates the .reg file for the library.
  5. At the command prompt, type this command and then press ENTER: Notepad Test.reg

    This opens Test.reg.
  6. Locate this entry for the Primary Interop Assembly:

    [HKEY_CLASSES_ROOT\TypeLib\{TypeLib ID}\Version Number]
  7. Replace the decimal number for the version with the hexadecimal number. Save the file.
  8. Type Test.reg at the command prompt. Press ENTER to update the registry information.
Note You can find the hexadecimal number that corresponds to a decimal number if you use the Microsoft Calculator in scientific mode.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Problem

  1. Create an ActiveX DLL project in Microsoft Visual Basic 6.0. Name the project Test.
  2. Add the code that follows to Class1:
    Public Function GetName() As String
       GetName = "Microsoft"
    End Function
  3. On the File menu, click Make Test.dll.
  4. In the File Name text box, type C:\Test.dll and then click OK.
  5. Repeat step 3. Do this 10 times to create version 10 of the type library or Test.dll.
  6. Move to the Microsoft Visual Studio command prompt. Change the drive to C.
  7. Type the following command: sn -k myKey.snk

    This command generates a strong name key file.
  8. Type the following code to import the type library as the Primary Interop Assembly: tlbimp Test.dll /out:TestNet.dll /keyfile:myKey.snk /primary
  9. Type the following code to register the assembly with the Regasm tool: regasm TestNet.dll
  10. To open Registry Editor, on the taskbar click start and then click Run.
  11. Type regedit in the Open text box and then click OK.
  12. Expand HKEY_CLASSES_ROOT and then click to select TypeLib.
  13. On the Edit menu, click Find. Type TestNet and then click Find Next.

    Notice that the Primary Interop Assembly information is added to the version 10.0 key.

REFERENCES

For more information about Primary Interop Assembly Namespaces, see the .NET Framework SDK documentation or visit the following Microsoft Web site:

http://msdn.microsoft.com/library/en-us/csvr2002/htm/cs_sp_netprogframework_dfkd.asp

Modification Type:MajorLast Reviewed:6/18/2003
Keywords:kbinterop kbRegistry kbDLL kbbug KB816970 kbAudDeveloper