Showing posts with label SharePoint 2010. Show all posts
Showing posts with label SharePoint 2010. Show all posts

Tuesday, 9 September 2014

Surface 3 Pro as a web development machine




A few weeks ago I obtained a surface 3 pro (128gb/4gb), since then I have been using it constantly as my main machine in an effort to see if and how it can be used as a development machine, before this I was using a Lenovo Z500 (8GB ram, i7 3rd gen, 1tb disk) so I naturally compare the performance and use of the surface to that.

The work I do in a day to day basis:
  • PHP dev (LAMP server, VS 2013)
  • Powershell (ISE/prompt x 2)
  • ASP.net Dev (2-5 dev sites up at any time, all with VS 2013)
  • SharePoint Dev (SPD 2010/2013, VS 2010/2012/2013)
  • Graphic Design (Paint.Net, Photoshop)
  • Presentations and demoing (Office Suite, Lync, Camtasia)

So I main needs for a laptop are:
  • It needs to be Quick
  • Can handle the masses of chrome and IE tabs I have open along with a few instances of VS and a few RDP sessions
  • Portable (I generally carry it for atleast 2h/day)



The Good
  • The battery can generally see me through an entire workday without needing to charge, very useful for travelling
  • The plug has a USB charger built in
  • The build of the Surface is spot on, its solid and all the parts work well together
  • Size means its easy to use in smaller spaces
  • Nice in-built sound, for those spotify/netflix moments
  • Type keyboard feels good when typing, feeling like a miz beterrn a mac pro keyboard and the awesome old "tappy" keyboards
  • Its very portable, being list and small, the kick stand being able to pivot to most positions makes it great to have on most types of desk
  • The InstantGo functionality is nice, meaning you can just close the keyboard over the screen and the surface instantly goes into a sleep state, you can carry it around for hours and it wont loose almost any battery in that stage, great when you are about to make a demo or a presentation, one less thing the demo gods can smite you with! 
The Bad
  • The touch screen functionality in windows 8.1 still doesn’t really cut it when you need to use a lot of selecting so a mouse is needed
  • Use of display port means I have to carry a box of different cables around (VGA/HDMI/Ethernet) to connect to a wired network or to any external screen
  • 4GB of ram means occasionally being selective on the apps I have open and almost no possibility for on-box VM's, but with teh readily available Azure VM's, there isnt really a need to have the local VM's, atleast in the way we used to need them so this isnt much of an issue
  • Screensize can be a bit small, recommend docking it to a larger screen

Conclusion
I have found this to be a brilliant replacement for a the z500 laptop, it can rip through almost any work quickly, my biggest issue with it is the size of the screen, when developing on it, due to the nice resolution it means code can be hard to see, but of course if you have an office space, a doc and a 24inch monitor solves that very easily and cheaply.

Now i have been using this for weeks i cant see the need to go back to a full laptop unless you need that extra grunt for VM's or a few instances of Photoshop and other apps open

Ofcourse it depends on what you are looking for and the type of intensive web dev you do, based on my needs it ticked every box, i would use this for everything apart from local VM's

Wednesday, 25 June 2014

SharePoint 2010/2013: Enable-SPFeature Error (Failed to create receiver object from assembly)

So I had another lovely error recently, I had a wasp which had some external assemblies, I accidentally forgot to add one to the package manifest and when it deployed I got:

Enable-SPFeature : Failed to create receiver object from assembly "ASSEMBLYNAME, Version=1.0.0.0, Culture=neutral, PublicKeyToken=eaf1b7820cf1
fb30", class "CLASSNAME" for feature "FEATURENAME" (ID: 08284496-c68e-4f6c-befe-5777d14ad74b).
: System.ArgumentNullException: Value cannot be null.

So I instantly realised I was being silly and added the reference to the package manifest, packaged it, cabbed it, The Dll was in there, Great! I deployed the wsp and tried The deployment script again, it failed on the same point, I checked the gas, it was there alright, everything was looking as it should, but I couldn't activate the feature.

What was wrong? I tried deploying once more, did an observer for good measure and still nothing.

I then thought I would reopen the PowerShell window and try once again on the off chance that something was borked, so I restarted it, ran the script and it worked!

For some reason, the PowerShell session had cached the old error response from the feature activation, I don't know why but that's what it seemed to do.

Rule of thumb for the future, open a new ps session if you get an unexplained issue with a ps script

Saturday, 7 June 2014

Powershell | Get SharePoint 2010 Custom Error and Access Denied pages

A simple script, run this on any SharePoint server in a farm and it will return all set error and access denied pages for all web applications:

Scenario: Audit of farm setup

Script:
<#
.Synopsis
   Gets all set error and access denied pages for all webapps in the current farm
.EXAMPLE
   get-sperrorpages
#>

function get-sperrorpages()
{
    $snapin = Get-PSSnapin | Where-Object { $_.Name -eq 'Microsoft.SharePoint.Powershell'}
    if ($snapin -eq $null)
    {      
        Write-Host "Loading SharePoint Powershell Snapin"
        Add-PSSnapin "Microsoft.SharePoint.Powershell"
    }

    Start-SPAssignment -global
get-spwebapplication | ForEach-Object {
Write-Host "Web Application: $_" -foregroundcolor Green
Write-Host " - Error Page Set:" $_.GetMappedPage([Microsoft.SharePoint.Administration.SPWebApplication+SPCustomPage]::Error)
Write-Host " - Access Denied Page Set:" $_.GetMappedPage([Microsoft.SharePoint.Administration.SPWebApplication+SPCustomPage]::AccessDenied)
Write-Host ""
}

    Stop-SPAssignment –global
}

