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 / June 2004

Tip: Looking for answers? Try searching our database.

Q: Referencing shared assembly in your project

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jiho Han - 09 Jun 2004 15:08 GMT
I have a set of assemblies that are shared by a number of
applications(ASP.NET).  I signed the shared assemblies using SN.  I would
register them in the GAC in production but I was wondering if I need to do
the same when I'm developing.
Basically, do I need to install the shared assemblies in my workstation's
GAC as well?  Or is there another way to reference them without utilizing
the GAC while developing?

Thanks much.
Jiho
Jacek - 09 Jun 2004 17:14 GMT
Hi Again!

You can use DEVPATH option in machine config file for using shared
assemblies outside of GAC.

<configuration>
  <runtime>
     <developmentMode developerInstallation="true"/>
  </runtime>
</configuration>

Check MSDN for DEVPATH keyword and other details.

Jacek

> I have a set of assemblies that are shared by a number of
> applications(ASP.NET).  I signed the shared assemblies using SN.  I would
[quoted text clipped - 6 lines]
> Thanks much.
> Jiho
Jiho Han - 09 Jun 2004 18:35 GMT
Dude you rock!

In any case, do you think that the runtime searches the GAC first and then
the DEVPATH or the reverse?(assuming it still does search the GAC for some
things)
I guess I could test it but thought I'd ask anyway.

Thanks a lot!

> Hi Again!
>
[quoted text clipped - 21 lines]
> > Thanks much.
> > Jiho
Jiho Han - 09 Jun 2004 19:26 GMT
Umm.. then I found this blog:

http://blogs.msdn.com/suzcook/archive/0001/01/01/57238.aspx

so maybe DEVPATH is not a good idea...

> Hi Again!
>
[quoted text clipped - 21 lines]
> > Thanks much.
> > Jiho
Jacek - 09 Jun 2004 22:38 GMT
Well, I do agree and disagree in this same time with Suzanne. What you do
depends on development environment you work with.
If you are on a small team and rather would not run into dll hell
(versionning skiping) just pick it but working on large dispersed teams
would rather mean forget it.

Still there is simple hack ;) to bypass full signing of assemblies before
installing them in GAC. Just create unsigned or delay signed version with
SkipVerification Security ActionAttribute set on assembly and simply copy
them using console into right directory in GAC (simple batch script would do
work for large projects). The directory should already exist for given
assembly. Framework will not check for their validity anymore - so they will
be in GAC with full versioning support (version inidicated by GAC
directory).

Hope this helps.

Jacek

> Umm.. then I found this blog:
>
[quoted text clipped - 31 lines]
> > > Thanks much.
> > > Jiho
Jiho Han - 09 Jun 2004 23:19 GMT
I was planning to use the delaysign facility from the get-go since besides
the hack you provided, there is that added benefit of having only certain
individuals maintain the private key(the main reason for me).

However, what I would really want is not to have to use GAC at all even in
the production.  Here's my situation:

I am developing add-ons to an already existing ASP.NET application.  The
application is a website in itself and my add-ons would simply be subfolders
underneath the app root.  I would rather not have to create virtual folders
for each of my add-ons if I don't have to.  The structure of my add-ons is
that there is a single folder underneath the app root so that all my add-ons
are located nicely in a single folder from the perspective of the
application.  The folder would contain common files, resources, pages,
assemblies for those pages in its own bin folder.  Then there would be
subfolders underneath that for each add-ons.  The add-ons would themselves
have their own files, resources, pages, assemblies for those pages in its
own bin folder.  Normally, ASP.NET would only look for assemblies in the
application root's bin folder.  I added <probing> element in web.config to
get around this so that the ASP.NET runtime now finds my assemblies in
folders other than the application bin folder.  The only problem is that
this does not affect the ASP.NET compilation step, meaning the codebehind
base class which derives from Page and the assembly that contains it, must
still be found in the application bin folder since that is the only place
ASP.NET will look when compiling your <pagename>.aspx.  That means I have to
put all those assemblies in the application bin folder.  So why is this a
problem?

We come back to the versioning issue - and perhaps the reason I need to use
GAC after all (YUCK!).  If I deployed, let's say, 5 add-ons to a particular
app, and later find that I need to update the common platform assemblies
(add-on specific assemblies are ok since they won't collide with each other
anyway because of their names(even the short) will differ. i.e.
Com.Infinity.App.Addon1.Web).  This may happen when you make some changes to
one of the add-ons and while you're at it make changes to the common
platform to support new features, changes, etc.  This happens and while you
try not to break any dependencies, sometimes it's unavoidable.  If I could
put my assemblies in other than application bin folder, then, by simply
configuring my web.config, I can put the newly updated platform assemblies
in the particular add-on's bin folder so that it only affects that add-on
and leave the other 4 add-ons functioning.  Now, leave any arguments
regarding my update schemes, assembly versioning faux pas, etc. aside for a
moment.  Being able to specify different location for assemblies for each
subfolder would be nice nonetheless - a la web.config.  AND it should use
that location for both compile time and runtime.  As it is implemented
currently, the only way to do that with ASP.NET is to use the GAC.

Sorry about the rant.
You've been very helpful!

> Well, I do agree and disagree in this same time with Suzanne. What you do
> depends on development environment you work with.
[quoted text clipped - 51 lines]
> > > > Thanks much.
> > > > Jiho
Roger Tan [MSFT] - 19 Jun 2004 00:55 GMT
Jiho, I think I have a solution that might fit the bill. I am in no ways an
ASP.NET guru, or even power user, but I played around with it, and this
seems to work:

In the web.config, do something like:

<configuration>
 <system.web>
    <compilation>
    <assemblies>
        <add assembly="SomeFile, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=xxxxxxxxxxxxxxxx" />
    </assemblies>
    </compilation>
 </system.web>

 <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="SomeFile" publicKeyToken="xxxxxxxxxxxxxxxx" />
            <codeBase version="1.0.0.0" href="subdir/SomeFile.dll" />
        </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

There are two parts to this. The first part, the ASP.NET specific config
section, says "add this assembly to the list of assemblies we need." The
second part is a general-runtime section, saying "if you're looking for
this file, this is where to find it."

With this solution, you can strongly sign your files w/o going through the
GAC, and using web.config, making everything less of a headache.

Hope that helps!

Rate this thread:







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.