by Andreas

Windows key stuck in remote desktop session

imageHave you ever experienced the problem where the Windows key gets ‘stuck’ during a remote desktop session? It makes it impossible to write, since every time you click ‘e’ it’s like Windows + E and the Explorer window opens. If you click ‘d’ all windows are minimized, as if you’ve clicked Windows + D. Frustrating, to say the least..

This is supposed to be due to a bug in RDP 6.0, and one way to fix it is to open the on screen keyboard (under Start – Programs – Accessories – Ease of Access – On-Screen Keyboard), and click the Windows key twice.

If you can’t even log into the remote computer because your password contains one of the Windows shortcut characters (like ‘u’, giving you the “Ease of Access” dialog), turn CAPS-LOCK on and hold the SHIFT key while you type. This overrides the Windows key and allows you to use all characters.

Update: some other tips if this doesn’t work:

- lock and unlock the remote computer
- frantic tapping on the Windows key (6-7 times)
- reboot the remote desktop

by Andreas

Windows Phone 8 announced

The next generation of Microsofts mobile OS has been annouced. As expected it will be based on the Windows 8 platform, making developers like us happy since porting applications should be a breeze. But the biggest surprise / disappointment was that the existing WP 7.5 mobile phones will not be able to run it.

As a compensation, version 7.8 will be released. This will give those of us with non compatible devices some of the improvements, like the new home screen options with configurable tile sizes.

We’re all pretty excited about getting our hands on a device and have already started looking into developing for this platform.

More info about the new platform can be found here

imageWinking smile

by Stian

TFS: Discard changes in merge

imagesWhen merging between two branches in TFS, you get a list containing specific changesets that have been checked into the source branch but not merged into the target branch. Sometimes these are changesets that you never want to merge into your target branch and they are just messing up for you (because at some point you are going to hurry through this wizard and accidentally  select “Merge all changesets”).

Well, no need to kill yourself yet: you can always discard these changesets and forget all about them. There is no way to do this in Visual Studio GUI, so you will need to fire up the Visual Studio Command Prompt.

Make sure you are in your workspace directory and write a command like:

tf merge $/project/branch $/project/trunk /discard /recursive /version:C666~C688


Version is FROM changeset ~ TO changeset. If you are only discarding one changeset, you would repeat the changeset like this /version:C666~C666.

It should also be mentioned that you are still required to check in the changes, even though there is essentially no change in the file content.

by Stian

Moles not compiling

Have you ever experienced that you get a long list of compilation errors after adding Moles Assembly on a reference? The other day I was stucked with several compile errors like:

The command ""C:\Program Files\Microsoft Moles\bin\moles.exe" @"D:\…\obj\Debug\Moles\moles.args"" exited with code –1007
‘System.Net.Moles.SFileWebResponse.Dispose(bool)’: no suitable method found to override [D:\...\obj\Debug\Moles\s\m.g.csproj]
Cannot call an abstract base member: ‘System.Xml.XmlReader.Close()’ [D:\...\obj\Debug\Moles\sx\m.g.csproj]
The command ""C:\Program Files\Microsoft Moles\bin\moles.exe" @"D:\…\obj\Debug\Moles\moles.args"" exited with code –1002

I tried to clean, rebuild, restart, re-add, redo and all the other tricks you do when you see a very unreasonable compile error in Visual Studio. The solution seem to be way more unlogical, but it works – so no questions asked at this time.

<Moles xmlns="http://schemas.microsoft.com/moles/2010/">
  <Assembly Name="System.Xml" ReflectionOnly="true"/>
</Moles>


moleThe secret seems to be to add the ReflectionOnly attribute and set it to true.

I should mention that while searching for a good explanation for this, I found little information, but it seemed that everybody affected by this was using Visual Studio 2010 SP1. Still, using this version on many other computers, this was the only time I ran into this issue. And I did so with adding Moles assembly for System.Xml 

by Andreas

How to kill an RDP session on a remote server

My RDP session is locked up, and the remote server is located roughly 16 000km away. I’ve still got contact with it, but when initiating a remote desktop session all I get is a black screen. This is how you kill a RDP session on a remote machine:

First, if the server is on a different domain map up one of the drives to gain access (replace the hidden text with the IP address or server name):

image

Next, get a list of running sessions on the remote server. There are two ways, one using qwinsta and one using session (Windows 7):

image

or:

image

 

Kill the session by using the ID (3 in my case):

image

or

image

And if all else fails, reboot the whole thing:

image

by Njål

Telenor 3G modem + Python + C# = SMS Gateway

Bilde av Option Icon 225 modemThe past year we have been using an Android phone running SmsSync as a SMS gateway (connected to the server through USB). This setup requires that SMSSync is started & running and that the phone is sharing internet through the usb cable +++. If the server rebooted – then the SMS Gateway wouldn’t work until we set it up again. Not an ideal setup.

