Does anyone know what path the AssemblyKeyFile attribute is relative to?
For example I currently have mine set to
<Assembly: AssemblyKeyFile("..\NicksKey.snk")>
Sometimes this works, and sometimes I need to change it to
<Assembly: AssemblyKeyFile("..\..\NicksKey.snk")>
Which could only mean that sometimes it is relative to the projects root
and sometimes it is relative to the compiled executable. I'm looking around
on the web for this one too, but does anyone else know what it is relative
too? I only want to have 1 copy of the snk file, hence using a relative
path, and I didn't want to use the full path (Even though I might have to).
Thanks again!!
Nick.
--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."
Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
No answer, just my own question - what's a .snk file ? Nothing sneaky, I hope, lol.
Regards,
Fergus
==================================
Call that code? That's not even pseudo code!!
I'm telling Jack on you.
He'll have something to say about it, that's for sure.
==================================
Hi Fergus,
It's something quite interesting that means that my assembly's are going
to be a damn sight more secure from crackers than they were before! It's a
"strong named key" file,
http://www.ondotnet.com/pub/a/dotnet/2003/04/28/strongnaming.html
I found this URL on the web while looking up RSA encryption again and
was quite suprised that I hadn't found out about it before. It's worth
having a look at and if you plan on distributing software, use it!
especially if you want to sell it! Seems like quite a good site that one
:-)
"Fergus Cooney" <filt...@tesco.net> schrieb:
> No answer, just my own question - what's a .snk file ? Nothing
> sneaky, I hope, lol.
AFAIK "SNK" = "Strong Name Key". A SNK file can be created with the
"Sn.exe" utility. Have a look at the docs for "Strong Name" for more
information.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
The path for the AssemblyKeyFile attribute is relative to the project
output directory. It means that it is relative to the path where the
generated .exe or .dll file exists. Generally, the .exe or dll file is put
in the projectfolder\bin\debug folder when debugging. So, if your strong
name key file have to be ..\..\strongnamekey.snk.
If anything is unclear, please feel free to reply to the post.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
Hi Kevin,
Thanks for the information, this is what I had presumed, but for some
reason I get told sometimes that my key cannot be found, even though it was
used successfuly last compile. The only way I can get around this is by
changing the path from
..\..\strongnamekey.snk
to..
..\strongnamekey.snk
or vise versa
This is strange because that means that sometimes it is relative to the
debug folder, this is and example of my directory layout,
strongnamekey.snk
project folder\
bin\compiled program.exe
obj\debug\compiled program.exe
Hence having to swap around sometimes. I have no problems with changing
the value when necessary but would just like to understand under what
circumstances that VB would make the key relative to the debug exe. Thanks
again for your advice.
Since we went from VS 2002 to VS 2003 I can not get a relative path to
work for this attribute in a web service project (it worked in 2002).
If I fully specify it it's ok, but if I try a relative it simply says
it cannot find the file specified. How do I get relative path to work
for a web service project?
v-k...@online.microsoft.com (Kevin Yu) wrote in message news:<#lleIagd...@cpmsftngxa06.phx.gbl>...
The location of the project output directory is dependent on whether you
are working with a local or web project. For local projects, the project
output directory is defined as <Project Directory>\obj\<Configuration>. For
example, if your KeyFile is located in the project directory, you would
specify the AssemblyKeyFile attribute as [assembly:
AssemblyKeyFile("..\\..\\mykey.snk")] For web projects, the project output
directory is defined as %HOMEPATH%\VSWebCache\<Machine Name>\<Project
Directory>\obj\<Configuration>.
Please check the folder to see if the strong name key file is there. If you
have already put the strong name key file there, would you please tell me
the error message when compiling?
Here's my directory structure:
e:\Solution\App\
|
|__Control Project
|
|__WinForm Project
|
|__WebService Project
|
|__Other Projects
My snk file resides in e:\Solution\App. All projects except the Web
Service one have the following in their AssemblyInfo file:
<Assembly: AssemblyKeyFile("..\..\..\App.snk")>
In VS2002 I simply had the following for the Web Service project:
<Assembly: AssemblyKeyFile("App.snk")>
and it worked fine. Since VS2003 I can't seem to do anything relative
AssemblyKeyFile attribute for the Web Service project. Absolutes work,
but not relatives. I have IIS set so that the default home directory
is e:\Solution. The Web Service project's VRoot local directory is set
to e:\Solution\App\WebService.
I did put the snk file in %HOMEPATH%\VSWebCache\<Machine
Name>\<Project
> Directory>\obj\DEBUG as you suggested. I still get the "can't find it" message. Is this a change from VS2002? Because it used to work.
Any ideas would be appreciated.
v-k...@online.microsoft.com (Kevin Yu) wrote in message news:<PYfxZi2...@cpmsftngxa06.phx.gbl>...
%HOMEPATH%\VSWebCache\<Machine Name>\<Project Directory>\obj\DEBUG is the
directory your AssemblyKeyFile attribute relative to. Generally, We put the
strong name key in the %HOMEPATH%\VSWebCache\<Machine Name>\<Project
Directory>\
Please take a look at the AssemblyKeyFile attribute. It has to be
<Assembly: AssemblyKeyFile("..\\..\\App.snk")>, if your key file is put in
%HOMEPATH%\VSWebCache\<Machine Name>\<Project Directory>\ Note that you
have to use double “\” in the string.
If you put the key file in %HOMEPATH%\VSWebCache\<Machine Name>\<Project
Directory>\obj\DEBUG, the attribute has to be set as <Assembly:
AssemblyKeyFile("App.snk")>.
v-k...@online.microsoft.com (Kevin Yu) wrote in message news:<R#66jYBeD...@cpmsftngxa06.phx.gbl>...
Hi there,
I understand exactly what you mean about have 2 copies of the snk file.
I think it is a security risk to have more than one. As well as being much
easier to backup your data if it is all in 1 path.
Actually, you only need to maintain one copy of the key file, just put it
under the folder %HOMEPATH%\VSWebCache\<Machine Name>\<Project Directory>\.
Another one in the project folder is not required.
v-k...@online.microsoft.com (Kevin Yu) wrote in message news:<JQqlAxNe...@cpmsftngxa06.phx.gbl>...
You don't need to hardcode them in your program.
%HomePath% can be got as
System.Environment.GetEnvironmentVariable("HomeDrive") +
System.Environment.GetEnvironmentVariable("HomePath")
And MachineName as System.Environment.MachineName.
However, I recommend you use relative path instead. It could be
"..\\..\\App.snk"
Please tell me how to provide a relative, non-machine/user dependent
path for all my project types that point to the same snk file. I don't
see how this is possible.
v-k...@online.microsoft.com (Kevin Yu) wrote in message news:<CdbWnpze...@cpmsftngxa07.phx.gbl>...
Hi there,
A path is only "relative" to another path if it is on the same drive.
So if the snk file is on another drive you would not be using a relative
path, but the exact path. I can't see how you could do it any other way if
the file is contained on another drive, more to the point, why would you
want to? Or is it not even picking it up on another drive?, mine looses the
key file every now and then and I have to restart VB to get it to find it
again! :-)
Visual Studio .NET will not search for the strong name key file under the
project folder but under the VSWebCache folder when you're working on a web
service project. So you have to copy a key file to the VSWebCache folder to
get a relative path.
If you want to keep your private key file safe and only want to maintain
one copy of the strong name key file for all the projects, you can use
Delay Signing. Delayed signing at build time allow you to reserve space in
the portable executable (PE) file for the strong name signature, but defer
the actual signing until some later stage (typically just before shipping
the assembly).
Please refer to the following link for more information:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpcondelayedsigningassembly.asp
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
--------------------
| From: no...@knorrassociates.com (Norm Dotti)
| Newsgroups: microsoft.public.dotnet.languages.vb
| Subject: Re: AssemblyKeyFile relative to?
| Date: 15 Sep 2003 06:19:53 -0700
| Organization: http://groups.google.com/
| Lines: 28
| Message-ID: <219f4ebc.03091...@posting.google.com>
| References: <OiYRRmG...@TK2MSFTNGP10.phx.gbl>
<#lleIagd...@cpmsftngxa06.phx.gbl>
<219f4ebc.03090...@posting.google.com>
<PYfxZi2...@cpmsftngxa06.phx.gbl>
<219f4ebc.03091...@posting.google.com>
<R#66jYBeD...@cpmsftngxa06.phx.gbl>
<219f4ebc.03091...@posting.google.com>
<JQqlAxNe...@cpmsftngxa06.phx.gbl>
<219f4ebc.03091...@posting.google.com>
<CdbWnpze...@cpmsftngxa07.phx.gbl>
| NNTP-Posting-Host: 67.85.172.14
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1063631994 6408 127.0.0.1 (15 Sep 2003
13:19:54 GMT)
| X-Complaints-To: groups...@google.com
| NNTP-Posting-Date: 15 Sep 2003 13:19:54 GMT
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA06.phx.gbl!TK2MSFTNGXA0
5.phx.gbl!TK2MSFTNGP08.phx.gbl!news-out.cwix.com!newsfeed.cwix.com!prodigy.c
om!pd2nf1so.cg.shawcable.net!residential.shaw.ca!sn-xit-03!sn-xit-01!sn-xit-
08!sn-xit-09!supernews.com!postnews1.google.com!not-for-mail
| Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.vb:137012
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb