2015. március 25., szerda

Opening a password protected Excel document from c#

I have to write a migration tool for a client whose idea of data security is password protecting the Excel files.

However even if I supplied the Password and WriteResPassword parameters to the Open function, it still gave me a little dialog box asking for a password.

With some trial and error I found that in Read-Only mode the interop will actually open the file silently, so I thought I would share the code snippet.

As usual, your mileage may vary.

2015. március 11., szerda

Things to do before uploading a VHD to Azure

I recently had to upload several virtual machines into azure. No sysprep, no image creation, just moving a domain consisting of a couple of virtual servers and a DC into the cloud.

After uploading the disks, creating a virtual network, creating virtual machines etc I got the following super annoying message.

Remote Desktop can’t connect to the remote computer for one of these reasons:1) Remote access to the server is not enabled 2) The remote computer is turned off 3) The remote computer is not available on the network
Neither restarting, nor recreating the machines, nor resizing the machines, nor deleting the RDP endpoint and recreating it helped (if you encounter the same error try these steps nevertheless)
After a bit of trial and error I created the following checklist for future endeavours, maybe it will help you as well. 
  1. Enable Remoting in System/Remote settings (well duh)
  2. Open incoming TCP on port 3389 in the firewall for all network profiles. (Or just turn the whole windows firewall off, Azure doesn't allow any incoming traffic anyway)
  3. Install Azure VM Agent (from here for example). It seems like if you don't do this you will be stuck on the "Installing VM extensions" step of creating the virtual machine
My experience had been that I could only log in after the Installing VM Extensions step completed.