ASP.NET CustomErrors can't capture HTTP 401s…

It’s been a mad few weeks, so sorry for the posts tailing off a bit. Anyway, let’s get back into it with an interesting (and fairly short) problem.

ASP.NET applications can have custom error pages for the different HTTP responses. For example, you can have a custom “404 – Page not found”. Now, this can be a good idea, particularly for errors that produce stack traces or provide potentially sensitive information about the workings of your code. Or, heck, maybe you just want to present a nice looking error page. Continue reading “ASP.NET CustomErrors can't capture HTTP 401s…”

ASP.NET CustomErrors can't capture HTTP 401s…

Forms Based Authentication User Management – bah!

SharePoint supports Forms Based Authentication. I suspect this isn’t news to anyone – if nothing else, I’ve posted about articles describing setting it up.

However, what SharePoint doesn’t do is give you a way of administering these users. In those articles about setting it up they all recommend using the Visual Studio ‘Configure Website’ tool. This works, but it isn’t pretty, and I wouldn’t want customers using it!

Now, it is a shame the SharePoint doesn’t have this facility – we’ve got the membership provider framework abstracting the actual storage of user details (SQL database? Active Directory? Flat file? Who cares? It all looks the same through the provider’s interface). Further, the membership provider interface gives you admin functions that you might want – like list, create, delete, update.

Thus, it seems to me that an obvious thing to provide is a user interface for administering the contents of that MembershipProvider. Sadly, it doesn’t. I suppose the problem is that a developer could extend the membership provider interface or something, but it is a pain. I figured that I can’t be the only person suffering this pain, so I decided to check on Codeplex.

(Don’t get me started on the performance of the codeplex site.)

The Community Kit for SharePoint has an FBA management, well, sub-project, I guess. I tried installing it, but soon found myself asking the same question as Wouter Van Vugt – what is the quality of this project? I mean, it installed okay, but I immediately got a NullReferenceException when I tried to use it. Looking into the code, I found some oddities too – like why is the list of users being filtered to those assigned rights to a site? Surely this should just be administered at the site collection level (well, technically, at the web-app level, but they’re usually the same thing)? That just seems an unnecessary complexity. And the Datasource control used for this lacks create, update and delete – so no clever Gridview usage.

There is also another codeplex project – Forms Base Authentication Tools and Utils for SharePoint 2007 – but it’s been in beta for over a year, and has very little activity, so I don’t know what the state of this is.

All of which, ultimately, brings me around to the idea that I’ll have to write my own (though I’m checking to see if Wouter started to do that, as he seems to have come to the same conclusion). And, actually, the crux of it isn’t a SharePoint thing – such a facility would be easy if there was a DataSource control that wrapped the MembershipProvider. I may just write a datasource to do this.

Forms Based Authentication User Management – bah!

Stupid Visual Studio 2005 MSDN DVD

A note for myself. The MSDN DVD for April 2007 (Disc 3070.1) with Visual Studio 2005 on it can’t be installed directly from the DVD. The installer asks you to ‘Install Disk 1’, which is unfortunate, as there is no disc 1, and the DVD contains both CDs in different directories on it.

The solution is to copy both CDs to a single directory on the hard disc of the machine, and run the installer from there.

Unfortunately, for some reason my virtual machine won’t let me do that directly – it complains about copying one of the files from the DVD – but I can share a folder on the host, and copy the installation files into the VM via that folder.

Once you’ve copied the files on, though, the ‘pre-filled’ licence key isn’t there anymore. You can get the key by starting installing from the DVD, writing it down, and then using it when you install from the hard disc.

It’s crazy the work-arounds you have to go through sometimes 😦

Stupid Visual Studio 2005 MSDN DVD

MSI Setup projects in Visual Studio : 2005 != 2008

I’ve been working on a project that is a shared plugin to Office 2003. I was writing this in Visual Studio 2005, but for a variety of reasons (not least of which was having a tidier dev environment), I decided to move this onto a convenient VM which happened to have a lot of the things I needed (MOSS, a domain controller, AD, exchange).

Unfortunately, it also had Visual Studio 2008 too. I didn’t think this would be a problem, though, and so I when I opened the project on it for the first time and it asked me to upgrade the project to 2008, I was happy do. I didn’t think there’d be a problem.

Well, during development, there wasn’t. Whenever I went to test my MSI installer, though, I started to have problems. Installation kept failing and I kept getting the error:

Error 1937. An error occurred during the installation of assembly ‘Extensibility,Version=”7.0.3300.0″,Culture=”neutral”,PublicKeyToken=”B03F5F7F11D50A3A”,ProcessorArchitecture=”MSIL”‘. The signature or catalog could not be verified or is not valid. HRESULT: 0x80131045. assembly interface: IAssemblyCacheItem, function: Commit, component: {8C306A7E-AE8E-14F0-4168-C43060985CF4}

This was surprising. Extensibility.dll isn’t one of mine – it’s a Microsoft one that should’ve been in the Primary Interop Assemblies for Office. Anyway, it’s not one of mine, it hadn’t changed, and it was signed correctly. So what gives? Continue reading “MSI Setup projects in Visual Studio : 2005 != 2008”

MSI Setup projects in Visual Studio : 2005 != 2008

Visual Studio Comments

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.

Visual Studio Comments

Use Reflection to find a calling method

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…

Use Reflection to find a calling method

Problems with the extensibility.dll in Outlook add-ins

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?

Problems with the extensibility.dll in Outlook add-ins