Skip to Main Content
Visual Studio Hacks
book

Visual Studio Hacks

by James Avery
March 2005
Intermediate to advanced content levelIntermediate to advanced
304 pages
19h 23m
English
O'Reilly Media, Inc.
Content preview from Visual Studio Hacks
Quickly Sign Assemblies #54
Chapter 6, Speed Hacks
|
211
HACK
HACK
#54
Quickly Sign Assemblies Hack #54
Use a macro to sign an assembly with a strong name.
Strongly signing assemblies is one of the more tedious processes that you
have to perform when developing with the .NET Framework. The normal
process to strongly sign an assembly is as follows:
1. Create a .snk file using the sn.exe command prompt utility.
2. Move the .snk file into your project.
3. Point to the .snk file using the
AssemblyKeyFile attribute.
This is the process that you will reproduce using a macro. Follow these steps
to create a macro that will automatically sign assemblies for you:
1. Open the Macro IDE.
2. Create a new module.
3. Copy the following code into the module:
Imports EnvDTE
Imports System.Diagnostics
Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.ControlChars
Imports System.Windows
Imports System.Windows.Forms
Imports System
Public Module Module1
Public Class WinWrapper
Implements System.Windows.Forms.IWin32Window
Overridable ReadOnly Property Handle( ) As System.IntPtr Implements _
System.Windows.Forms.IWin32Window.Handle
Get
Dim iptr As New System.IntPtr(DTE.MainWindow.HWnd)
Return iptr
End Get
End Property
End Class
Sub AddStrongNameToProject( )
Dim init_dir, outfile_name, outdirectory As String
Dim stemp, Macroprojname As String
Dim prjSolution As EnvDTE.Project
Dim prjVSProject As VSLangProj.VSProject
Dim openfile ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Microsoft Visual Studio 2015 Unleashed, Third Edition

Microsoft Visual Studio 2015 Unleashed, Third Edition

Mike Snell, Lars Powers
.Net Framework Essentials

.Net Framework Essentials

Thuan L. Thai, Hoang Lam
C# 5.0 Unleashed

C# 5.0 Unleashed

Bart De Smet
Programming .NET Security

Programming .NET Security

Adam Freeman, Allen Jones

Publisher Resources

ISBN: 0596008473Errata Page