views:

645

answers:

1

We have a Sharepoint project where we have deployed the dll's of the project to the GAC.

We have seen that the best practices is to have them in the bin directory. This is based on the information in the answer to this question: http://stackoverflow.com/questions/1073347/web-part-dll-in-gac-or-bin-using-sharepoint-2007

What are the steps that we have to do to make this change?

Thanks

Shiraz

+2  A: 

Essentially two things:

This allows SharePoint's full trust assemblies to make use of those operating under partial trust (yours).

  • Write a custom Code Access Security file and add it to the web.config for the SharePoint web application.

Writing your own CAS file can be tricky and error prone if you want to do it properly. If you use a tool such as WSPBuilder it can create one automatically for you, which I strongly recommend. Otherwise, there's a written-by-hand guide here. A "cheat" method is to write a CAS file that fully trusts your assembly, but that's going against the point.

Note: Certain SP artifacts such as event handlers must be deployed to the GAC.

Alex Angas
You have this backwards Alex. the APTC attribute is placed on an assembly destined for the GAC, so partially trusted assemblies (i.e. thse in the bin) may call them. In this case, the SharePoint assemblies are in the GAC and already marked with APTC where appropriate. Assemblies in the BIN have no need for this attribute (as long as the BIN is not fulltrust).
x0n
@x0n: Hmmm do you have a reference for that? Searching for `AllowPartiallyTrustedCallers web part` describes using the APTC attribute for deploying to the bin folder not the GAC.
Alex Angas
@alex: sorry - the limitation is on strongly-named assemblies, not only those in the GAC (when I hear strong-named, I think "in the gac."); if your assembly in the bin has a strong-name, it demands full-trust callers unless marked with this attribute. You are still not quite right though; fulltrust assemblies (like sharepoint's) can call into partial-trust strong-named assemblies in the bin. It's just that non-fulltrust assemblies cannot (e.g. other assemblies in the bin or perhaps in ISAPI etc)
x0n
@x0n: OK I'm with you now. As you know more about this than I do it might be better if you write the correct answer? Once you've done I'll delete mine.
Alex Angas