Sharepoint ListAdded event - sharepoint-2010

I need to execute some code when a new document library is added.I have created an event receiver for Lists and handle the ListAdded event.The error i get after debug/deploy is
"The object cannot be created from sandboxed code assembly...

To cause the event to trigger on all sites in the site collection, the scope of the Feature must be changed to Site; this way, the functionality is enabled when we activate the Feature at the site collection rather than having to activate the Feature on every subsite. Note that the Site scope of a Feature refers to site collection (see Figure 7); Web scope refers to the sites.
more: http://msdn.microsoft.com/en-us/library/gg981880.aspx

Related

What is Injectable and Embeddable?

I have heard about both terms Injectable and Embeddable many times, but I am not getting actual meaning of it.
Please help me to understand both clearly.
Injectable means that something can be created and added to the main script while the script is running.
Embeddable means something can be added to a script or code before running it i.e before compilation or running of the script.
For better understanding lets take a website with a textbox as a context.
Now, In the textbox, suppose its very basic one. So, I can add a javascript into the textbox and when I will submit, it will run my JS script. This way, I am injecting my own script into the main page.
Now, suppose, I add an Iframe of another website to the HTML file of my website. In this way, when the website will be viewed, it contains the iframe. In this way, the Iframe is embedded to the website.
Injectable means that the object can be created and injected at run time. This is a hint to the compiler that this object will be managed outside the scope of the compilation and can be used at runtime to determine if the object was intended to be injected.
Embeddable means that the object can be serialized and stored in a column instead of as a separate table when the containing object is persisted. That also implies the lifetime of the embedded object is the same as the lifetime of the containing object.

SharePoint feature event receiver not firing

I want to add a custom RoleDefinition to my sharepoint site, in VS2010 I added a new feature receiver and under the Activated Event I added this code:
using (SPSite site = new SPSite("http://localhost:8280"))
{
using (SPWeb web = site.OpenWeb())
{
web.RoleDefinitions.Add(AdminRole);
web.Close();
}
site.Close();
}
Using the package designer I added the feature and from VS I deploy the solution to the "Web" scope. when I go to site features I do see my feature being Active but the Role Definition is not there. I suspect the Event receiver code not being fired so I added some code that writes to a log file and there the file was empty so the code is never reached. knowing that the solution is deployed as a sandbox solution on SharePoint 2010.
any ideas?
Many thanks
The Event receiver did not fire because it was not linked to the feature...doh!
here is the thing, in the feature template file these two attributes must be added:
ReceiverAssembly="Full name, version, neutral,publikeytoken"
ReceiverClass="*Namesapace.classname"
hth
You created some code that got deployed within a feature. But you never do something to make that code run. I assume you have a business reason to do this in code in a feature, as the UI would let you do this sort of thing. Your code should actually be within a feature receiver if it is something you want to execute upon activating the feature. You would add this code to the override routine for the feature activating class.
Search for Feature receiver for detailed instruction.

Tracking full browser activity in VB.Net

There's a website that contains some real time information. I want to have a VB.Net windows application that monitors the page, and when it detects certain events it triggers some actions based on the data in the page.
I've been searching like crazy for some mechanism to "hook" into the browser and hopefully inspect the messages transmitted for the application to know how to react.
I've seen the SHDocVw COM object, which comes very close. But when I use the BeforeNavigate2 event, it only seems to fire for GETs, and once I'm on the page where the information is displayed/refreshed the event is not raised.
Short of reverse engineering the page, or having to write some kind of proxy...is there a good way to do this in VB.Net?
Here's a method you can try:
Create a GreaseMonkey script embedded on the page to hook up events.
When changes occur, collect the changes in an array or display them on the screen.
Create a VB.Net webpage service to listen for POST requests.
Post using AJAX from your GreaseMonkey script to the webpage service, which then writes to a log file/database on your server.
Otherwise the proxy would probably be the next best method, providing the server isn't HTTPS.

WorkflowCreationEndpoint ResumeBookmark with a filled response

I've spend days trying to find a solution the problem i'm going to try to describe, i've googled alot and even looked at the .NET 4 reference source for SendReply and InternalSendReply activity. But until now i'm stuck.
To make the life of our end customers simpler i want to replace the Receive and SendReply activities with custom activites and use bookmarks instead.
I'm implementing a central webservice which can route to a correct workflow instance, that workflow modifies the bookmark value and finaly it creates a new bookmark while returning the modified bookmark value. It's rather complex already with a WorkflowServiceHostFactory which adds Behaviours and Attach a DataContractResolver to the endpoint.
The endpoint is derived from WorkflowHostingEndpoint which resolves a bookmark created in a custom activity (instead of a receive). And i want another activity instead of a sendreply. Those 2 should correlate and the custom sendreply does send a response on the open channel through the endpoint while creating a new bookmark.
The problem is that i didn't find a way yet to access the endpoint responseContext from within my custom send activity. On the other side, at the workflowcreating endpoint side, it seems that i'm not able to be notified whenever the workflow becomes Idle and as well i don't seem to be able to access the WorkflowExtensions from the host. i'm missing something?
A possible solution i've in mind might be not using a WorkflowServiceHost, but then i loose alot of AppFabric functionaly.
The workflowapplication in platform update 1 has some extension methods called RunEpisode with an overload Func called idleEventCallback. There it's possible to hook into the OnIdle and get a workflowextension to get the object to send back as response.
To answer my own question, i ended up in a workaround using the servicebroker functionality of sql server. The SqlDependency class where the workflow listens for the event to be fired whenever the workflow reach the activity that creates a new bookmark in another state.

Sitecore - Multiple-Site Error Page Handling

I have a multiple-site Sitecore project. I know how to deal with error pages via the webconfig's ErrorPage, ItemNotFoundUrl, LayoutNotFoundUrl, LinkItemNotFoundUrl for one site.
However, I'm wanting to display a different error pages for each site. How can I accomplish this?
In any case, you can probably store the URLs of the error pages for each site as attributes of the /configuration/sitecore/sites/site elements in web.config by extending the Sitecore.Sites.SiteContext class (see for information about extending existing classes).
The SDN forum post provides more information specifically about the 404 /ItemNotFound condition, including an example of an extension of Sitecore.SItes.SiteContext.
For ItemNotFoundUrl, I think it depends on whether you use an item or a file as the 404 page. If you handle 404 with items, then after the item resolver, add a processor to the httpRequestBegin pipeline to set the context item to the 404 item for that site if the context item is null. If you use files, then I think override Sitecore.Pipelines.HttpRequest.ExecuteRequest.HandleItemNotFound() and Sitecore.Resources.Media.MediaRequestHandler.DoProcessRequest() and update the corresponding references in the web.config file.
For ErrorPage, I think you would have to override Sitecore.Pipelines.RenderLayout.SecurityCheck.Process and update the corresponding reference in web.config.
For LayoutNotFoundUrl, I think you would have to override Sitecore.Pipelines.HttpRequest.ExecuteRequest.HandleLayoutNotFound, and update the corresponding reference in web.config.
For LinkItemNotFoundUrl, I would probably add a processor to the renderField pipeline to perform replacement of the default value of the setting with the value that applies for the context site.
If this is a common requirement, we should turn it into a Sitecore Shared Source project, or add it to an existing project.
There's an entry in the SDN scrapbook about how to do this for a multi-site install.
There is a Shared Source project which should fit the requirements is most parts. It's called Sitecore Error Manager.
Hope that helps.