Output:
PS C:\dev\scripts\audit> .\get-errorpages.ps1
Web Application: SPWebApplication Name=intranet.devnet.local
 - Error Page:
 - Access Denied Page:

Web Application: SPWebApplication Name=extranet.devnet.local
 - Error Page: /_layouts/Devnet.Local/Error.aspx
 - Access Denied Page: /_layouts/Devnet.Local/AccessDenied.aspx

Web Application: SPWebApplication Name=internet.devnet.local
 - Error Page: /_layouts/Devnet.Local/Error.aspx
 - Access Denied Page: /_layouts/Devnet.Local/AccessDenied.aspx

Web Application: SPWebApplication Name=edit.internet.devnet.local
 - Error Page: /_layouts/Devnet.Local/Error.aspx
 - Access Denied Page: /_layouts/Devnet.Local/AccessDenied.aspx

As you can see from that execution my farm has four web applications, three are publicly accessible so i have set custom error and access denied pages, the fourth is internal only so there is no need for any custom branded pages

Thursday, 11 April 2013

SharePoint Issue: Exception has been thrown by the target of an invocation while adding a CQWP

Summary Info:
SharePoint Version: 2010 Standard
OS:Windows 2008 R2

So, Yesterday I had another fantastically inexplicable issue.

I have this solution, this solution deploys a site definition, when the site is created, it activates a custom feature that processes the more complex requirements of the site, including some CQWP's whereby you been to set the listguid and weburl properties.

This solution was build and on both Dev and UAT it worked like a dream, but then it came to the production deployment, solution deployed, features activated, everything was looking rosey, until I tested creating a site, then boom "an unexpected error has occurred for correlation id.....", so there was me thinking there is an issue with the deployment that got glazed over, I checked the ULS logs for the correlation and there I found:

 Error Message   Exception has been thrown by the target of an invocation.   
  Error Stacktrace:  at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)  
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)  
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)  
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)  
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)  
   at Microsoft.SharePoint.WebPartPages.SPPropertyInfoPropertyEntry.SetValue(Object control, Object value)  
   at Microsoft.SharePoint.WebPartPages.BinaryWebPartSerializer.ExtractLinks(Object property, Object value, Int32 propertyLocation)  
   at Microsoft.SharePoint.WebPartPages.BinaryWebPartSerializer.Serialize(PersonalizationScope scope)  
   at Microsoft.SharePoint.WebPartPages.BinaryWebPartSerializer.get_Links()  
   at Microsoft.SharePoint.WebPartPages.SPWebPartManager.AddWebPartToStore(WebPart webPart, Int32 viewId, String viewGuid)  
   at Microsoft.SharePoint.WebPartPages.SPWebPartManager.AddWebPartInternal(SPSupersetWebPart superset, Boolean throwIfLocked)  
   at Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager.AddWebPartInternal(WebPart webPart, String zoneId, Int32 zoneIndex, Boolean throwIfLocked)  
   at Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager.AddWebPart(WebPart webPart, String zoneId, Int32 zoneIndex)  
   at {Logic Namespace}.AddCQWebPart(SPWeb rootWeb, SPLimitedWebPartManager webPartManager, String webpartName, String zoneId, Int32 zoneIndex, Guid listId, String url)  

What! what the hell is that!, the content query web part couldn't be added, OK!,  well that could be one of many issues:

  • SharePoint feature corruption
  • CQWP I'm referencing isn't there
  • Namespace is invalid
  • Couldn't set the properties

So I checked the webpart in the gallery, it looked ok, I added a webpart to the page through the UI, configured it to look at the list and it worked! so the .webpart is fine, the namespace and features are fine, so it looks like the property setting.

I removed the code setting the properties and still the error occurred  so as a process of deduction i took property after property out of the webpart until i found the properties breaking it, after taking the MainXsl, HeaderXsl and ItemXsl properties out of the .webpart file, the web parts deployed, why? good question!

So the SC I was deploying to was root and at "/" of the webapp so it cant be the URL of the properties.

Just to make sure I programatically set the urls of the xsl to the correct urls, when I did this I got another error!

 Error Message   Object reference not set to an instance of an object.   
  Error Stacktrace:  at Microsoft.SharePoint.Publishing.WebControls.CmsDataFormWebPart.MakeSiteRelativeUrl(String xslServerRelativeUrl)  
   at Microsoft.SharePoint.Publishing.WebControls.CmsDataFormWebPart.SetXSLLink()  
   at {Logic Namespace}.AddCQWebPart(SPWeb rootWeb, SPLimitedWebPartManager webPartManager, String webpartName, String zoneId, Int32 zoneIndex, Guid listId, String Url, String& errorMessage)  
   at {Logic Namespace}.AddCQPageWebPart(String pageUrl, String webPartName, String webPartZone, String listName)  

Ok now we're getting further down the rabbit hole!

Then I started investigating the context properties programmatically and found that when deploying this the HttpContext was null. I know this has been known to mess up some context sensitive operations. so I added the following before I attempted to instantiate the webpart to add:

 if (HttpContext.Current == null)  
 {  
      HttpRequest request = new HttpRequest("", rootWeb.Url, "");  
      HttpContext.Current = new HttpContext(request, new HttpResponse(new StringWriter()));  
      HttpContext.Current.Items["HttpHandlerSPWeb"] = rootWeb;  
 }  

and viola! the web part started to deploy!

So in conclusion, the CQWP is very context sensitive, and to do anything programatically, make sure you have access to a HttpContext