Category Archives: ASP.NET

Solving ‘An exception occurred in publishing: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)’ with Visual Studio 2012 RC

So I’m using Visual Studio 2010 RC and loving web deploy as a simple way to publish my projects to different environments.  However a problem cropped up today after installing some web tooling updates:

‘An exception occurred in publishing: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)’

I couldn’t even open the publish settings dialog to see if anything was wrong in there.  I tried restarting Visual Studio, then running it as Admin, no change.  I eventually found the following steps on a forum which resolved the problem for me:

  1. Run Command Prompt as Administrator
  2. regsvr32 actxprxy.dll
  3. Restart Visual Studio

And hey presto, project publishing was working again!

Hopefully this will be of use to someone else out there banging their head against a brick wall trying to figure this one out.

Advertisements

Claims Proxy – A C# Library for Calling Claims Protected Web Services

The ClaimsProxy library enables you to get a WIF cookie collection for a SharePoint site which is protected by Claims Based Authentication. It assumes that ADFS is configured as the Trusted Identity Token Issuer and that the down-stream identity provider is based on the StarterSTS / IdentityServer project.

In some recent work I needed to call some SharePoint 2010 web services from a client outside of the SharePoint farm.  Using traditional network credentials and Windows Authentication this was a straightforward matter, for example:


ICredentials credentials = new NetworkCredential('username', 'password', 'domain');
SharepointUserGroupsWCF.UserGroupSoapClient client = new SharepointUserGroupsWCF.UserGroupSoapClient();
client.ClientCredentials.Windows.ClientCredential = (NetworkCredential)credentials;
client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
client.Endpoint.Address = new EndpointAddress(webPath + "/_vti_bin/usergroup.asmx");

XElement groupXml = client.GetGroupCollectionFromSite();

However, when the target service is protected by Claims Based Authentication, it’s not so straightforward to call such services.  In my scenario I had a SharePoint 2010 site protected in a web application configured with Claims Based Authentication.  I had configured SharePoint to direct authentication to ADFS (Microsoft Active Directory Federation Server), and then I had a custom claims provider configured based on Dominick Baier’s Identity Server  open source STS product (formerly StarterSTS), however my approach could easily be adapted to work with any number of final claims providers.

Even if you just want the code, read this bit first.

I’ve implemented the code as a .NET 4.0 assembly, although it should be relatively easy to get it to compile under .NET 3.5.  The overall approach works as follows:

  • Use username + password to request a symmetric token from our custom STS (you could get a Windows token here or whatever you are using) – set the realm to that configured for ADFS
  • Use that token to request a bearer token from ADFS – set the realm to the SharePoint site realm as configured in ADFS
  • Use the token from ADFS to authenticate with SharePoint
  • From the resulting authentication response, extract the WIF (Windows Identity Foundation) cookie for authentication (commonly named FedAuth)
  • Return this cookie to the client

I have included a test application in the solution which demonstrates using the returned cookie to make a call to a web service in the SharePoint site.  I’ve left the responsibility of caching the cookie to the client (but included this in the test app).

IMPORTANT NOTE: There is one modification required to the library which I haven’t done yet.  If you read the finer details of WIF you will know that if the SAML token data is too large for a single cookie, then WIF spreads the data over multiple cookies named FedAuth1, FedAuth2 … FedAuthN.  The library assumes that there is only one FedAuth cookie at present – which will be sufficient for most applications – but its worth keeping an eye on if you’re running into troubles.  I will get around to sorting this at some point, but feel free to make a pull request on my Github repository if you get there first.

Download the ClaimsProxy library and sample application from Github

ClaimsProxy is straightforward to use:


// configure our SPServiceRequestor.
var requestor = new SPServiceRequestor
{
    DobstsEndpoint = "https://startersts.yourdomain.com/startersts/users/issue.svc/mixed/username",
    DobstsUsername = "joe.bloggs@yourdomain.com",
    DobstsPassword = "password",
    DobstsAdfsRealm = "https://adfs.yourdomain.com/adfs/ls/",
    AdfsEndpoint = "https://adfs.yourdomain.com/adfs/ls/",
    SharepointRealm = "urn:sharepoint:sp.yourdomain.com",
    SharepointSiteUrl = "https://sp.yourdomain.com/",
    IgnoreSslValidation = true,
    DebugMode = true,
    DebugEventCallback = (data) =>
    {
     // your debug function here
    }
};

string spCookieRaw = requestor.GetCookie();

N.B.: DobSts is our own implementation of the StarterSTS project.

Check out the sample application for a full example of how to use the library.

I’d welcome any comments / feedback on this – hopefully it will be of some use to others out there, it certainly has been to me.

Web Development Toolsets – PHP vs. .NET IDEs

[tweetmeme source=”shuggill” only_single=false]

