MS Word Interop: Documents.Open throws exception#

The other night I was writing a quick utility app to open word docs and then save as text docs.  Pretty simple I thought except for one unsaid detail about opening word docs via C#.  Following the How to: Open Existing Documents I used the code:

object readOnly = true;
object fileName = @"C:\Test\NewDocument.doc";
    
this.Application.Documents.Open(ref fileName,
    ref missing, ref readOnly, ref missing, ref missing, ref missing,
    ref missing, ref missing, ref missing, ref missing, ref missing,
    ref missing, ref missing, ref missing, ref missing, ref missing);

Now the one thing missing form this is what is “missing”;  “missing” should be define as:

object missing = Type.Missing;

Without defining this correctly you would get a type mismatch exception when trying to open a word document.


		
Sunday, July 30, 2006 2:31:13 AM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Infragistics UltraGrid: Setting Columns At Runtime#

I received a comment from an individual wishing to set columns at runtime before binding an object and not have any other column information show up when bound.  The situation below having a customer object that has a first name, last name, address and phone.   The grid columns are set up to show bound columns FirstName, Address, Phone but not LastName.  There is also an unbound column added called Phone2.  The code that resulted is below.

        private void CreateBindButtonClick(object sender, EventArgs e)
        {
            List<Customer> customers = new List<Customer>();

            //Customer has a FirstName, LastName, Address, Phone
            customers.Add(new Customer("John", "Smith", "123 race", "555-555-5555"));
            customers.Add(new Customer("Bob", "Fanny", "5568 s. block", "555-554-5555"));
            customers.Add(new Customer("Ken", "Little", "6552 gohome", "545-555-5555"));
            customers.Add(new Customer("Joe", "Flint", "6 left turn", "555-595-5555"));
            customers.Add(new Customer("Sue", "Ogden", "871 frank street", "456-555-5555"));

            CreateColumns();
            SetCustomerDataSource(customers);
        }

        private void SetCustomerDataSource(List<Customer> customers)
        {
            //binds to customers without a datamember and hides new columns
            this.ultraGrid1.SetDataBinding(customers, null, true);
        }

        private void CreateColumns()
        {
            //always create a new band. 
            //Each time a band is added it looks to replace the old band.
            UltraGridBand band = CreateBand();
           
            //these are all Bounds columns
            //A Customer contains FirstName, LastName, Phone, Address
            //The LastName column is not added and wil not be shown
            UltraGridColumn phoneColumn = new UltraGridColumn("Phone");
            phoneColumn.Header.VisiblePosition = 2;
            UltraGridColumn firstNameColumn = new UltraGridColumn("FirstName");
            firstNameColumn.Header.VisiblePosition = 0;
            UltraGridColumn addressColumn = new UltraGridColumn("Address");
            addressColumn.Header.VisiblePosition = 1;
            //this is an unbound column thus the second param in the constructor
            UltraGridColumn phone2Column = new UltraGridColumn("Phone2", 3);

            band.Columns.AddRange(new object[]
                {
                    firstNameColumn,
                    addressColumn,
                    phoneColumn,
                    phone2Column
                });
        }

        private UltraGridBand CreateBand()
        {
            UltraGridBand band = new UltraGridBand("NewBand", -1);
            this.ultraGrid1.DisplayLayout.BandsSerializer.Add(band);

            return band;
        }

Hope this helps some of you dealing with the Infragistics controls.

Saturday, July 22, 2006 3:51:10 AM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Working with CAB Workspaces#

After reviewing some code there is a simple concept that I want to share with others working with CAB.  When working with workspaces use and design them in such a way that you trade out one workspace for another at any time.  What I’m referring to is if you are using a tab workspace to do not put controls directly on tab pages of the workspace.  instead create a separate view and show it in the workspace.  By doing this you could change out the CAB TabWorkspace for the Infragistics UltraTabWorkspace without any problems.  

This is a fairly straight forward concept but I’m sure others have run into it or will shortly.

Happy coding! 

Saturday, July 22, 2006 3:08:05 AM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

