473,239 Members | 1,598 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,239 software developers and data experts.

Public Key Specification When Referencing A Strong Named DLL

Tom
My unsigned DLL works in my project that references it as long as I
set Copy Local = true.

Now I have signed the DLL with the sn.exe generated keys but have not
yet moved the DLL into the GAC.

Can I use a strong named DLL outside the GAC with Copy Local = false
by providing a reference to the public key?

If yes to above, please tell me how to reference the public key within
the IDE of the project that calls upon a signed DLL.

I am hopeful that there is a way to simply browse to the .snk file
within the IDE and auto generate the appropriate attribute within the
AssemblyInfo.cs file.

Thank you for any assistance.

-- Tom
Jul 30 '08 #1
1 2805
Tom
Hey folks --

I am now past baby step #1 in using the GAC and am hoping this follow
up posting might be of benefit to some that are new to using the GAC
for the first time.

Some of the instructional references I found suggested dragging the
DLL file into the proper GAC folder. Other references said to use the
Configuration tool. I tried each of these and they both failed. The
problem is you need to do *both* !! And why this is not emphasized
somewhere in the instructional documentation is beyond me. Perhaps
because it is so elementary? I don't know. From the perspective of a
first time GAC user, it seems to me that explanations should not
require this ever so tiny leap in understanding.

I now think of the configuration tool as the means of storing or
registering the public key, DLL name, hash, and version number (plus
additional information) into a database repository on the computer.

The placement of the DLL file itself is an obvious requirement too. It
needs to (or most safely "should") reside in a common directory ...
but certainly this is NOT the only step in the process.

Some texts talk of the need for policy files too. The default behavior
for a newly installed DLL is satisfactory. Policy files are for
maintenance and updating DLL components on older and established
applications. Don't let the policy file implications confuse the issue
when using the GAC for the first time ... just ignore them.

Additionally, there is the need for the calling application to
reference the public key created using the sn.exe utility. How this is
done appears to be different among the various .Net languages?
Fortunately, one C# text I have states that >"If you're using the
Visual Studio .NET IDE, public keys for strong-named assemblies are
automatically retrieved when you compile an application." I found this
to be true for VS2005. So ... don't let some of the Basic.Net
information found via a C# Google search confuse the issue.

Some texts also discuss "signing" and usage of Authenticode practices
in the same section as strong naming. This caused me to think during
the midst of several failed attempts that signing might also be
needed? Not true. Ignore signing when using the GAC for the first
time.

-------------------
So here is a step-by-step guideline for strong naming C# DLL
assemblies using VS2005 and placing them into the GAC:

1) Create you DLL project.

2) Debug it without signing by referencing it within a testing program
with a property setting of: Copy Local = true.

3) Right click on the project folder within the Solution Explorer and
select "Properties". Then select the "Signing" grouping and check the
"Sign the assembly" check box. Use the drop down menu to choose
"<New...>" and fill in the Key file name and optional password
protection fields. Note: There is no longer any need to use the
command line and the direct usage of the sn.exe utility.

4) Build a release version of your solution/project.

5) For prevention of accidental deletion ... use file explorer and
Ctrl-drag the .dll file found in the bin/release folder into a secured
folder. One such folder is the one containing the .Net classes. To
locate this folder ... examine the properties of an included .Net
reference class of your project. (For example: System.Data,
System.Windows.Forms, System.Drawing, etc.) Usage of two File Explorer
instances simplifies this task.

6) Open the registration tool using the following command:

Start Programs Administrative Tools Microsoft .NET Framework
2.0 Configuration

----------------------------------------
Note: In the above path, if the "Administrative Tools" selection is
not visible ... use the following path to check the appropriate check
box:

Start Settings Taskbar & Start Menu... Advanced (tab)
----------------------------------------

Expand the "My Computer" node and select the "Assembly Cash" node.
Right click "Assembly Cash" and choose "Add...". Then browse to the
..dll location to make the appropriate entry of the signed .dll file.

