Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / November 2004

Tip: Looking for answers? Try searching our database.

Basic GAC question...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul Mason - 26 Nov 2004 12:55 GMT
Hi folks,

I was under the impression that once you had loaded an assembly into the
GAC, that you didn't have to make specific reference calls to the assembly
in another assembly.  I was under the impression that this was the way you
extended the .net framework.

I've just done a little test a put a very basic assembly into my local GAC.
All well and good, but I can still only manually reference i.e. provide a
physical path and filename, the DLL to get to it's contents.  So what
exactly does the GAC do if it doesn't serve as a central repository for ones
assemblies.  I know it says it's there for when we want to share assemblies,
but how is this done when we still have to make a manual reference?

More to the point, if I am making manual references I'm still subject to the
same old cock up factor.  Either I'm barking up the wrong tree or I'm
missing some sort of flag or declaration.

To be a bit clearer this is the kind of code I'm trying to achieve, without
making a manual reference to MyTest.DLL.

imports MyTest.CRCTU.Test

public class bla bla...form declaration

   Private Sub btnTestGAC_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnTestGAC.Click

       Dim objtest As New clsTest1
       Dim result As Integer

       objtest.InputNumber = 5
       result = objtest.OutputNumber

       MsgBox(result.ToString)

   End Sub

end class

where clsTest1 resides in the namespace CRCTU.Test.

Thanks in advance for any replies...

Cheers...P
Richard Blewett [DevelopMentor] - 26 Nov 2004 13:38 GMT
If you put an assembly in the GAC then the runtime will be able to find it *when you ask for it by name* wherever you application is running from on the local machine.

The assembly name is not, say, foo.dll but rather "foo, version=1.0.0.0, Culture=neutral, PublicKeyToken=aabbccddeeff11223344".

There are two ways to ask for an assembly by name: explicitly using Assembly.Load(); implicitly by setting up a reference in the applicaiton's manifest. The latter is done in Visual Studio by adding a reference to the assembly in the "References" in the solution view. It is done from the command line using the /r: compiler switch.

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

  Hi folks,

I was under the impression that once you had loaded an assembly into the
GAC, that you didn't have to make specific reference calls to the assembly
in another assembly. I was under the impression that this was the way you
extended the .net framework.

I've just done a little test a put a very basic assembly into my local GAC.
All well and good, but I can still only manually reference i.e. provide a
physical path and filename, the DLL to get to it's contents. So what
exactly does the GAC do if it doesn't serve as a central repository for ones
assemblies. I know it says it's there for when we want to share assemblies,
but how is this done when we still have to make a manual reference?

More to the point, if I am making manual references I'm still subject to the
same old cock up factor. Either I'm barking up the wrong tree or I'm
missing some sort of flag or declaration.
Paul Mason - 26 Nov 2004 16:12 GMT
Hi,

Have you or anyone else got any examples of Assembly.Load being used.
Having tried it, I can't find any reasonable friendly way of landing up with
a variable typed as a class within one of these assembly e.g.

dim objMyClass as object

objA = [Assembly].load("assembly name etc")
???
objMyClass = ????
???
objMyClass.MyMethod

From what I've seen you have to jump through hoops using the GetTypes
method.  It looks like you land up with an object where you have to run the
lottery of late binding (something I avoid at all costs!).

Cheers...P

> If you put an assembly in the GAC then the runtime will be able to find it
> *when you ask for it by name* wherever you application is running from on
[quoted text clipped - 36 lines]
> same old cock up factor. Either I'm barking up the wrong tree or I'm
> missing some sort of flag or declaration.
Mattias Sj?gren - 26 Nov 2004 21:40 GMT
Paul,

>Having tried it, I can't find any reasonable friendly way of landing up with
>a variable typed as a class within one of these assembly

For that you need a compile time reference. Assembly.Load is used for
dynamicly loading assemblies.

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.