I’ve been writing code for the web for 10 years now, and in a (full-time) professional capacity for almost three and a half.  I’ve worked extensively on the Linux Apache MySQL and PHP (LAMP) stack as well as in Microsoft’s ASP.NET.  This post is a helpful summary of my experiences developing in both worlds, and what you need to focus on your job.

Important information on operating systems: I carry out all of my development on Windows, so you’ll not find any suggestions or reviews of software for Macs or Linux here.  If you’re one of these people, why not write up your own review?

Integrated Development Environments (IDEs)

Let’s be honest, we all started out in Notepad, writing angle brackets in long hand and making extensive use of Ctrl+C.  However once we graduated from the single scripted site, managing multiple files and object oriented links between them soon left us lost in a sea of notepad.exe windows.  To curb this problem, and many others, software vendors developed IDEs, to incorporate a number of development tools into one application.

My favourite PHP IDE – Netbeans

If you write any amount of PHP code then you’ll want to get comfortable in one of the many PHP IDEs out there.  In the last two years I’ve spent many hours bashing keys in Netbeans IDE.  Whilst this application is written in Java (which undoubtedly makes it dog slow at times), Netbeans have dramatically improved the performance in the last few releases to the point where most features are finally usable!

Debugging

Remote team debugging does require screwing around with XDebug and Komodo Python Debug Proxy, which I did manage to get working on a Linux development VM.   However it has proved to be a little temperamental, requiring frequent restarts.

Source Control

Netbeans includes integration for SVN Source Control and this works pretty seamlessly – you can commit and revert from within the application, as well as see which files are under source control and their status.

Code Navigation

With the right hints in your code, you can jump between classes with Ctrl+Click pretty quickly.

Summary

I have toyed with other IDEs, notably phpDesigner, however Netbeans has been my favourite (free) IDE, and has served me very well.

My favourite .NET IDE – Visual Studio 2010

Much has been written about Visual Studio 2010, so I’m hesitant to try and add to the endless blog posts detailing every feature of this application.  All I will say is that it is an incredible piece of software.  It runs like grease lightening, it has a database explorer, browser and designer built in, as well as an extension model for a variety of useful add-ons.

Debugging

Even since my days of programming in Visual Basic 6, step-by-step debugging has been the most productive way to debug, rather than the old “Made it to here” debugging output.  You can attach to remote servers, or simply fire up the built in development web server to step through your code, with watch windows and full stack traces to hand.  This debugging experience is head and shoulders above that of Netbeans.

Source Control

Whilst you can get some source control add-ins for Visual Studio, my impression is that use of the Team Foundation Server is quite heavily pushed.  I have yet to find a good HG (Mercurial) add-in, so I hack away on the command line to feel like a real programmer.  On this item, Netbeans is my winner.

Code Navigation

When combined with IntelliSense, it beats Netbeans hands down, purely due to the speed and variety of options.  You get hinting at method parameters, namespaces to include as well as class properties, methods and events.

Summary

No serious .NET developer would use anything else, and as Microsoft make their express editions freely available, there’s really no excuse not to be using Visual Studio if you’re writing .NET code.

The Final Word

My overall development experience is much slicker in Visual Studio 2010; it feels like the right tool for the job, and it is so quick that I never feel like it gets in the way.  Netbeans is more of a necessary evil for development, and it often feels like I’m having to kill time whilst waiting for things to happen, or have those moments of keystroke regret when you see the “scanning for indexes” message in the status bar.  But compared to Notepad, it is so many steps ahead that I’ll just have to keep putting up with the performance issues.

Web Development Toolsets – PHP vs. .NET IDEs

I’ve been writing code for the web for 10 years now, and in a (full-time) professional capacity for almost three and a half.  I’ve worked extensively on the Linux Apache MySQL and PHP (LAMP) stack as well as in Microsoft’s ASP.NET.  This post is a helpful summary of my experiences developing in both worlds, and what you need to focus on your job.

Important information on operating systems: I carry out all of my development on Windows, so you’ll not find any suggestions or reviews of software for Macs or Linux here.  If you’re one of these people, why not write up your own review?

Integrated Development Environments (IDEs)

Let’s be honest, we all started out in Notepad, writing angle brackets in long hand and making extensive use of Ctrl+C.  However once we graduated from the single scripted site, managing multiple files and object oriented links between them soon left us lost in a sea of notepad.exe windows.  To curb this problem, and many others, software vendors developed IDEs, to incorporate a number of development tools into one application.

My favourite PHP IDE – Netbeans

If you write any amount of PHP code then you’ll want to get comfortable in one of the many PHP IDEs out there.  In the last two years I’ve spent many hours bashing keys in Netbeans IDE.  Whilst this application is written in Java (which undoubtedly makes it dog slow at times), Netbeans have dramatically improved the performance in the last few releases to the point where most features are finally usable!

Debugging

Remote team debugging does require screwing around with XDebug and Komodo Python Debug Proxy, which I did manage to get working on a Linux development VM.   However it has proved to be a little temperamental, requiring frequent restarts.

