I’ve just had to write some instructions about how to check if the Office Primary Interop Assemblies are installed – or more specifically, the Outlook ones. I thought that might be useful…
Archive for the 'Coding' Category
I keep having to look this up every couple of months. Microsoft support have described how to find out. Read more »
I didn’t realise this, but Visual Studio allows you to see comments beginning TODO, HACK and UNDONE in the task list pane. That’s really quite neat, though it’s unfortunate that the list only contains items for files that are currently op open in the IDE. You can also add your own ‘tokens’ via the Options > Task List dialog. Vish has a pretty good summary. It’s just a shame that the task list isn’t for all files, irrespective of whether they’re open or not. Still, a neat feature that I didn’t know about.
Reflection is a great way of finding the calling method in another method. I found this post which provided a good template for what I was trying to do (build a logging class that would automatically log the method and object that created the log entry). My code ended up being:
StackTrace stackTrace = new StackTrace();
// Calling Method and Object are only one frame up.
StackFrame stackFrame = stackTrace.GetFrame(1);
MethodBase methodBase = stackFrame.GetMethod();
string method = methodBase.Name;
string obj = methodBase.DeclaringType.Name;
Neat! I the write obj and method into my log…
Folks are really keen on RSS feeds in SharePoint, but the RSS web part only receives feed from 1 location. Well, good news, as Eric Shupps created (a while ago, actually) a feed aggregator web part. That’s a useful thing to know – but it’s interesting that he hit the problem I have with RSS feeds – too many formats of them…
On and off I’ve been writing an Office add-in for Outlook. We’ve reached the point of testing, but when we installed it on a clean machine, it wouldn’t run. There was an error message complaining about not having the Extensibility.dll installed. “Odd” we thought. We’d been careful to install the Outlook PIAs (Primary Interop Assemblies), and no-one had heard of this assembly before.
Well, it appears that this assembly is installed with Visual Studio, but it isn’t installed with the PIAs. Nice. Fortunately Gunnar Peipman has an extremely timely post on this - I’d been looking at the Extensibility.dll in the GAC, but apparently there is one under Common Files too. I’m not sure where is has to go though – the GAC, the application folder, or into the common files directory. I’ll report back when I figure this out…
What I’d really like to know, though, is why this file isn’t part of the PIAs? I mean, what are you going to do with them if you aren’t writing an add-in?
I’ve been setting up forms based authentication for SharePoint. This is pretty much a normal ASP.NET authentication set up, but I’ve been following the instructions from Andrew Connell, and the excellent instructions from Dan Attis.
In these instructions, we set up the ASP.NET database using aspnet_regsql and then use the Web Site Administration tool to check the connections and create users (if you want to know more, check out the articles). However, here I had a bit of a quirky problem. Both sets of instructions say to, in the Web Site Administration tool, select the Provider tab and then select Select a Different Provider For Each Feature (Advanced). Then click Test by each provider. The problem – no Test link beside either provider.
As I was having some problems, I decided to dig into this. I tracked through the code that makes up the Web Site Administration tool, and found that this link is only shown if your provider contains the text ‘Sql’. I kid you not…
I was talking with one of our customers about SharePoint branding the other day. They’ve got some neat icons for displaying the status of things. However, the guy I was talking to wasn’t keen on them as they were the same colour (although their shape differs). This sort of led around to a discussion of the use of colour (or ‘color’) in web development.
One of my ‘neat tools to have around’ is the Color Contrast Analyzer (which I think you can get here -I must confess, I’m not sure who exactly wrote it or where exactly you’re supposed to get it from). This little tool lets you check the contrast of colour schemes so that your users will be able to use the site, even if they’re colour blind. Fair enough. The really exciting bit, though, is the ability to take screenshots and then simulate the different types of colour blindness.
I used this to look at the SharePoint KPI icons. Similar icons to this are available in Excel 2007 for conditional formatting. I thought this was pretty interesting. For a start, it turns out that colour blindness is more complicated that just “red-green-blue” colour blindness, not least because the photoreceptors for the different colours overlap in their response to different frequencies of light. Still, this tool give a good view of the effects of the main conditions. For a full description, read this article at Wikipedia.
Normal |
GreyScale |
Deuteranopia (Red-Green Colour Blindness) |
Protanopia (Different Form of Red-Green Colour Blindness) |
Tritanopia (Blue-Yellow Colour Blindness) |
|
What this shows is pretty obvious – that the icons from red and green are pretty similar for red-green types of colour blindness (what a surprise), but that the shape of the icons still gives a good visual cue to the state of the KPI. Given that (according to Wikipedia) 7-10% of men are Red-green colour blind, this is important. It’s worth noting that women are very rarely colour blind, and that this probably explains my Dad’s dress sense and my Mum’s opinions on it…
I came across an interesting little problem with putting query string parameters for an HTTP request into a SharePoint page.
I was using a Dataview web part, which accepts query string parameters into the filter that it runs over the data that it’s going to display. That’s pretty cool – I had a list of items with a status column, and I wanted to be able to filter the items based on that status, and that the status would come from the query string. However, on the page, I also wanted to show a title with what was being filtered by in it. So, for example, my url might read:
http://server/site/page.aspx?status=Ready
And I wanted the title in the page to read “Filtering by ‘Ready‘”.
What I didn’t appear to be able to do was to just use the request object . Something like
<%= Request.QueryString.ToString() %>
won’t work as code blocks aren’t, apparently, allowed in the file – the error message is “code blocks are not allowed in this file”. Okay, given that SharePoint designer is supposed to open these pages up to ‘Power Users’ I do get why code blocks aren’t allowed. But I really wanted to write code, and there had to be a way to do that. Well, Kirk Allen Evans has figured out how – you have to enable them in the PageParserPaths section of the web.config file. (It’s strange how easy it is to forget the web.config file that controls SharePoint sometimes). Just to repeat his example (in case blue and red on black is difficult to read):
<PageParserPaths>
<PageParserPath VirtualPath="/pages/*" CompilationMode="Always" AllowServerSideScript="true" />
</PageParserPaths>
This example allows code blocks for all files under the /pages directory of my web application – it’s worth noting that this is for the web application in IIS, not a SharePoint site collection or the like.
Okay, so that works – great. However, there are security implications, and this is probably best only used for development environments. I’ve written a bit about under what conditions our inline code will run.
In our instance our customer is kind of reluctant to make changes on their server. Changing the web.config file would be a bit of a big deal. (As a side note, this is a bit restrictive – I think a blog posting on that is due sometime). So what could we do without a server footprint?
Well, without code in the page, we would need a web control to call in that page – that would work also. It’d be trivial to write one. However, that requires deployment, marking as safe in the web.config file, etc., so really that just pushes the problem into another file.
Thus, I ended up getting a bit ‘old skool’ – JavaScript in the page to write the value from the query string on the client. I came up with:
<script type="text/javascript">
var query = window.location;
var regex = /letter=([^&=]+)/i;
var match = regex.exec( query );
if( match != null ) {
document.write( "Filtering by '" + match[1] + "'" );
}
</script>
Made a function, this became:
function getQueryParam(key) {
var regex = new RegExp(key+"=([^&=]+)","i");
var match = regex.exec( window.location );
if( match != null ) {
return match[1];
} else {
return null;
}
}
What this code does is it gets the page’s url (window.location), runs a regular expression looking for the ‘letter’ parameter, and if it find one, it outputs some text to the document. A bit noddy, but simple and it works – with no server footprint. Of course, you do need JavaScript enabled…
Previously, I’d posted about people and risk – and how we’re bad at judging it. The second part of the thoughts I’d had while driving to work was how risk applies to software development. Read more »