Name ActiveX controls for public sites AKA go away name.dll prompt

So, I use Chrome, there I said it. They say that admitting you have a problem is the first step to solving it. Anyway when I’m browsing the web using what is, in general, a pretty good browser I’ll every so often see this:

Don't show this on the internet, this is a horrible thing for the public!

As an anonymous user I don’t want to, nor should I ever see this.

So, what’s happening here?

SharePoint really has its roots as an internal collaboration tool and one of the really great things it does in this space is show presence indicators for other users. Now, those online presence indicators and the contact cards they spawn which let you initiate an IM or Lync call, they use an ActiveX control for this whiz-bang functionality.

Luckily there is an simple way of disabling this functionality. For 2010 and 2013 you can disable the presence indicators on a per-web application basis:

disable-presence

But the downside here is pretty obvious, it’s for the whole web app, and if you’re using Host Named Site Collections that’s going to hit a few more sites than the public facing one you’re trying to prevent that ugly prompt on.

Luckily there is another approach, with a couple of lines of JavaScript embedded into the master page this problem can be switched off:

<!--<SharePoint:SPSecurityTrimmedControl runat="server" AuthenticationRestrictions="AnonymousUsersOnly" >-->
  <script type="text/javascript">
    function ProcessImn() { }
    function ProcessImnMarkers() { }
  </script>
<!--</SharePoint:SPSecurityTrimmedControl>-->

Kudos goes to Randy Drisgill for this wee gem which I got switched onto when using the SharePoint 2010 Starter Master Pages. Be aware that it’s not in the 2013 Starter Master Pages as yet.

Now, you’ll note the SPSecurityTrimmedControl in there, that is to ensure that fragment is only ever present in the HTML for anonymous users. So authenticated users can see presence indicators and easily chat with colleagues working on the site too.

Those comment tags?

Well the SPSecurityTrimmedControl emits either a <span> or a <div> tag which is a no-no in the <head> of your HTML, the comment tags there just stop the browser interpreting the erroneous tags and deciding that the <head> should stop there.

Posted in Development, SharePoint | 3 Comments

SPDisposeCheck: Do not use for SharePoint 2013

I like many SharePoint developers out there I am user of SPDisposeCheck. My team and I use this as in our Continuous Integration builds as one of our quality checks on to determine if our code is passing the checks we need for a ‘green’ build.

In fact SPDisposeCheck is so valuable in terms of catching issues before they get into any live code from my team I consider it to be, borrowing from Doug Ware’s metaphor, the safety catch on my machine gun.

During beta we discovered that SPDisposeCheck was not working for SharePoint 2013.

Consider this code:

This code leaks like a seive

Now most of you who have done a bit of SharePoint development should be able to see that code has a gaping memory leak and should not pass SPDisposeCheck.

SPDisposeCheck zero issues found

Yeah, that’s not ideal…

But what about static code analysis? Microsoft.Reliability: CA2000 Dispose objects before losing scope is supposed to catch things like this too, right? Unfortunately this memory leak slips right past that check too.

Code analysis no issues found

This still has not been resolved. Yes, if you were doing SharePoint 2013 and thinking that you’re doing the right thing, using SPDisposeCheck, you need to do a code review. Now.

Myself and other SharePoint MVPs who are development focused are doing our best to keep this on the radar within Microsoft.

I for one really hope that we do get another version of SPDisposeCheck that can analyse our .NET 4.5 SharePoint 2013 code to stop developers out there from shoot themselves in the foot and taking down SharePoint servers with memory leaks.

Posted in Best Practice, Development, SharePoint | 2 Comments

Practical Guide to Public Facing sites

This year I presented a second session at the New Zealand  SharePoint Conferences, on “A Practical Guide to Public Facing web sites”. As promised in my session here is the slide deck.

Posted in Conferences, Development, SharePoint | Leave a comment

Writing testable SharePoint code: New Zealand and Australian SharePoint Conferences

This year I was lucky enough to be invited back to present at the New Zealand and Australian SharePoint Conferences, this time on “Writing Testable SharePoint Code”. As promised in my sessions here is the slide deck and, more importantly, the sample code :)

Posted in Conferences, Development, SharePoint, Visual Studio | Leave a comment

Design Manager and Server 2008 R2

I was trying to use the design manager features today and ran into this on my dev server. I’d copied the short cut from the screen and pasted it into the map network folder dialog and got this:

image

 

If you’re trying to do this from Server 2008 R2 you’ll need to do a simple piece of config first; Simply go and add the Desktop Experience Feature and reboot your server!

A nice and easy fix :)

Also make sure you use the http:// path and not the file:// path that you’ll get with right click > copy shortcut ;)

Posted in Uncategorized | Leave a comment

Setting up Visual Studio 2012 for SharePoint 2013

VS2012 Update 1 is great it adds the Microsoft Fakes framework for stubbing out SharePoint dependencies and other really useful tools for SharePoint development. If you’re using Visual Studio 2012 you should be using Update 1; but it doesn’t have the extensions for 2013 development as yet. To get those they need to be installed using the web platform installer.

1) Download and install http://www.microsoft.com/web/downloads/platform.aspx (you should probably do this for all development environments anyway)

2) Launch the Web Platform Installer and search for SharePoint

3) Add install the latest version of the “”Microsoft Office Developer Tools for Visual Studio 2012” (currently it’s Preview 2)

Posted in Development, SharePoint, Tools | Leave a comment

PowerShell: Pause for specific key strokes

Today I needed to add a wait into a Powershell script, given that is a point where the user running the script needs to go do some manual steps on another server I thought it might be a good idea to wait for a specific key press. So off to Bing I go…

There are plenty of great articles on waiting for or getting user input, personally I really like Windows PowerShell Tip of the Week: Pausing a Script Until the User Presses a Key and the User Interaction chapter from the PowerShell Cookbook. After seeing that [Console]::ReadKey() would give me an object which told me about the modifers on the key press (Crtl, Alt and/or Shift) I started thinking about making that key press more specific, say Ctrl + G, so I wrote a function to handle this:

function Pause
{
	param([string] $pauseKey,
			[ConsoleModifiers] $modifier,
			[string] $prompt,
			[bool] $hideKeysStrokes)
			
    Write-Host -NoNewLine "Press $prompt to continue . . . "
    do
	{
		$key = [Console]::ReadKey($hideKeysStrokes)
	} 
	while(($key.Key -ne $pauseKey) -or ($key.Modifiers -ne $modifer))	
	
    Write-Host
}

This function received a bit of inspiration from How to Properly Pause a PowerShell Script which itself is pretty interesting.

Things to note:

Ctrl + C will still cancel the script, you’ll need to use $host.UI.RawUI.ReadKey with the AllowCtrlC option to prevent that, but then accessing the Modifiers is done differently.

$modifers is a simple enum value of ConsoleModifiers if you want to do combinations like Atl+Shift you’ll pass a collection of modifers and do –band operations to see if your conditions are met.

To call the Pause function use something like this:

$modifer = [ConsoleModifiers]::Control
Pause "G" $modifer "Ctrl + G" $true  

And then you’ll see this: image

Posted in Uncategorized | Leave a comment