Source Control

Netbeans includes integration for SVN Source Control and this works pretty seamlessly – you can commit and revert from within the application, as well as see which files are under source control and their status.

Code Navigation

With the right hints in your code, you can jump between classes with Ctrl+Click pretty quickly.

Summary

I have toyed with other IDEs, notably phpDesigner, however Netbeans has been my favourite (free) IDE, and has served me very well.

My favourite .NET IDE – Visual Studio 2010

Much has been written about Visual Studio 2010, so I’m hesitant to try and add to the endless blog posts detailing every feature of this application.  All I will say is that it is an incredible piece of software.  It runs like grease lightening, it has a database explorer, browser and designer built in, as well as an extension model for a variety of useful add-ons.

Debugging

Even since my days of programming in Visual Basic 6, step-by-step debugging has been the most productive way to debug, rather than the old “Made it to here” debugging output.  You can attach to remote servers, or simply fire up the built in development web server to step through your code, with watch windows and full stack traces to hand.  This debugging experience is head and shoulders above that of Netbeans.

Source Control

Whilst you can get some source control add-ins for Visual Studio, my impression is that use of the Team Foundation Server is quite heavily pushed.  I have yet to find a good HG (Mercurial) add-in, so I hack away on the command line to feel like a real programmer.  On this item, Netbeans is my winner.

Code Navigation

When combined with IntelliSense, it beats Netbeans hands down, purely due to the speed and variety of options.  You get hinting at method parameters, namespaces to include as well as class properties, methods and events.

Summary

No serious .NET developer would use anything else, and as Microsoft make their express editions freely available, there’s really no excuse not to be using Visual Studio if you’re writing .NET code.

The Final Word

My overall development experience is much slicker in Visual Studio 2010; it feels like the right tool for the job, and it is so quick that I never feel like it gets in the way.  Netbeans is more of a necessary evil for development, and it often feels like I’m having to kill time whilst waiting for things to happen, or have those moments of keystroke regret when you see the “scanning for indexes” message in the status bar.  But compared to Notepad, it is so many steps ahead that I’ll just have to keep putting up with the performance issues.

Developer Q&A Part 2

OK, so it’s been a couple of weeks since my last post of answers to Scott’s developer questions, but here’s the next batch that I’ve been researching…images

Q) What is the maximum amount of memory any single process on Windows can address? Is this different to the maximum virtual memory for the system? How would this affect a system design?

A) On a 32 bit system the maximum amount of memory that can be addressed is 4GB (2 to the power of 32). I think that this is the same as the total virtual memory. Any system that requires large amounts of memory (such as a database) would need to consider these restrictions.

Q) What is the difference between an EXE and a DLL?

A) An EXE has an entry point and can be executed in isolation. A DLL (Dynamic Link Library) is a resource used by executables to provide modularised functionality.

Q) What is strong-typing versus weak-typing? Which is preferred? Why?

A) Strong-typing is where the “type” of variables is explicitly specified up-front, whereas weak-typing is where variable type is implied, usually through the operations performed on it (examples are using the variant type and performing Mathematical operations). Strong-typing is usually preferred so that a compiler/interpreter can spot potential errors early on. However if you are writing short scripts or make use of the flexibility of weak-typing, then it can sometimes by preferable to use it.

Well, we’re off to Geneva for 5 days now, so a long break from computing and time to reflect, read, talk, explore and enjoy!

The training years

I’m young, 24 years old.  Sometimes I feel like I’m ready to change the world today.  Fortunately I know I’m not.  As I said recently at a talk I gave to University finalists, “it takes a whole series of small steps to achieve something great”, I now remind myself of my advice.  Take your time.

And so I view these years of my life as training, preparation, learn all you can years.  In that vein and inspired by Scott’s Be a better developer in 6 months I’m taking on two challenges:

  1. Answer one question every day from What Great .NET Developers Ought to Know.  At the end of each week I’ll post up my answers.
  2. Start the project below

ASP.NET logoA number of my web design buddies, notably Paul and Chris, are PHP coders and turn out great sites with full XHTML 1.0 Strict markup and CSS 2.0 compliant styles.  Accessibility is big on the web these days, so are sites which degrade with older browsers and mobile devices.

I’m out to prove to them (and myself) that using ASP.NET I can put together a fully functional web site that passes W3 CSS and XHTML validation, is accessible according to WCAG guidelines and utilises some of the benefits of ASP.NET (i.e. I don’t have to hack it to death to get it to work).

So, I’ve created a new virtual machine in Microsoft Virtual PC 2007, running Windows XP, IE 7, Firefox and Safari.  I’ve installed Visual Web Developer 2008 Express Edition (all free tools).  I’ll put up my site plan in another post, but the idea is to blog every week on progress, with screencasts of what I’ve learned.

To assist me will be a couple of good ASP.NET books I have, the ASP.NET site and a few late nights.

Watch this space.