The circle of life – ** .Net – Training – MOSS **

  • Past Post

  • Vistor Locations

  • Advertisements

Where should WebPart assemblies live ?

Posted by Clayton James on April 29, 2007

I have had a few questions lately upon where the webpart assembly should live. Should it be in the:

  • _app_bin folder
  • bin folder
  • GAC

Moss 2007 has a new application folder named _app_bin. This folder was designed to hold application assemblies which were previously installed in _layouts/bin. A webpart assembly *should not* be installed in this folder. It may cause problems to the SafeControls engine and will also grant the assembly full trust.

This is the correct place to install your webpart assemblies when you want its scope to be for the web application it is installed in only and there is a need to control it security privileges. When a webpart is installed in the bin folder is uses CAS (Code Access Security) to determine what privileges are granted. There are three initial policies you can assign WSS_Minimal, WSS_Medium & WSS_FullTrust. You change the policy setting in the web applications web.config file.

This is the correct place to install if you want to share this webpart across multiple web applications and it is from a trusted source as it operates under full truest privileges. You need to sign the assembly with a strong name key (SNK) before you can install it in the GAC

I feel it is good practice to sign your assembly even if you intend for the assembly to be installed in the bin folder…why…because if you don’t you are already providing a limitation on where it can be installed and sometimes this may not be your decision.

Once your assembly has been installed into the correct location then all you have do know is create a SafeControl element in the web.config


One Response to “Where should WebPart assemblies live ?”

  1. Mick said

    CJ – also to add:

    You dont *need* to add to the GAC, but you could drop into the Bin and add to the safecontrols for the WebApp.

    You dont need to have it strong named if you drop it in the bin.

    Nice write up.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: