problem
Under the DOTNET platform, a complete class library is provided, but the first version is always impossible, and because of historical legacy issues, often and com
Interoperability between / ACTIVEX components.
The problem that the author touched is to call the Excel object in an Assembly, but the assembly needs to be encapsulated into an ActiveX's Control for IE for client script call. In short, I used a COM component in C #, but also packaged myself into a COM component, it sounds a bit of a little more than a better way.
In such packaged mode, I encountered a problem. If an assembly wishes to encapsulate the ActiveX / COM component, it must have a strong name, that is to specify the SNK (Strong Name Key) when compiling. But when an assembly is compiled by a strong name, it requires that the other Assembly referenced by itself must have a strong name, otherwise it is not possible to successfully compile. And when we directly refer to a COM component (for example: Excel 10 Object Library), VS.NET can help us import type library, but at this time, the reference type library is not a strong name, the environment expected in the author Can't compile success.
solve
I feel very tricky, it seems to be caught in and dead, but I've been able to find the document very easily, and the corresponding tool is provided in the DOTNET Framework, which is able to convert COM's type library. He is tlbimp.exe (everyone can Found in the directory similar to "C: / Program Files / Microsoft Visual Studio .NET 2003 / SDK / V1.1"). TLBIMP can package a COM component into the form of class libraries that DOTNETs can be used, and VS.NET's automatic conversion should be the tool. This tool has many parameter switches, which requires a strong name to open an additional switch. Introduce the author thinks the most likely parameters:
/ OUT: FileName: The name of the output file after the type library conversion.
/ Namespace: Namespace: The namespace used by the type library conversion.
/ keyfile: filename: Specifies the SNK file used in the conversion, indicating that the parameter, the type library after the configuration has a strong name.
Complete examples are as follows:
Tlbimp Excel.exe /out:Iinterop.Excel.dll / namespace: Excel /keyfile :Excel.snk
The SNK file can be generated by another tool Sn in the DOTNET, and details are not described herein.
Complete the above work, directly quote the type library we constructed in the project, you can successfully compile with a strong named DLL.
If it is a control, instead of ordinary component, then you can't use TLBIMP, but you need to use the AXIMP.EXE tool, how to use TLBIMP, he generates two files: one is the proxy file of the type library, the other is Proxy file for Windows Form.
Further resolution
However, there is a simpler solution that sets "Wrapper Assembly Key File" in the engineering attribute, this property. After setting this property, the COM / ActiveX component added by add report will be identified, with a strong name.
This requires a setting, it should be more convenient. Reference documentation
TLBIMP related: http://msdn.microsoft.com/library/en-us/cptools/html/cpgrftypelibraryImportertlbimpexe.asp
SN related: http://msdn.microsoft.com/library/en-us/cptools/html/cpgrfstrongnameutilitySnexe.asp
AXIMP Related: http://msdn.microsoft.com/library/en-us/cptools/html/cpgrfWindowsFormSactiveXControlImportraximpexe.asp
C # project's property description: http://msdn.microsoft.com/library/en-us/cscon/html/vcurfcprojectGeneralPropertyPage.asp