If an Assembly is to be encapsulated as an ActiveX/COM component, it must have a Strong Name (Strong Name), that is, you must specify the SNK (Strong Name Key) during compilation ). However, if an Assembly is compiled with a strong name, it requires that all other assemblies referenced by it must have a strong name. Otherwise, compilation cannot be successful. In this case, you can create or recreate a named assembly as follows.
First, whether we need a key pair (take VS2008 as an example ): 1. Run in "Start Menu"-"program"-"Microsoft Visual Studio 2008"-"Visual Studio Tools"-"Visual Studio 2008 command prompt" (Use this command line to work to execute the VS command line tool in any path ); 2. Create a strongly-named Assembly key file and execute the command C: \ sn-k keypair. snk 3. Bind a key file to the class library (1). if you have the source code of the class library to be referenced, you can find AssemblyInfo in the class library project. add the following attributes to the cs source file: [assembly: AssemblyKeyFile ("C: \ keypair. snk ")] (if the source code is available, you can also directly use the project configuration to directly generate and bind a key pair to the class library project. Configuration example: Right-click "Class Library Project"-> "properties"-> "signature" tab-> select the "sign for assembly" check box-> select a strong name key file (K): "drop-down box->" new "or" browse "to select an existing key file .)
B. Generate a project to obtain a type library with a strong name. (2) If you only have a third-party class library (xxxxxx. dll) file and no source code project, continue with the following operations.
A. Use the class library file to obtain the Microsoft intermediate language (MSIL) source code file.
C: \> ildasm xxxxxx. dll/out: xxxxxx. il B. use the MSIL source code file (xxxxxx. il) and the newly generated (keypair. snk) key file to create a new Assembly class library file C: \> ilasm xxxxxx. il/dll/key = keypair. snk