PC Review


Reply
Thread Tools Rate Thread

AssemblyKeyFile relative to?

 
 
Nak
Guest
Posts: n/a
 
      6th Sep 2003
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
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\


 
Reply With Quote
 
 
 
 
Nak
Guest
Posts: n/a
 
      6th Sep 2003
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
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\


 
Reply With Quote
 
Fergus Cooney
Guest
Posts: n/a
 
      6th Sep 2003
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.
==================================


 
Reply With Quote
 
Nak
Guest
Posts: n/a
 
      6th Sep 2003
> 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
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      7th Sep 2003
Hello,

"Fergus Cooney" <filter-(E-Mail Removed)> 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



 
Reply With Quote
 
Kevin Yu
Guest
Posts: n/a
 
      8th Sep 2003
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."

 
Reply With Quote
 
Nak
Guest
Posts: n/a
 
      8th Sep 2003
> 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
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\


 
Reply With Quote
 
Norm Dotti
Guest
Posts: n/a
 
      9th Sep 2003
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-(E-Mail Removed) (Kevin Yu) wrote in message news:<#(E-Mail Removed)>...
> 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."

 
Reply With Quote
 
Kevin Yu
Guest
Posts: n/a
 
      10th Sep 2003
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."

 
Reply With Quote
 
Norm Dotti
Guest
Posts: n/a
 
      10th Sep 2003
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-(E-Mail Removed) (Kevin Yu) wrote in message news:<(E-Mail Removed)>...
> 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."

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Digital Signing...Error Using Relative Path For AssemblyKeyFile Vahehoo Microsoft ASP .NET 0 1st Apr 2007 04:41 AM
Error Using Relative Path For AssemblyKeyFile gowens@nixonpeabody.com Microsoft VB .NET 1 28th Jul 2005 01:46 AM
AssemblyKeyFile Attribute Ram Microsoft C# .NET 1 2nd Feb 2005 09:14 AM
AssemblyKeyFile Ram Microsoft VB .NET 0 2nd Feb 2005 09:01 AM
AssemblyKeyFile attribute George Durzi Microsoft Dot NET Framework 1 5th Feb 2004 11:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:16 PM.