Re: Adding an AssemblyKeyFileAttribute to a Visual Basic App

From: Joe Kaplan \(MVP - ADSI\) (
Date: 10/21/04

Date: Thu, 21 Oct 2004 12:06:09 -0500

The path is relative to the obj\debug or obj\release directory (where the
actual compiled files are placed initially) the way VS.NET compiles the
project. Normally, people put the snk file in the root of the project file
and do 2 parent paths in the key file path:

<Assembly: AssemblyKeyFile("..\..\smsupdate.snk")>

Knowing that should give you some options. You can also use sn to store it
in a key container and user AssemblyKeyName instead.

Joe K.

"Patrick" <> wrote in message
> To be brutally honest, I'm still new to VB and this is a little above me.
> After digging around on MS's site, I added the lines:
> Option Explicit On
> Imports System.Reflection
> <Assembly: AssemblyKeyFile("smsupdate.snk")>
> To the top of my code (seems to be correct (no blue lines ;)) - but no
> matter where I put smsupdate.snk - the program can't seem to find it when
> trying to build - that's my new issue.
> I feel comfortable with anything about this program, but I've spent more
> time trying to get the program to run from a share than actually putting
> it
> together - this is a little too much at this point for me. I understand
> inherited permissions, rights, roles, most everything about AD, NT,
> Novell,
> whatever permissions, but now having to deal with inherent file
> permissions
> is too much for my brain.
> However, no matter what I do, I know the first time is the worst/hardest,
> so
> I need to figure this out, so thanks for your time!
> "Nicole Calinoiu" <calinoiu REMOVETHIS AT gmail DOT com> wrote in message
> news:uRT7Qd4tEHA.1176@TK2MSFTNGP11.phx.gbl...
>> What are these instructions that you are following? Is there some
> specific
>> problem that you're having adding the AssemblyKeyFile and AssemblyVersion
>> attributes?
>> "Patrick" <> wrote in message
>> news:eGIj5R3tEHA.820@TK2MSFTNGP12.phx.gbl...
>> > Hello - after completing a simple app and finally getting it right, I
> put
>> > the app on a network share for others to test. Well, you know the rest.
>> > Doesn't work with a System.Security.Permissions.SecurityPermission
> error.
>> > I
>> > found out about the .NET administrative tool to create an MSI and it
> works
>> > if I apply that to a system before I run the app. The notes about
> security
>> > using it this way have me spooked, though.
>> >
>> > I would like to add a strong name to my app, and have run and created a
>> > key
>> > using sn -k myappname.snk
>> >
>> > But the instructions say to add an AssemblyKeyFileAttribute to your
>> > assembly, and this points to the snk file. I also need the
>> > AssemblyVersionAttribute. This is driving me crazy - 3 days to develop
> the
>> > solution, 5 days to get the app to work on our Network. I'm pretty new
> to
>> > this, and this is probably the most deflating part...
>> >
>> >