7) Return to the testing program and delete the old reference to your
unsigned dll and delete the files within the solution's bin directory.
You don't want a residual copy of the unsigned dll lingering around
and causing confusion. Add a new reference to your now signed dll.
Within the reference properties for the dll ... set >Copy Local =
false. Rebuild the test program. Note: Within C# there is no need to
reference the public key of the private/public key pair created and
stored in the .snk file. The .snk file should be visible within the
project folder of the signed assembly. Full functionality of the
testing program should be observed.

You can also reuse a previously created .snk file by browsing to it in
the above step #2 ... rather than using "<New...>". The .snk file is
just a simple file and can be stored in a convenient location. Perhaps
the safest location is in the GAC? -- however; I have not yet tested
storing the .snk within the GAC. You decide. Only when created locally
using "<New...>" will it be automatically placed in the project
folder.

================================================== ========

Hopefully the above step-by-step guidelines makes the signing of
assemblies an easier to learn task.

There are many more related topics to explore to automate the
inclusion of dll or other assemblies into the GAC. One area is that of
'Fusion' ... but I am not yet there. I am still building and running
my own dll's on my own computer. Commercial implementations require
some additional work.

I encourage 1'st time GAC users to clarify and improve upon the above
guideline. I hope the steps needed are more clearly expressed above
than the texts and online sources I found ... but having completed the
task with many failed attemps along the way ... I might have easily
missed an important step or two.

-- Tom

On Wed, 30 Jul 2008 13:58:36 -0500, Tom <Th********@earthlink.net>
wrote:
>My unsigned DLL works in my project that references it as long as I
set Copy Local = true.

Now I have signed the DLL with the sn.exe generated keys but have not
yet moved the DLL into the GAC.

Can I use a strong named DLL outside the GAC with Copy Local = false
by providing a reference to the public key?

If yes to above, please tell me how to reference the public key within
the IDE of the project that calls upon a signed DLL.

I am hopeful that there is a way to simply browse to the .snk file
within the IDE and auto generate the appropriate attribute within the
AssemblyInfo.cs file.

Thank you for any assistance.

-- Tom
Aug 1 '08 #2

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

Similar topics

4
by: Derrick | last post by:
Long story short: I've been working on a project which includes both designtime and runtime components, for both the PC and Pocket PC. While testing, I've been having problems with Visual Studio...
2
by: Jon Davis | last post by:
I have a full-blown application that consists of several (fifteen or so) assembly DLLs, each being a separate VS.NET project that outputs to the main DLL's bin directory. They are all strongly...
14
by: AAguiar | last post by:
Thanks for your replies. Last week, I continued working with this problem. Trying to reproduce the error, I developed a short example and found that the problem is related to strong name dll. ...
4
by: Stefan | last post by:
Hi, I have an application that consists of multiple strong-named assemblies like: App.exe references Utils.dll (for simplicities sake) All assemblies are strong-named, but not GAC'd...
2
by: SStory | last post by:
How can I strong name my assembly if it references 3rd part non-strong named dlls? I just want my part strong named--I don't care about their part. Thanks, Shane
6
by: AA | last post by:
Hi all, I have created a .Net control for myself, and put it inside the folder "framework\v1.1.4322". Then, I create a new project, reference the dll and draw the control on the window form....
2
by: Sky | last post by:
Hello: I'm trying to make sense of snk files, when to use, under what conditions to regenerate new ones,...can someone take a look if these statemes make sense? And then the final questions at the...
10
by: =?Utf-8?B?SmFjayBTbWl0aA==?= | last post by:
Hello, I have a solution that contains a C# application that is installed and runs as a service. The solution also contains several DLLs, some of which are C# assemblies and some are C++ DLLs. ...
32
by: Joe | last post by:
I am just starting to use Object Oriented PHP coding, and I am seeing quite often the following (this example taken from a wiki): $wakka =& new Wakka($wakkaConfig); What exactly is the =&, and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.