473,385 Members | 1,944 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,385 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 2820
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.