Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Thursday, May 22, 2014

Getting Started with the Modern.ie VMs on VirtualBox with IIS Express

Microsoft has made pre-packaged Virtual Machine images available for purposes of testing different versions of IE via the modern.ie web site.  This blog post describes how you can get these VM images loaded into the free VirtualBox software and talking to an IIS Express web site running on your local PC.

Warning: These instructions were tested on VirtualBox 4.3.12, the latest version as of May 22, 2014.  By default, this is set up to make your VM get Internet access via your PC using a virtual NAT.  The VM will be assigned an IP address by a built-in DHCP server that runs on the VirtualBox Host-Only NIC.  Unless you start changing things, this should all remain on your local PC and your VM won’t accidentally get an IP address from your network’s real DHCP server – but your mileage may vary and you should confirm that!  The author of these instructions makes no warranty that these settings may not cause a problem on your particular network, so you should proceed with caution and at your own risk.  Do not follow these instructions if you are not comfortable with the concepts of IP addresses, network cards, virtualization, or web servers – or what havoc a rogue DHCP server could cause.

  1. Download and install Virtual Box: http://www.virtualbox.org (yes I know it’s Oracle, but it is gratis and it works even on some older Core2 processors that Hyper-V doesn’t support)
    • Be sure that Virtual Box is fully installed before starting the next step because installing the drivers will temporarily disable your physical NIC.
  2. Open your Network control panel and ensure that the “VirtualBox Host-Only Network” adapter is set to use the static IP 192.168.56.1 and the Subnet Mask is 255.255.255.0.  You can leave the DNS server blank.
  3. Download the appropriate VM image from the modern.ie web site
    • Open this page: http://modern.ie/en-us/virtualization-tools#downloads
    • Select "VirtualBox on Windows".
    • Download part1.exe and all of the .rar files for the particular VM you want.  Save these to a temporary "downloads" folder.
      ie8-modern-ie
    • When all of the files are downloaded, run the EXE and allow it to extract the .OVA file.  Once you have the .OVA file, you can then delete the corresponding .EXE and .RAR files.
    • Move the .OVA file to a “special place”.  This is the file you have to run to set up a new VM of that variety.
    • Run the .OVA file by double-clicking on it.  You will get an "import" screen in Virtual Box.
      • Change the "Virtual Disk Image" path to point to the appropriate place where you want the virtual hard drive to live for the VM you’re creating.
      • Check the box to reinitialize the MAC addresses.
      • Click “Import”
        image
  4. When the import is complete, go into the settings for the VM.  On the Network tab, confirm that network Adapter 1 is attached to NAT.  Click OK.
  5. Boot the VM by selecting it and clicking the Start button in the button bar.
  6. Note: the login information on all of the modern.ie VMs is IEUser and Passw0rd!
  7. When the VM boots up, open a command line in the VM and run ipconfig /all
    • The first VM you launch should have an IPv4 address like 10.0.2.15 which was served by the virtual DHCP server on 10.0.2.2.
  8. The next step assumes that you already have a working site in IIS Express.  If not, use Visual Studio or some other tool to create one.
  9. In your “Documents” folder on the host PC, open the IISExpress\config\applicationhost.config file.
    • Find the web site that you want to set up for the VM to use and add an extra entry to the bindings tag to allow IIS Express to listen on the internal VirtualBox IP address (in my example, the site was set up on port 59707 – you can use whatever port you wish) and save the config file:
      image
  10. Start the site.
  11. Try to access the site by visiting http://192.168.56.1:59707 (or whatever port number that you used) – it should hopefully work as expected.

Have fun getting your new site working with old IE!

Tuesday, August 14, 2012

Fix: Crystal Reports Shows Red X Across Entire Page When Report Run Inside Visual Studio

I was googling (with Bing AND Google) like crazy for a solution to this, but didn't find one from any of the open resource sites, so I figured I'd blog about my fix for this to help the next poor dev to come along.

I was getting user feedback that one of the Crystal Reports in an application that I support was intermittently crashing.  When I ran the report in Visual Studio, on certain pages of the report, I observed a red X across the whole screen with a white field.  Obviously something was very wrong here!!!

Red X on Crystal Report 

It boiled down to that there was a null value being used in one of my formula fields, and Crystal seems to raise an exception for nulls when they are used as part of certain types of formulas and not converted manually to an actual value first.  I didn't know which field was causing the issue so I just started a divide and conquer approach.  I suppressed all fields and confirmed that the report worked (select a bunch of fields, Right Click... Format Multiple Objects... Suppress).  Then I started un-suppressing a few objects at a time until the report started failing again.  Now I knew where the problem was (or at least one of the problems).

I then right-clicked one of the formula fields and chose "Find In Formulas" to open the formula workshop.  I drilled down to the formula field (it could be in any of the sections) and found the offending one.  Note that it could be a "normal" formula field or even one of the special formatting formulas (like "if this field's value is true, format as green").

image

I believe the "right way" to fix it is to handle NULLs properly using ISNULL() (which returns a boolean unlike the T-SQL ISNULL() ) or another appropriate method in Crystal for each and every one of your formulas.  This MSDN article describes that.  However, there exists another workaround as well which should be fine for most simple cases.  On the top of each formula when you click into the white field where the code actually lives, you can change this box:

Exceptions For Nulls

To say this:

Default Values for Nulls

If you choose "Default Values For Nulls", Crystal will substitute "" for null strings and an appropriate flavor of 0 for numeric fields.  Here's some documentation that oddly seems to skip booleans.

This dropdown selection is per-formula, so it might take a lot of work to go through and change every formula in the tree view (don't forget to look at the formatting formulas too!!!), but if your report is crashing with the dreaded red X and you don't know why, this may get it working again.

Wednesday, July 18, 2012

Enabling "Open Project Folder" for project types that don't support it

One annoying thing about SSIS (2008) and some of the other project types in Visual Studio is the lack of an "Open Project Directory..." option on the project right-click menu.  Visual Studio's "Tools" menu can provide a work-around this.
 
Go to Tools... External Tools... and add a new entry with the following properties:
Title = &Open Project Folder
Command = explorer.exe
Arguments = "$(ProjectDir)"
Initial Directory = "$(ProjectDir)"

image


Now, when I select my SSIS project, I can choose "Tools... Open Project Folder" (or ALT+T,O,<ENTER>), and the correct folder will open in Windows Explorer.
 
Using macros such as $(ProjectDir), $(SolutionDir), $(Configuration), and others can come in very handy when you find yourself doing the same types of things over and over in Visual Studio.  Here is the documentation for all other built-in VS macros:  http://msdn.microsoft.com/en-us/library/c02as0cs.aspx