473,545 Members | 937 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2832
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 "Administra tive 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********@ear thlink.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.c s 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
1753
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 loading several versions of the DLLs, resulting in Invalid Cast Exceptions. A solution which was suggested to me was to make sure all my...
2
1558
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 named. I have registered the main DLL, which references the other DLLs, to the GAC cache. I have built a plug-in for a third party application with...
14
2563
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. Following is the example to reproduce it. I have a C++ project (mixed dll, managed and unmanaged), with classes: EncodeDecode.cpp, EncodeDecode.h,...
4
2320
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 (private assemblies). My goal is that once I have deployed App.exe, I want to deploy a bugfix
2
1344
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
1183
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. I am fail running the project and the error is encountered at the line "InitializeComponent" in the form, claiming that some dependency is missing.
2
2430
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 end that they first statements bring up in my mind... a) Because two developers, unbeknownst to each other, can end up releaseing different...
10
2720
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. The service application references the DLLs. The service app also has an installer class that is set up to run as a custom action in the Setup...
32
2515
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 why is it different from = ?
0
7467
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7419
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7756
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5326
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4944
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1879
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
703
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.