 |
| ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 19th, 2012, 12:52 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
|
|
Referencing DLLs from code
I have created a user control which I have compiled to DLL. The DLL is referenced by a score of different web applications. It is referenced by browsing to the DLL in a shared folder on the IIS server from the IDE for each project and then consumed by various pages.
I have since noticed that published folders on the IIS server each contain a copy of this DLL. This suggests that all of these programs will need to be republished every time this DLL changes to ensure the new DLL is copied to each application's production folder. And indeed, the projects in question appear to force me to drop and re-reference the DLL when it changes.
This seems counterintuitive - shouldn't all applications reference the same copy of the DLL in one shared folder via registration in the GAC? Isn't the purpose of using a DLL to avoid creating duplicate files that previously caused confusion when they did not match? Have I somehow incorrectly established the reference in some way that requires making a copy of the DLL in the applciaiton BIN ofolder?
|
|

October 19th, 2012, 03:01 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Quote:
|
shouldn't all applications reference the same copy of the DLL
|
It depends. By enabling applications yto have their own private copy you minimize DLL hell where an update of the assembly could potentially break many applications that use it.
Quote:
|
in one shared folder via registration in the GAC
|
Yes, it you want to share the same copy, the GAC is your answer. Register the assembly in the GAC and then make sure "Copy Local" is set to false for the reference oiin your VS project.
Cheers,
Imar
|
|

October 19th, 2012, 03:32 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
|
|
Ah - that's why it felt like the opposite side of DLL hell! I do not recall enabling this for any project so it must be the default setting.
Thanks for the clue, as always, Imar!
|
|

October 22nd, 2012, 04:27 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
|
|
Still struggling with this. No matter what I do, it will not allow me to add the new control to the existing project that worked before making this change. It keeps telling me it's not a .NET module. And I just compiled the control using .NET!
What could cause VS to think it is not a .NET module, particularly when I am able to load the old DLL from its location?
|
|

October 24th, 2012, 06:47 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
What type of DLL is it? A .NET Class Library? How do you add it? And have you added it to the GAC?
Imar
|
|

October 25th, 2012, 08:40 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
|
|
Thanks for the response, Imar!
The DLL is compiled from a .NET Web Control Library project containing a single public class consisting of a couple of labels and a few properties that can be set on the interface or at run time. I compiled it and copied the DLL to a shared folder on our IIS server. I then added it to the project via the Add References dialog box browse tab. Using Choose Items from the toolbox context menu I then browsed to the shared location and added the control to the toolbox. Dragging it from the toolbox to the page definition registered it for the page. It worked well enough this way, but made copies of the DLL in the BIN folder of every application referencing it this way.
This time, after copying the DLL to the shared location, I registered it on the server manually using GACUtil /if option from the cmd prompt. I also verified registration using the /l parm and the registered component appears only once. I again referenced the DLL with the consuming application from Add References. But when I try to Choose Items from the toobox, it tells me it's not a .NET module?
When
|
|

October 28th, 2012, 03:11 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
To be honest, I have no idea..... ;-)
Is the DLL you're adding to VS on your local machine? Did you add it to the GAC there as well?
Imar
|
|
 |