More Virtual Machine Optimizations#

Optimization 1:

Since my last post I have found a few other things to squeeze a bit more performance out of my machine.  I picked up a new computer today with a standard image on it.  I started up VMWare Workstation and the RAM and CPU looked fine but my disk was going nuts.  I looked at the process explorer and the to CPU intensive task was SYSTEM, so not much help.  Thus enter FileMon, as soon as I started up FileMon I saw the process MSASCui.exe having a massive amount of I/O activity.  Turns out MSASCui.exe is part of Windows Defender.  After knowing this I opened up Widows Defender and disabled the real time protection which fixed the problem.

Optimization 2:

Since I had FileMon out I decided to look inside the virtual machine.  I saw the process TSVNCache.exe having a lot of I/O and CPU activity.  It turns out this is how the fancy icon overlays get applied but this can be optimized.  Open TortoiseSVN settings and click on “Icon Overlays”.  The first thing you will notice is “Show overlays on in explorer” is checked which means only show icons in the explorer.  The other option will show overlays in dialogs like Save and Open dialogs.  When I opened up an explorer window TSVNCache was going through all folders, since I just have two folders that I use with TortoiseSVN I included those directories in the “include paths” which resolved the problem.

TSVNSettings

Friday, July 21, 2006 11:48:57 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Good Lookn' Women and Windows XP? Where are the Cute Puppies?#
WindowsXPMagThe other night I was walking through Barnes and Noble and the Microsoft Windows XP magazine caught my eye.  Why you ask, well there was a good looking woman on the cover.  I stood there looking at it wondering "Why is she on the cover of Windows XP Magazine?", but hey I was looking at it.  I’m sure it helps sell more copies(or at least get more looks) so I fully expect to see cute puppies to start showing up on the cover.
Friday, July 21, 2006 11:16:02 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Optimizing VMWare Workstation#

Lately I have been looking for ways to optimize VMWare workstation.  Below is a list of items that have help the speed of my VM.

  • Defragment VM
  • Defragment Host
  • Disconnect CD Rom for VM (VM->Settings->CD-Rom->Device status)
  • Set memory to not swap (Edit->Preferences->Memory->Fit all virtual memory into reserved host RAM)
  • Make sure your disk set up to use write caching (<DriveLetter>->Properties->Hardware-><PhysicalDrive>->Properties->Policies->Optimize for performance)
  • Disable visual effects for the VM (fade effect) (<Desktop>->Properties->Appearance->Effects->uncheck all)
  • Run VM in full screen mode

VMWare also has many performance counters if you wish to use the performance monitor on the host machine (Administrative Tools->Performance) to see how your VM is performing.

Tuesday, July 18, 2006 2:30:13 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Are you virtualized? Why the hell not!#

In case you have been living in a cave and have not been virtualizing your environments now is your chance.  There is now a choice of free virtualization software:

So crawl out of that cave and get virtualized.

Monday, July 17, 2006 3:20:04 AM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Agile, the other white meat#

If you have not read Brad’s post on Scrummerfall you should.  Brad speaks of a very common pitfall about people adopting SCRUM without adopting any development practices to help the team develop great software. 

Many folks out there find waterfall and all the documentation it brings gives them a sense of comfort.  Maybe it is because they can say “It is in the requirements” when the arguments start at the end of the project when the wrong thing was delivered (yes I’m assuming something was delivered other than paper).  Or the comfort could be a CYA move that people get out of requirements signoff, basically it just creates an argument in waiting.

So why are we seeing Scrummerfall?  Well, my first observation is most methodology in companies is driven by project managers and not involving developers.  The developers have to be part of the culture shift that comes with being Agile since they are the ones actually building the deliverable.

Believing that a methodology is the road map to success is a false hope, in the end it is all about people.  If you have a team that hates each other and a client that does not want to be involved in the project then there is not much chance for success no matter what methodology is used.  Know when to walk away from a deal when you see the people just are not there to make the project be a success, that is also part of the courage of Agile.  Being “Agile” involves a lot more work than just saying it.

