deployment of a .NET DLL

G

Guest

Hell

I find with .NET it is so easy to create class libraries and user control projects and build them as DLLs, and reference them, that I am doing it as a matter of course
But what is the method of deploying a DLL that is created with .NET (say a class library or a windows control library) and needs to be used by an application
If this was VB6, it would be a COM object so I would have to make sure it was regserver-ed. If it was C++, it would be a windows DLL, so I would have to make sure it was in the same directory as the application or the system directory
But what if it's neither a Win32 DLL nor a COM dll - just a ".NET" DLL?
 
B

Bob Powell [MVP]

..NET assemblies (dll's) can be deployed in two ways.

Either distributed with the application (exe) and copied to the same
directory as the application (XCopy deployment) or strongly named and signed
with a cryptographic key and placed in the Global Assembly Cache using the
gacutil.exe utility. If your DLL is going to be used by a number of
different applications, the latter method is probably preferable.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Image transition effects, automatic persistent configuration and
design time mouse operations all in April's issue of Well Formed
http://www.bobpowell.net/wellformed.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://royo.is-a-geek.com/siteFeeder/GetFeed.aspx?FeedId=41





songie D said:
Hello

I find with .NET it is so easy to create class libraries and user control
projects and build them as DLLs, and reference them, that I am doing it as a
matter of course.
But what is the method of deploying a DLL that is created with .NET (say a
class library or a windows control library) and needs to be used by an
application.
If this was VB6, it would be a COM object so I would have to make sure it
was regserver-ed. If it was C++, it would be a windows DLL, so I would have
to make sure it was in the same directory as the application or the system
directory.
 
G

Guest

What if I'm not approved by microsoft - can I still 'sign it with a cryptographic key'

If not, will putting it in the same directory as the EXE make it work?
 
G

Guest

1) Is there a simple tutorial on using gacutil.exe

2) Can gacutil.exe be made to work with Inno setup creator

3) Does installing the .NET framework mean that you've got gacutil.exe?
 
G

Guest

Does it require you to change the reference to the release version when building a release version of the program?
 
B

Bob Powell [MVP]

You can generate a key using the SN utility. You don't need to be approved
by anyone. The Strong Name system just enables a specific DLL to be uniquely
identified by information such as a unique key, name and version number.
This enables you to have side-by-side installs of different versions of an
assembly.

Putting an unsigned DLL in the same directory as the executable will make
the .exe find it first.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Image transition effects, automatic persistent configuration and
design time mouse operations all in April's issue of Well Formed
http://www.bobpowell.net/wellformed.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://royo.is-a-geek.com/siteFeeder/GetFeed.aspx?FeedId=41
 
B

Bob Powell [MVP]

1. http://samples.gotdotnet.com/quickstart/howto/doc/gac.aspx

2. Dont know. Sorry

3. Yes. Gacutil is provided in the .NET framework SDK as is the SN utility.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Image transition effects, automatic persistent configuration and
design time mouse operations all in April's issue of Well Formed
http://www.bobpowell.net/wellformed.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://royo.is-a-geek.com/siteFeeder/GetFeed.aspx?FeedId=41
 
B

Bob Powell [MVP]

Does it require you to change the reference to the release version when
building a release version of the program?

No.

If you're building with Visual Studio you can have the IDE build a strongly
named DLL for you by setting the appropriate values in the AssemblyInfo.cs.
Look at the comments in that file for a greater understanding.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Image transition effects, automatic persistent configuration and
design time mouse operations all in April's issue of Well Formed
http://www.bobpowell.net/wellformed.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://royo.is-a-geek.com/siteFeeder/GetFeed.aspx?FeedId=41





songie D said:
Does it require you to change the reference to the release version when
building a release version of the program?
 
S

songie D

1. http://samples.gotdotnet.com/quickstart/howto/doc/gac.aspx

2. Dont know. Sorry

3. Yes. Gacutil is provided in the .NET framework SDK as is the SN
utility.

Is it redistributable? What I'm getting at, is that Inno is the method I
would
be using to deploy my C# program as it has quite powerful features.
So, would I be able to put gacutil.exe in my package, and configure it
such that it would extract the .NET framework, install that, then extract
gacutil.exe, and then subsequently cause it to install the DLL?
i.e. more a question of would I be allowed to, I'm sure I could work out
how to. Surely others have run into this problem, is there not a good
documented
method or anything? I'll check the website you gave me though...

And how do I 'strongly name' the DLL? (using 'SN' utility? how do I access
that?)
 
S

songie D

Is this like the difference between late binding and early binding in VB6?
Except it's set at the building-of-the-DLL level?
I think it just sounds simpler to have it in the same directory as the app -
after all I don't want to get into a strange bootstrapping process when
installing it on the user's pc...
 
B

Bob Powell [MVP]

Hi,
You don't need to redistribute gacutil because the .net framework, which has
that in it, must be installed before you install your application.

The deployment project in Visual Studio has the ability to install
assemblies into the GAC for you. Right click the "File System On Target
Machine" root node and select "Add Special Folder" then select "Global
Assembly Cache Folder"

The installer will automatically place the DLL in the GAC for you.

To strongly name the DLL, create a key by running the Visual Studio Command
Prompt which can be found in the VS menu in your start bar. Use the command
line:

sn -k <keyfile>.snk

A key file will be generated..

Then, in the AssemblyInfo.cs file, edit the assembly: AssemblyKeyFile entry
to include the path to your key file. such as..

[assembly: AssemblyKeyFile("c:\mykeyfile.snk")]

The DLL will be built as a signed assembly.

There is a great guide to this in MSDN which you can find online or in the
Visual Studio help called "Creating and Using Strong-Named Assemblies"

--
Bob Powell [MVP]
Visual C#, System.Drawing

Image transition effects, automatic persistent configuration and
design time mouse operations all in April's issue of Well Formed
http://www.bobpowell.net/wellformed.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://royo.is-a-geek.com/siteFeeder/GetFeed.aspx?FeedId=41
 
B

Bob Powell [MVP]

Installing the DLL in the same directory as the executable is by far the
simplest scenario.

Installation in the GAC is useful when a single DLL serves for many
applications and requires strict version management.

DLL's whether in the application directory or in the GAC are all "early
bound". That is to say that the compilation process must have access to the
reference of the DLL and the specific version does matter even though you
might be able to configure the application to use a different version later.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Image transition effects, automatic persistent configuration and
design time mouse operations all in April's issue of Well Formed
http://www.bobpowell.net/wellformed.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://royo.is-a-geek.com/siteFeeder/GetFeed.aspx?FeedId=41
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top