Some notes on software development... RSS 2.0
# Friday, 23 August 2013

MakeTechEasier.com have a great article describing how to shrink a VirtualBox disk image with lots of screenshots, but here are the basic steps for shrinking a VirtualBox image that runs a Windows 7 guest OS. This only works on VDI disk images.

On the Windows 7 guest OS follow these steps:

  1. Uninstall any unused programs
  2. Delete any files you don’t need
  3. Run Disk Cleanup Start->All Programs->Accessories->System Tools->Disk Cleanup
  4. Download CCLEANER and run it.
  5. Run Disk Defragmenter Start->All Programs->Accessories->System Tools->Disk Defragmenter
  6. Download SDELETE and run this command: sdelete –z C:\

The guest Windows 7 OS has now had all the free space zeroed out and is ready for compacting. So from a command line on the host OS:

  1. Navigate to the VirtualBox installation folder, on my Windows 7 x64 OS it’s located here: C:\Program Files\Oracle\VirtualBox\
  2. Run: vboxmanage modifyvdi YOUR-VDI-FILENAME.vdi compact

Job done!

Links:
VirtualBox
How To Shrink Your Virtualbox VM And Free Up Space For Your Hard Disk

Friday, 23 August 2013 08:04:31 (GMT Standard Time, UTC+00:00)  #    -
Virtualisation
# Wednesday, 31 July 2013

Whilst tying to open a legacy app at work today there were multiple ‘Object Library Not Registered’ errors. Looking at the offending form log file shows some Microsoft common controls that don’t appear to get loaded correctly:

image

Current development environment is Windows 7 64-bit. Strangely I has previously managed to build the same application from the VB6 IDE a few months ago. Having searched the web it looks like the automatic upgrade of IE10 has broken something with the registration of MSCOMCTL.OCX….thanks Microsoft.

The Answer
Apparently uninstalling IE10 fixes the issue. For me this is not an option as I require IE10 during everyday development.
There were also many posts about re-registering MSCOMCT.OCX & MSCOMCT2.OCX from the SYSWOW64 folder…this did not work for me.

The post mentioned above contains the answer, see post #60
Register the MSDATSRC.TLB file using REGTLB.EXE from an elevated visual studio command prompt like so:

regtlb C:\Windows\SysWOW64\msdatsrc.tlb

image

Bingo! VB6 IDE is up and running……can’ believe I’m still mentioning VB6 in 2013 :-/

Links:-
Windows 7 64-bit -- Library Not Registered problem

Common controls do not load in VB6 after IE10 installation

Wednesday, 31 July 2013 16:57:51 (GMT Standard Time, UTC+00:00)  #    -
VB6
# Tuesday, 09 October 2012

The default MSBUILD xml produced by Visual Studio 2010 is missing <Private>True</Private> for the reference.

To fix this simply set the reference Copy Local to False, save the file, then set Copy Local to true.

The correct MSBUILD xml is now produced in the project file.

 

Links:
Stack Overflow - reference dll not copying to bin with deployment project causing error

Tuesday, 09 October 2012 13:48:46 (GMT Standard Time, UTC+00:00)  #    -
Visual Studio
# Wednesday, 06 June 2012

This post is an extension to How to Bind to Enums on JSON Objects in ASP.NET MVC 3 from www.codetunnel.com so please see that excellent post for more details.
This class basically extends the MVC default model binder to include Enum property support. This allows models with enum properties to be correctly set (bound) when JSON is sent to the controllers action method.

The class is nearly identical to codetunnel’s version, I just included the Enum.Parse statement so that it also supports enum name values being passed in.

 

So the class looks like this:

    public class DefaultModelBinderEx : DefaultModelBinder
    {
        /// <summary>
        /// Fix for the default model binder's failure to decode enum types when binding to JSON.
        /// </summary>
        protected override object GetPropertyValue(
            ControllerContext controllerContext,
            ModelBindingContext bindingContext,
            PropertyDescriptor propertyDescriptor,
            IModelBinder propertyBinder)
        {
            var propertyType = propertyDescriptor.PropertyType;

            if (propertyType.IsEnum)
            {
                var providerValue = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);

                if (providerValue != null)
                {
                    var value = providerValue.RawValue;

                    if (value != null)
                    {
                        var valueType = value.GetType();

                        if (valueType == typeof(string[]))
                        {
                            valueType = typeof(string);
                            value = ((string[])value)[0];
                        }

                        if (!valueType.IsEnum)
                        {
                            return Enum.Parse(propertyType, value.ToString());
                        }
                    }
                }
            }

            return base.GetPropertyValue(controllerContext, bindingContext, propertyDescriptor, propertyBinder);
        }
    }

..and then you just need to update the Application_Start method in the Global.asax file with this line:

ModelBinders.Binders.DefaultBinder = new U413ModelBinder();

Now your default binding will support models with Enum properties.

Wednesday, 06 June 2012 13:20:35 (GMT Standard Time, UTC+00:00)  #    -
ASP.NET MVC
Navigation

Sign In
Extras
Statistics
Total Posts: 116
This Year: 0
This Month: 0
This Week: 0
Comments: 36
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2018
Hadrian Phillips

All Content © 2018, Hadrian Phillips
DasBlog theme 'Business' created by Christoph De Baene (delarou)