Microsoft KB Archive/816970

= BUG: The Regasm Tool Registers the Type Library with the Decimal Value Instead of the Hexadecimal Value =

Article ID: 816970

Article Last Modified on 6/18/2003

-

APPLIES TO


 * Microsoft .NET Framework Software Development Kit 1.0 Service Pack 2
 * Microsoft .NET Framework Software Development Kit 1.0 Service Pack 2

-





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   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:

 



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.
 * 1) At the command prompt, type this command and then press ENTER: Notepad Test.reg

This opens Test.reg.
 * 1) Locate this entry for the Primary Interop Assembly:

 
 * 1) Replace the decimal number for the version with the hexadecimal number. Save the file.
 * 2) 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.



Steps to Reproduce the Problem
 Create an ActiveX DLL project in Microsoft Visual Basic 6.0. Name the project Test .  Add the code that follows to Class1: Public Function GetName As String GetName = &quot;Microsoft&quot; End Function  On the File menu, click Make Test.dll. In the File Name text box, type C:\Test.dll and then click OK. Repeat step 3. Do this 10 times to create version 10 of the type library or Test.dll.</li> Move to the Microsoft Visual Studio command prompt. Change the drive to C .</li> Type the following command: sn -k myKey.snk

This command generates a strong name key file.</li> Type the following code to import the type library as the Primary Interop Assembly: tlbimp Test.dll /out:TestNet.dll /keyfile:myKey.snk /primary </li> Type the following code to register the assembly with the Regasm tool: regasm TestNet.dll </li> To open Registry Editor, on the taskbar click start and then click Run.</li> Type regedit in the Open text box and then click OK.</li> Expand   and then click to select TypeLib.</li> 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.</li></ol>

<div class="references_section">