.snk File

S

Scott M.

After using the sn.exe tool (or using VS 2008) to generate a strong name key
file and associating my assembly with that strong name, what should I be
doing with the actual .snk file? Do I deploy that?

-Scott
 
M

Mr. Arnold

Scott M. said:
After using the sn.exe tool (or using VS 2008) to generate a strong name
key file and associating my assembly with that strong name, what should I
be doing with the actual .snk file? Do I deploy that?


You have to deploy the file with the application, otherwise, the file is not
going to be there when the application looks for it.
 
J

Jeff Winn

Hey Scott,

No you don't distribute the snk file with your application. It's used for
signing assemblies to create a strongly named assembly, nothing more. If you
start distributing your key file with your application - anyone would have
access to your key and be able to create strong named assemblies using your
key, which would be bad.

Here's a link for some basic information about strong naming assemblies.
Perhaps it will give you some more insight on what they're used for:
http://msdn.microsoft.com/en-us/library/wd40t7ad(VS.71).aspx

If you're delay signing your assemblies this will give you more information
on it, however you still shouldn't be distributing your key file:
http://msdn.microsoft.com/en-us/library/t07a3dye.aspx

- Jeff
 
M

Mr. Arnold

Scott M. said:
Where on the production machine should the .snk file be deployed to?

I take that back. You don't have to deploy the .snk file.

I have only used the .snk file a couple of times, but that was during the
compile of a 3rd party business framework that used the .snk file during
compilation in the assembly manifest where the manifest pointed to the .snk
file, to make it a strong named assembly.

Once the assembly has been compiled using the .snk, then it's a strong named
assembly and you don't deploy the .snk file with the binaries.

Sorry for the miss information.
 
M

Mr. Arnold

Scott M. said:
Where on the production machine should the .snk file be deployed to?

Oh, one other thing, if the assembly has to be strong named, it needed to be
deployed to a production machine and you didn't use the sn.exe tool for the
assembly, then you use the Gacutil.exe tool to place the binary in the
Global Assembly Cache of the machine. All assemblies place in the GAC are
tagged as a strong named assembly.
 
S

Scott M.

I don't think that's quite right. All assemblies in the GAC must be strong
named. This is how we avoid versioning conflicts.
 
M

Mr. Arnold

Scott M. said:
I don't think that's quite right. All assemblies in the GAC must be strong
named. This is how we avoid versioning conflicts.

You are correct on the strong named part, but I think the assembly
publictokenkey is what makes things unique where you can use an assembly
redirect in the web or app.config pointing to various version of the same
named assembly in the GAC. Maybe the sn.key is part of pt.key
 
S

Scott M.

The .snk contains a public/private key pair. For any assembly to be in the
GAC it must be stong named using this pair. If you redirect via your
..config files to another assembly in the GAC, that assembly will still have
to be strong named. If you point to a private assembly is doesn't (but
still could be).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top