Saturday, July 15, 2006 2:08:52 AM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Goodbye Monkey Bean#
I’m very sorry to be passing along the news the that the Monkey Bean is closing at the end of July.  Denver will be losing the best coffee house and bistro it has ever had.  So if you have not visited the Monkey Bean try and get down there before it closes down and see what Denver is losing.
Saturday, July 15, 2006 1:45:18 AM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Checking out the Infragistics AppStyler#

First impressions, WOW!  This is really cool, being able to design the look and feel of a winforms app period is cool.  Now imagine being able to build detailed style sheets for how each control will look.  What is even cooler is being able to have a collection of style sheets to choose from very much in the same way skins work in ASP .NET 2.0.  It is also possible to base style sheets on other style sheets.  Another great feature is being able to apply and design style sheets at runtime using the appstyler runtime component.

Take a look at the online demo.

Wednesday, July 12, 2006 1:35:20 AM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Sony Ericsson W600 does not suck in the end#
As a followup to my last post my new W600 has had no freezing problems and is working very well.  It does have its down sides (slow shutter speed in low light) but overall the phone is pretty good.  Before this phone I never realized how little I use the keypad and the gaming keys are very nice as well.  Hopefully it all stays going well.
Monday, July 10, 2006 6:27:51 PM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Sony Ericsson W600: To Suck Or Not To Suck#

Yesterday I received a new phone, the Sony Ericsson W600.  Looks neat, has a lot of media functions and oh yeah receives and makes phone calls.  One of the features that was not in the manual is the phone freezing every 50 minutes.  By freezing I mean nothing works, not even the power button.  So every 50 minutes I had to take out the battery and turn it on again.

So I stopped by the Cingular store and they exchanged the frozen paper weight for a new one.  Hopefully I will have better luck but my mind is definitely tainted about Sony Ericsson.

Sunday, July 02, 2006 3:46:48 AM (GMT Standard Time, UTC+00:00) #    Comments [0]  | 

 

Resizing VMWare Virtual Disk#

Recently I changed over from VPC to VMWare Workstation.  One of the limiting factors of VPC was the 16GB size limit.  Now with VMWare the virtual disk size can be extended.  Here are the steps I took to extend my VM.

1)  Power off your VM.

2)  Make a backup copy of VM.

3)  Use the VMWare DiskManager to expand the size of disk by using the command prompt.  The vmware.exe is located in the install directory of VMWare.

        vmware-vdiskmanager -x 10GB myDisk.vmdk

      This will allocate the space but it does not expand the main volume.  If you wish you can format and use this new space.  I wanted my main C: drive to be larger which brings me to step 3. 

3)  Download the Knoppix ISO.  This is a fairly large download at ~700mb.

4)  In VMWare Workstation go to “VM->Settings…” and choose the “CD-ROM”.  Under “Connection” select the radio button labeled “Use ISO image”.  Browse to the Knoppix ISO image downloaded in step 3.

VMWareSettings

5)  Turn on the virtual machine and press the “ESC” key to get to the boot menu.  In the boot menu select “CD-ROM Drive”.

6)  Knoppix will now load and show a boot prompt.  At the prompt type “knoppix dma kde”.  You will then see Knoppix start.

Boot

7)  Open a Shell-Konsole and type “su” then “qtparted”

Konsole

8)  QTParted will start.  Right click and Resize your primary volume to include the newly allocated space created from step 3. 

QTParted

9)  Select “Device->Commit” to commit the changes.

10)  Power off and restart your VM as normal.  Windows may run a CheckDisk and then will boot normally.  After that you are good to go.

NOTE:  The above steps do not work with dynamic disks.

Sunday, July 02, 2006 3:29:08 AM (GMT Standard Time, UTC+00:00) #    Comments [3]  | 

 

All content © 2008, John Luif
On this page
This site
Calendar
<November 2008>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
Archives
Sitemap
Blogroll OPML
Disclaimer

Powered by: newtelligence dasBlog 2.1.8102.813

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

Send mail to the author(s) E-mail

Theme design by Jelle Druyts