So I set out to replace it with something that was robust, stable and reboot friendly. It turned out the solution to this problem was in my desk drawer. An old Telenor 3G Option Icon 225 modem that we didn’t use anymore. I inserted a Network Norway SIM card into it – and shoved it into a usb port. The modem was locked and would only accept Telenor SIM cards. I should have guessed it. 

Based on this blogpost by Dogbert – I was able to unlock the modem using these steps (I had to use pywin 2.1.4):

 

  1. Install python 2.6.x (32 bit version): http://www.python.org/download/releases/2.6/
  2. Install pywin32 – 2.1.4 – for python 2.6: http://sourceforge.net/projects/pywin32/files/
  3. Install pyserial: http://sourceforge.net/projects/pyserial/files/
  4. Download the unlocker (http://sites.google.com/site/dogber1/blag/msm-unlock-v1.6.zip) and unpack it (e.g. into the directory C:\msm)
  5. Download a firmware update for the 3G modem from Option or T-Mobile
  6. Unpack the firmware update into the directory used above (e.g. C:\msm)
  7. IMPORTANT: The superfire.exe file of the update is packed. For the newest update, the superfire.exe can be used as it is.
  8. Remove the SIM card from the modem and plug it in . Make sure that you have the latest drivers from the option website installed before you start msm_unlock.py. Also, close all the tools for the stick (‘connection manager’ etc.).
  9. Write down the unlock code. Unplug the stick, replug it and apply the unlock code with msm_apply.py. If the unlock code is not accepted, search the comments for a posting by “muxx” – he has given detailed instructions on how to manually enter the unlock code.
  10. Unplug and replug the stick once more and you’ve got yourself an unlocked 3G modem.

After unlocking the modem it was time to test it. I first started out in Putty – connecting to the COM3 port – which it was running at. Sending some AT* commands worked fine.

I then downloaded Stefay Mayr’s excellent .NET GSMCOMM Library – and imported the DLL’s into a new Visual Studio project. It turned out sending an SMS was extremely easy:

 

//Connect to modem
var comm = new GsmCommMain(3, 9600, 1000); //ComPort, BaudRate, Timeout
comm.Open();

//Send SMS
var sms = new SmsSubmitPdu("Unicode ÆØÅ \n\n Supported!", "+4795441144");
comm.SendMessage(sms);

 

The gateway has been tested the last couple of days – and it seems to work flawlessly.

by Andreas

How to debug custom Sharepoint webparts

If you create a test suite for unit testing your custom Sharepoint webpart you might come across the following warning when running your tests:

The following module was built either with optimizations enabled or without debug information

image

You’ll also find that you’re unable to step into the methods while debugging, as if you don’t have access to the source of the assembly.

 

imageThe reason for this is that Sharepoint modules are signed with a Strong Name Key, because they are supposed to be deployed to the GAC. The solution is therefore to ensure that you deploy your web part before running your unit tests, and you’ll find that the warning message disappears and you’ll be able to debug the web part source as well.

by Njål

C#: Removing duplicate entries using LINQ

Here’s a pretty neat line of code that removes duplicate entries (ID is specified by you) from a IEnumerable:

class MyTestObject{
    public string MyKey;
    public int SomeValue;
    ...
}


//myList contains MyTestObjects - some of these objects
//have the same MyKey value, and I only want objects with unique MyKey values

var uniqueCollection = myList.GroupBy(x => x.MyKey).Select(y => y.First());

by Njål

console.log and Internet Explorer

imageWhen coding/debugging JS I usually work with Chrome and console.log works like a charm. But when you test the same page in Internet Explorer you’ll get a javascript error.

If you then open Developer Tools in IE and hit refresh – the page will work 100% – since IE now has a console object (the developer tools window) it can log to.

The solution is to either remove all console.log statements – or add this at the top of your js file:

 

if console === undefined {
    console = { log : function(){}};
}

 

 

by Stian

Free e-book: Programming Windows 8 Apps

Now hat Windows 8 Release Preview is out, Microsoft wishes to celebrate this by giving away a free e-book to get started developing apps for Windows 8.

You can download the PDF version here (4.34 MB)programming_win_8_apps
Examples from the book can be download here (27.5 MB)

Content:

Chapter 1 The Life Story of a Metro Style App: Platform Characteristics of Windows 8
Chapter 2 Quickstart
Chapter 3 App Anatomy and Page Navigation
Chapter 4 Controls, Control Styling, and Basic Data Binding
Chapter 5 Collections and Collection Controls
Chapter 6 Layout
Chapter 7 Metro Style Commanding UI
Chapter 8 State, Settings, Files, and Documents
Chapter 9 Input and Sensors
Chapter 10 Media
Chapter 11 Purposeful Animations
Chapter 12 Contracts
Chapter 13 Tiles, Notifications, the Lock Screen, and Background Tasks
Chapter 14 Networking
Chapter 15 Devices and Printing
Chapter 16 Extensions
Chapter 17 Apps for Everyone: Localization, Accessibility, and the Windows Store
Chapter 18 Services