Navigating with the Back button in Visual Studio

December 18, 2008

I have often wanted a Back button in Visual Studio, like there is in every browser. For instance if you right click some object and select “Go To Definition” then it would be nice to be able to jump back to where you where before without setting a bookmark or similar.

Turns out there actually are a back button, it’s just not accessible from the Edit menu, you just have to get the correct toolbar visible. To get it:

  • Right click on the toolbar (any button) and select “HTML source editing
  • The back button is the first button (looks like a document and a small blue arrow (Forward is here too)

To save monitor space, the “HTML source editing” can replace the “Text Editor” toolbar if you use keyboard shortcuts for bookmarks and intellisense.

The only minus is that apparently there are no keyboard shortcut for either Back or Forward button.

Update: There are shortcuts … CTRL+- for Back (I couldn’t get forward to work) or use navigation buttons on the mouse.

 


Autodesk Inventor Add-In Project Templates in Visual Studio 2008

October 13, 2008

Autodesk Inventor 2009 lacks support for Visual Studio 2008 in that it will not install a template for it. But luckily the VS2005 templates works fine in 2008 so you can just install them manually. Here is how:

  • Make sure you have installed the Inventor SDK:  %program files%/autodesk/inventor/sdk/DeveloperTools.msi
  • Install the templates: %program files%/autodesk/inventor/sdk/Developer Tools/Tools/Wizards/InventorWizards.msi
  • The templates are normally installed to%program files%/Autodesk/Inventor Wizards/ :
  • Now just copy VCSInventorAddInTemplate.zip from the VS8.0_USRPRJTEMPL folder to your template folder :%my documents%/Visual Studio 2008/Templates/ProjectTemplates/Visual C#/
  • For VB.NET copy VBInventorAddInTemplate.zip to the VB folder under ProjectTemplates
  • If you’re using Visual Studio 2008 Express, then you should copy the .Zips in the VCSEXP8.0_USERPRJTEMPL or VBEXP8.0_USRPRJTEMPL in stead (although the full templates will work)

No start Visual Studio and select new project, under My Templates you should now have a “Autodesk Inventor AddIn” template.


Windows Mobile 6 SDK gives Empty Toolbox in Visual Studio

May 24, 2007

I finally got around to installing the SDK for WM6. Turned out that my Toolbox (in Visual Studio) was completely empty when I started a new WM6 project afterwards.

The solution was to right-click the toolbox and select “Reset Toolbox” from the context menu. This was highly annoying because it of course removed my custom tools (e.g. the Ajax Toolkit). Anyway, at least it’s working.


Emulator 101

July 12, 2006

This is perhaps a newbie topic, but I have seen people use the emulator wrong (IMO), so today I’ll write about the basics regarding the emulator in Visual Studio 2005.

Unfortunately support for Windows Mobile 5.0 devices wasn’t ready when Visual Studio 2005 was released. There was a quite stable beta (Magneto) available, but several things was changed for the final release.

So lets assume you have a clean install of Visual Studio.
Download and install the Windows Mobile 5.0 SDK. Also download and install ActiveSync. If all goes well you should have a couple of new project types in Visual Studio, e.g. Visual C#->Smartdevice->Windows Mobile 5.0 Pocket PC. If you start a new project like this, you have access to the emulator for testing.

I think it’s important how you think about the emulator. I think it is common to simply think of it as a test run-time, i.e. you start it each time you test your application, then close it when you’re done. A better way is to think of it as a real physical device that just happens to be located on your machine. That means you start it and then keep it running in the background. If you press the stop button in Visual Studio (when debugging) the application will stop, but the emulator will keep on running. In this way at least you save some time not having to start the emulator each time.

How to use it:
You should start the emulator through the Device Emulator Manager. Go to Tools->Device Emulator Manager…
This manager is a powerful, but not very user-friendly tool (to start, you have to scroll to get to the Windows Mobile emulators). Start the emulator by right-clicking on Windows Mobile 5.0 Pocket PC Emulator and select Connect. If the emulator has a black screen, it means that is booting – just wait it out. If this is the first time starting the emulator, it may be a good idea to set up any changes (e.g. network connections see below) now, and the just close it again – answering Yes to save the emulator state.

If you do this and then start the emulator again (you might have to click the Refresh button on the DE Manager), you’ll see that it starts much quicker (with any changes you made). This is of course because of the saved state is just loaded in again exactly as it where.

One real neat thing about the emulator is that it is an exact copy of the real thing. So if you don’t have a real device you can play around with it to see how it’s like. If you mess it up, just don’t save the state when you close the emulator, and everything is back to normal (File->Clear Saved State (in emulator) if you accidentally save a messed up state).

If you start your program in Visual Studio (and select the Emulator in the dialog) it starts inside the emulator. An extremely cool thing is that you can set breakpoints and do remote debug against it (as you can do with a real device).

How to connect it to the Internet:
You have to use ActiveSync to do this. Make sure it is installed, then when the emulator is running – right click it in the Device Emulator Manager, and select Cradle. After a few seconds ActiveSync will pop-up after having noticed the new device. Just click cancel if ActiveSync wants to set up a profile for the device, and click Stop if it tries do synchronize. As you can see ActiveSync doesn’t know that it is an emulator, to it this is just another device connected to the PC via a cable.

You now have access to the emulators file-system either by clicking Explore in ActiveSync or selecting “Mobile Device” in Windows Explorer (under My Computer). Select My Windows Mobile-Based Device to go to the root of the device. The emulator should now be able to connect to the Internet through ActiveSync (make sure ActiveSync is not blocked by a firewall). Verify this by starting Internet Explorer in the emulator and click on the “Windows Mobile” logo (picture).

Tip: If you get the cannot connect error, go to Settings->Connections->Advanced. Then click Select network and select My work network in the topmost dropdown (so that both have this selected). Then click OK in top right corner twice. Back in IE try clicking on the logo now – usually that does the trick


Testing with localized versions of Windows Mobile

July 10, 2006

For testing purposes it is very useful to be able to run your program on different language versions of Windows Mobile. Luckily you don’t have to buy different physical devices, just change the OS image in the emulator.

To do this start by downloading the images (note: there are different images for smartphones). After downloading the MSI files simply install them as normal, and the new OS will appear in the Device List with the 3 letter abbreviation as a prefix.

Unfortunately it installs 8 different devices (items in the list) for each language, and if you plan to install a lot of different languages this can be annoying. Another way to change the OS is to simply use the image binary itself. The binary is located at <path where you installed the image>/Deviceemulation/0414/ the one you probably want is called PPC_xxx.bin (xxx = language code) (to get it – either extract it from the MSI or install, get the bin then uninstall the image).

Go to the options for the emulator and select the binary in the OS Image Name textbox. After restart (and clearing state!) you are set to go!


Setting the emulator’s available RAM

July 9, 2006

It is useful to be able to change the Device emulators available RAM, however if you select File->Configure… in the emulator you are not able to change the values!

The supposed reason for this is that Windows Mobile does not support changing/adding RAM on the fly (if you put more RAM into your physical device, you have to restart it to be able to use it).

To change it: In Visual Studio, select Tools->Options…, then select Device Tools->Devices (You can also click Device Options on the Device toolbar). Select Windows Mobile 5.0 Pocket PC Emulator in the list to the left, and click Properties. Then click Emulator Options.
If you check the “Specify RAM size” checkbox, you are able to change the RAM (remember to restart the emulator!).

There are also some other important options here, I’ll come back to them later.

A final gotcha – if you have saved the emulator state any changes to the RAM will not be applied. You have to clear the saved state (in the emulator: File->Clear Saved State) and reset the Emulator for it to update.


Missing error messages

July 7, 2006

When debugging against a physical device you may get this message when breaking on an exception:
“An error message cannot be displayed because an optional resource assembly containing it cannot be found”.

It’s extremely annoying because it doesn’t tell you what ‘optional resource’ that is missing. Luckily I found a clue on the Microsoft Forums (link).

If you get this message you should try to install the file “System_SR_ENU_wm.CAB” from the Mobile 5.0 SDK (mine was at %program files%\Visual Studio 2005\SmartDevices\SDK\CompactFramework\2.0\v2.0\
WindowsCE\Diagnostics ).

Note that the ENU parts corresponds to English-US so if you have set a different locale on your device (Start->Settings->System tab->Regional Settings) you should chose the corresponding .CAB file (if your locale don’t have a CAB hopefully the ENU will work, although I haven’t tried it).

Also note that the file can be uninstalled as a normal program (Start->Settings->System tab->Remove Programs).

What’s bugging me is that it seems like this problem suddenly appeared (i.e. I got error messages before), and I don’t know why. Ah, well – as long as it works…

Edit: Tip – if it doesn’t work, try changing your locale to the language you installed. (Settings->System tab->Regional Settings)