N S

Novick Software Management • Design • Programming • Training • Consulting

   

 

 

Tips and Tricks for:  VB.Net, C#

The Problem:   Unable to emit assembly: Referenced assembly 'Interop....' does not have a strong name

Visual Studio will give this message as soon as you give your own assembly a strong name even though Visual Studio had created the assembly when you first referenced the COM dll.


Solution: Use TLIMP to create an Interop assembly with a strong name.

The C# compiler has a project level property (Wrapper Assembly Key File) for the name of the .snk file that you're using to create strong names in your project.  Visual Basic.Net doesn't have a corresponding property and you have to use tlimp.exe to create the assembly with a strong name.  There's really no way around it.  Once you give your assembly a strong name, all assemblies that it calls must also have a strong name. 

Here's the text of a two line .CMD file that uses tlimp to create two assemblies.  One for SQLDMO, which is the heart of SQL Server Enterprise Manager, and the other for Office 2003 Outlook.  If you're working with Word or Excel, use the primary-Interop-Assemblies (PIA) that can be installed with the product instead of creating your own Interop Assemblies.

"c:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin"\tlbimp.exe 
          "C:\Program Files\Microsoft SQL Server\80\Tools\Binn\sqldmo.dll" 
          /out:InteropSQLDMO.dll 
          /keyfile:s:\strongname\mySnkFile.snk 
	    /namespace:SQLDMO
"c:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin"\tlbimp.exe "c:\Program Files\Microsoft Office\OFFICE11\msoutl.olb" /out:InteropOutlook.dll /keyfile:s:\strongname\mySnkFile.snk /namespace:Outlook

I've broken each line for readability but you can download the .CMD, which has been enclosed in a .ZIP file to get around download filters.  Of course you'll have to make your own .SNK file and change the path to in in the /keyfile parameter.  You'll also have to alter the paths to match your disk structure.  


RSS as HTML

Personal Blog

 
New Tips:

Loading SQL Profiler trace (.trc) files with fn_trace_gettrace

Upcoming
Presentations:

Big Data:
Working with Terabytes
in SQL Server

July 9 '08


Full Schedule