How to open a new tab in an existing Internet Explorer instance in C#

A problem that I recently came across is when opening a new Internet Explorer instance in C# the user was being required to login to a site that they had already logged in to. It was pretty clear that this was because the existing session was not being used as a new IE process was being started, therefore I surmised that the solution was to utilise the existing process.

I had read previously about the Navigate2 API and thought it may help but it wasn’t entirely clear how to use it and specifically how to use it on an existing IE instance, so I feel this blog may help others.

Continue reading

How to save to PDF in C# using Word 2003 or 2007 without SP 2 (using Pechkin)

I’ve spent a significant amount of time lately on trying to solve this issue and came across many, many barriers, so I thought I’d share with you my findings and the solution that I used. Whilst Word 2007 SP2 (or Word 2007 using the Save As PDF Add-in) and above natively support saving documents as PDF (and can therefore be used by C# to save as if saving a normal .doc or .docx – you can do this easily by adapting my code) below this level it is not possible. There are a few different ways that this problem can be solved (notably, using a paid library or a web service) but most involve payment and some involve methods that, in my case, were not acceptable (e.g. having to install additional software or having to access locations that were locked down).

Continue reading

How to force open Internet Explorer 32-bit or 64-bit in C#

On a project I was recently working on it was necessary to open a URL in Internet Explorer (a requirement of it to work correctly, unfortunately) and we had a few “bugs” which seemed to randomly occurred. It turned out this was due to Process.Start(“iexplore.exe”) loading 32-bit IE whereas it seems we required 64-bit.

Continue reading

How to install ADFS 2.0 and configure SAML for SSO (auto login/AD login integration)

I’ve recently had an experience of setting up Single Sign On (SSO) for an application that we sell in work (Oracle RightNow) which provides a SAML 2.0 interface for authentication and found that there is very little, useful instructions on how to install and especially to configure SAML – hopefully this information will help anyone else in a similar situation.

Continue reading

How to install NDepend in to Microsoft Visual Studio

So I had a very kind E-mail from a chap called Patrick Smacchia the other day offering me a free professional license for his software NDepend. There were no strings attached, he simply offered “I would be glad to offer you a pro license. This way you can use the tool and explain its capabilities on your blog if you find it useful”. I was a tad sceptical at first so did a little research and found out what it is; the description was a little cryptic – essentially it’s a suite of tools with its own language that allows you to analyse your code to find out more information e.g. number of lines of code in certain sections, code or framework dependencies, what are the most complex or largest functions etc. This essentially can help you understand the complexity and quality of your code which can help you improve it.

Continue reading

By popular request: image gallery of old, custom water cooling rig

I’ve promised a few friends over the years that I’d put up pics of my water cooling rig that I made a few years back – I designed and had built (by my mum’s then partner) an external enclosure; this contained a reservoir, pump, power supply, a radiator from a motorbike and 2 large fans to keep it cool. Connected to this was a bunch of tubing that entered the rear of the case (with valves in the middle so I could take it all apart easily and safely) and connected inside the PC to a CPU block, nortbridge block and GPU block. Additionally I wired together a device that would detect the PC power supply which then connected to the enclosure power supply so that when the PC turns on so does the water cooling unit.

Continue reading

How to remove warning: The ‘log4net’ element is not declared

So I’ve seen a lot of questions around this issue with generally the only resolution being: “It’s a warning, just ignore this”. Whilst it is safe to do this, for pedants like me there is a true resolution. There are a few places around the net to get this but (like a lot of issues I blog about) you often need to combine the advice. Here’s the true resolution:

Continue reading

Colour your Log4Net events in your RichTextBox

You’re most probably here because you have already read my article How to watch your log through your application in Log4Net and you’re thinking “that’s great, but I need to somehow differentiate all of this output!” – either that or you just really need a handy way to format certain keywords within your RichTextBox.

Continue reading

Scrolling textbox when text is added, but not if the user has scrolled

You may (or may not) have read my recent article How to watch your log through your application in Log4Net which allows you to append Log4Net events direct in to a textbox – if so, you may then also have come across a frustration that I also had, which is that whenever the texbox is updated it scrolls incorrectly and what you actually want is for it to scroll to the bottom unless the user has scrolled themselves and therefore it should remain in place (so that the user can carry on reading where they are).

Continue reading