473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

AssemblyKeyFile relative to?

Nak
Hi there,

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
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #1
18 9407
Nak
I also believe that this *may* only be happening with 1 project, the project
is in a solution with 1 other project. I can't replecate when it will
require either path as yet, but I'm sure there must be an explanation for
it.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #2
Hi Nick,

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.
==================================
Nov 20 '05 #3
Nak
> No answer, just my own question - what's a .snk file ? Nothing sneaky,
I hope, lol.

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...ongnaming.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
:-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #4
Hello,

"Fergus Cooney" <fi******@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

Nov 20 '05 #5
Hi Nick,

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."

Nov 20 '05 #6
Nak
> 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.


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.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #7
Kevin,

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-****@online.microsoft.com (Kevin Yu) wrote in message news:<#l*************@cpmsftngxa06.phx.gbl>...
Hi Nick,

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."

Nov 20 '05 #8
Hi Norm,

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?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 20 '05 #9
Kevin,

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-****@online.microsoft.com (Kevin Yu) wrote in message news:<PY*************@cpmsftngxa06.phx.gbl>... Hi Norm,

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?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 20 '05 #10
Hi Norm,

%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")>.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 20 '05 #11
It does work now. This is a bit of an inconvenienve though. I've got
my application directories and files on my E: drive yet it's got to
looks on my C: drive as the relative start position for web service
apps? I wish they hadn't changed this. I don't want to have to keep
two copies of the snk file. I can't seem to point to the same one
though (in a relative manner). I don't want to hard code it because
not all machines have the same drive mappings. Any other ideas?

v-****@online.microsoft.com (Kevin Yu) wrote in message news:<R#**************@cpmsftngxa06.phx.gbl>...
Hi Norm,

%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")>.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 20 '05 #12
Nak
> It does work now. This is a bit of an inconvenienve though. I've got
my application directories and files on my E: drive yet it's got to
looks on my C: drive as the relative start position for web service
apps? I wish they hadn't changed this. I don't want to have to keep
two copies of the snk file. I can't seem to point to the same one
though (in a relative manner). I don't want to hard code it because
not all machines have the same drive mappings. Any other ideas?


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.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #13
Hi Norm,

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.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 20 '05 #14
Are %HOMEPATH% and <Machine Name> treated as variables or do I need to
replace them with hardcoded values? It's not working as is.
v-****@online.microsoft.com (Kevin Yu) wrote in message news:<JQ**************@cpmsftngxa06.phx.gbl>...
Hi Norm,

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.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 20 '05 #15
Hi Norm,

You don't need to hardcode them in your program.

%HomePath% can be got as
System.Environment.GetEnvironmentVariable("HomeDri ve") +
System.Environment.GetEnvironmentVariable("HomePat h")

And MachineName as System.Environment.MachineName.

However, I recommend you use relative path instead. It could be
"..\\..\\App.snk"

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 20 '05 #16
I agree, relative path is the way to go. I've been trying to use
relative path all along. As you may recall ..\\..\\App.snk doesn't
work for the Web Service project. I have may apps on E: but the web
service's "home" relative start directory is on C:.

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-****@online.microsoft.com (Kevin Yu) wrote in message news:<Cd**************@cpmsftngxa07.phx.gbl>...
Hi Norm,

You don't need to hardcode them in your program.

%HomePath% can be got as
System.Environment.GetEnvironmentVariable("HomeDri ve") +
System.Environment.GetEnvironmentVariable("HomePat h")

And MachineName as System.Environment.MachineName.

However, I recommend you use relative path instead. It could be
"..\\..\\App.snk"

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 20 '05 #17
Nak
> I agree, relative path is the way to go. I've been trying to use
relative path all along. As you may recall ..\\..\\App.snk doesn't
work for the Web Service project. I have may apps on E: but the web
service's "home" relative start directory is on C:.


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! :-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Nov 20 '05 #18
Hi Norm,

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/de...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: <21**************************@posting.google.com >
| References: <Oi*************@TK2MSFTNGP10.phx.gbl>
<#l*************@cpmsftngxa06.phx.gbl>
<21**************************@posting.google.com >
<PY*************@cpmsftngxa06.phx.gbl>
<21**************************@posting.google.com >
<R#**************@cpmsftngxa06.phx.gbl>
<21**************************@posting.google.com >
<JQ**************@cpmsftngxa06.phx.gbl>
<21**************************@posting.google.com >
<Cd**************@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: gr**********@google.com
| NNTP-Posting-Date: 15 Sep 2003 13:19:54 GMT
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTN GXA06.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!s n-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
|
| I agree, relative path is the way to go. I've been trying to use
| relative path all along. As you may recall ..\\..\\App.snk doesn't
| work for the Web Service project. I have may apps on E: but the web
| service's "home" relative start directory is on C:.
|
| 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-****@online.microsoft.com (Kevin Yu) wrote in message
news:<Cd**************@cpmsftngxa07.phx.gbl>...
| > Hi Norm,
| >
| > You don't need to hardcode them in your program.
| >
| > %HomePath% can be got as
| > System.Environment.GetEnvironmentVariable("HomeDri ve") +
| > System.Environment.GetEnvironmentVariable("HomePat h")
| >
| > And MachineName as System.Environment.MachineName.
| >
| > However, I recommend you use relative path instead. It could be
| > "..\\..\\App.snk"
| >
| > Kevin Yu
| > =======
| > "This posting is provided "AS IS" with no warranties, and confers no
| > rights."
|

Nov 20 '05 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ram | last post by:
Hey, Whenever I add the "AssemblyKeyFile" attribute to a ClassLibrary project I created on my Win XP computer, the "Rebuild" take almost a minute! When I mark that line, the rebuild time is merely...
1
by: George Durzi | last post by:
Sorry to double post, but I figured I would get a better response here. Trying to assign a strong name to my assembly. I've created the .snk file for it. My assembly is called Common. Mail ...
1
by: Jarmo Muukka | last post by:
Hello, I started to use FxCop to check my assemblies. One requirement is a strong name key. Placing the .snk file for library projects was easy. I placed the file in project directory and in...
0
by: Ram | last post by:
Hey, Whenever I add the "AssemblyKeyFile" attribute to a ClassLibrary project I created on my Win XP computer, the "Rebuild" take almost a minute! When I mark that line, the rebuild time is merely...
1
by: gowens | last post by:
I've been trying to strong name my VB.Net v1.1 assembly with the strong name key that we're using for a project. The strongname.snk file is located in a root-level directory. No matter what I...
1
by: SenthilVel | last post by:
Hi I am in the Process of conversion of my existing 1.1 Dotnet Code to 2.0 framework. for each project when i compile in VS2005 , i get this error\warning: Use command line option...
4
by: SenthilVel | last post by:
Hi I am in the Process of conversion of my existing 1.1 Dotnet Code to 2.0 framework. for each project when i compile in VS2005 , i get this error\warning: Use command line option...
0
by: Vahehoo | last post by:
Hi, I am trying to digitally sign an old application in ASP.Net. For that purpose I created a Strong Name Key File. The snk file is located in a root-level directory. in Bin\DG_Key directory....
4
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, When using property assembly: AssemblyKeyFile in Visual Studio 2005, I find that it is not supported and we need to using Project --Properties --> Signing Tab to specify the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.