custom server control deployed for multiple site on server

Please let me know if this is the wrong spot to be asking this.

I'm building a dynamic CMS solution where one set of code will host multiple sites and content will be based on the DB.  Each site will have some specific information for that site and a admin site where they control the content. Very similar to a standard CMS solution.  Where I think this is different is most of the content will be custom server controls that will act like widgets on the site.  Client will be able to place them where they want from the admin and it will save this to the db.

 My problem is this: 

 I have a custom server control library that i'm building.  These controls will span across multiple site that I have on my server.  I have read that in order to do this I will have to add them (custom server controls) to the GAC with version number and namespace info.  When i create a site for a new client i plan on initially adding the reference to the costom controls.  My problem will be when i want to update a control or add a new one.  How will i be able to add/update the the reference in the existing sites?

 I guess i'm asking couple of questions

1)  from an architectural stand point is this the best option trying to be as dynamic as possilbe for multiple sites using one code base?

2)  Is there a method for adding references into the web.confi file which replaces the default namespace imports in the .cs files?

3)  How can i add a reference to a dll not using the Visual Studio interface? 

 Any help or ideas are greatly appreciated.

 thanks,

0
horromth
2/4/2008 7:00:14 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

7 Replies
675 Views

Similar Articles

[PageSpeed] 7

If you use GAC, you will use SN(strong name) for the version, and if you did not change the sn, you can just install / uninstall your dll.

If you change the SN, you will replace all website which make reference.

Hopes it will help you.


Don't forget to click "Mark as Answer" on the post(s) that helped you.
0
TonyDong
2/4/2008 9:00:42 PM

TD, thanks for the reply.  I think i am using a SN for my dll going into the GAC. I have a keyfilename attribute in the assemblyinfo and have placed that .snk file in the location of the project obj dir for the building of the dll.  I was under the understanding that once i did this and placed the dll into the GAC I would be able to either use a fully quailfied name in my code so that i would not have to put a referenece to the dll.  Is this correct?  Also when i do try and put a reference to the dll in the GAC i can't seem to find it?   The only ways i have been sucessful in referencing the dll is either put in my bin directory or put in the "C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5" directory.  Any help on why this would be the case?

 

thanks,

tom

0
horromth
2/4/2008 9:40:49 PM

 

You can put your dll in any directory, after you add it into GAC, you also can reference it from the directory you saved it. the only different is this time, the project did not copy this dll into bin folder
Don't forget to click "Mark as Answer" on the post(s) that helped you.
0
TonyDong
2/4/2008 9:54:03 PM

can you elaborate on this concept that once I put the dll in the GAC i can place it in any directory for the reference.  I understand and have used the add reference in VS and can point to any dll in a folder structure for the reference.  But how does it know that I want the GAC version and not the one on file?  Also you mentioned it would not save to my bin directory if i did place in the GAC but i look and I can see the dll in my bin after doing a reference.  I have to admit I'm a bit confused.  I'm not sure if i'm compiling correctly for the GAC or if its something else.  Is there a way to test to make sure the dll in the GAC is being read properly or can be read for that matter?  Thanks again for all your help. 

0
horromth
2/5/2008 1:51:40 AM

Step 1 

Creating an assembly key file

sn -k StrongNameFile.snk
 
Step 2 
Write/Edit your assembly
 
using System.Reflection;

[assembly:AssemblyKeyFile("StrongNameFile.snk")]

Step 3 

Adding your assembly to your GAC

gacutil /i AssemblyFileName.dll
//uninstall 
gacutil /u AssemblyFileName

And then you can make reference for your dll, it should works.

Or:

Step 4

Adding your assembly machine.config

<add assembly="AssemblyFileName, Version=0.0.0.0, Culture=neutral, PublicKeyToken=5edf592a9c40680c" />
Step 5 
%@Import Namespace="your dll namespace"%
 
 

Q: can you elaborate on this concept that once I put the dll in the GAC i can place it in any directory for the reference. 

 A: No, You have a directory to save your dll, and than add it to GAC

 

 

Q: I understand and have used the add reference in VS and can point to any dll in a folder structure for the reference.  But how does it know that I want the GAC version and not the one on file? 

A: Because you register it on GAC and call it with SN, so it is know. 

 

Hopes it make clear.
 

Don't forget to click "Mark as Answer" on the post(s) that helped you.
0
TonyDong
2/5/2008 2:07:47 AM

I followed those steps and it reads the dll now.  One thing that is not happening that I thought the whole purpose of having the dll in the GAC is when I make a change to the custom dll and build that project my site is not reflecting those changes?  I'm having to go through the whole process of creating new key file and the setup above for the reference.  I'm wanting not to have to touch my websites references or have to rebuild at all. Is this possilbe or am i going down the wrong path?

 

thanks 

0
horromth
2/5/2008 4:32:27 AM

haha, this is why I wrote the uninstalll function for you.

 

After you change your dll,  the only simple thing you need to do is uninstall your dll from GAC and install your new dll, everything will be fine.

So you don't need to touch your websites references or rebuild the website, the only build is your dll and reinstall it.

 

Regards,


Don't forget to click "Mark as Answer" on the post(s) that helped you.
0
TonyDong
2/5/2008 6:53:15 PM
Reply: