Showing posts with label WebPart. Show all posts
Showing posts with label WebPart. Show all posts

Monday, March 30, 2009

Implement the Object Model in a Custom Web Part

How to: Implement the Object Model in a Custom Web Part

http://msdn.microsoft.com/en-us/library/ms479215.aspx

Working with List Objects and Collections

http://msdn.microsoft.com/en-us/library/ms460897.aspx

ERROR

The "SimpleWebPart" Web Part appears to be causing a problem. Updates are currently disallowed on GET requests.  To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb

SOLUTION

SPWeb myweb2 = SPControl.GetContextWeb(Context);

myweb2.AllowUnsafeUpdates = true;


ERROR

Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security

SOLUTION

<trust level="Full" originUrl="" />

To get the PublicKeyToken

C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin>

sn -T *.dll

Where to Put Webparts

C:\Inetpub\wwwroot\wss\VirtualDirectories\80\bin

The web.config you have to edit to add safeControls

NHibernate and Sharepoint 2007

NHibernate and Sharepoint 2007

Sharepoint webpart that uses NHibernate to do Database operations.
It was a hard task, spent 2 days fixing deployment errors and assemblies dependencies.

At the end it worked :)

Make sure:
- Hibernate mapping file build action is embedded resource
- Use NHibernate.ByteCode.Castle not NHibernate.ByteCode.LinFu (I donno why!)
- hibernate.cfg.xml and NHibernate.ByteCode.Castle.dll should be in C:\Inetpub\wwwroot\wss\VirtualDirectories\80\bin
- NHibernate required libraries put them in the GAC C:\WINDOWS\assembly