Thoughts from Dan Miser RSS 2.0
 Monday, April 30, 2007
On my new Vista system, I was trying to install some software from a vendor that I trust. The problem is, the vendor doesn't really write software for the general public, so it's very tightly packaged to try and make it idiot-proof. Unfortunately, I would receive a DEP exception every time I would try to run the installer. I went to the DEP protection configuration screen (Start + Pause | Advanced | Performance Settings | Data Execution Prevention), and that is either an "all programs are protected" or "don't check these applications" choice. To make matters worse, I tried to add msiexec.exe to the exception list, and it wouldn't let me do it. So I had to disable DEP altogether.

In order to totally disable DEP, I used this command from tech-recipes:

bcdedit.exe /set {current} nx AlwaysOff

My application installed perfectly. As a side-note, You can re-enable DEP with this command:

bcdedit.exe /set {current} nx AlwaysOn 
Monday, April 30, 2007 8:00:08 AM (Central Standard Time, UTC-06:00)  #    Comments [1] -
Vista
 Tuesday, April 10, 2007
I didn't think it was possible for Dell to stuff any more garbage on a computer (forced install of Acrobat, anti-virus, AOL, etc.), but I guess I was wrong. It turns out that Dell partnered up to install Lojack on every single laptop they sell. That is not an insignificant number of laptops. They also force the $49.99 purchase price of the Lojack system to have it installed and activated. Of course that's just for one year of service.

For the first time ever, I just cancelled a Dell laptop order (that was due to be shipped to me next week). I'm sure my measly order means nothing to them, but I am now fed up with being forced to pay for garbage like this when I don't want or need it, and didn't order it. Any recommendations for a real nice dual core, development-class laptop for around $1200?

Tuesday, April 10, 2007 5:11:50 PM (Central Standard Time, UTC-06:00)  #    Comments [11] -

 Thursday, March 22, 2007
The following application shows a subtle difference in dealing with enums using Enum class methods and when using reflection. In this sample, I am looking to find the number of elements in the enum. Enum.GetValues and Enum.GetNames are not implemented in the .NET Compact Framework, so I cannot use those methods.

By using reflection, I figured I would gain the upper hand and take control of my enum woes. Unfortunately, calling GetFields on an enum type adds an extra entry named "value__" to the returned list. After browsing through the decompilation of Enum, I found that value__ is just a special instance field used by the enum to hold the value of the selected member. I also noticed that the actual enum members are really marked as static. So, to get around this problem, all you need to do is call GetFields with the BindingFlags set to only retrieve the public, static fields (see the code example below).


using System;

using System.Reflection;

 

namespace EnumReflection

{

    class Program

    {

        enum Test

        {

            One,

            Two,

            Three

        }

 

        static void Main(string[] args)

        {

            Type enumType = typeof(Test);

 

            //The following prints 3, but we can't use this method in .NET CF

            Console.WriteLine(Enum.GetValues(enumType).Length);

 

            FieldInfo[] infos;

            infos = enumType.GetFields();

 

            //The following prints 4! There is an extra, unrelated Int32 entry named "value__"

            //at the zeroth element of the info array.

            Console.WriteLine(infos.Length);

 

            //The following prints the 3 enum elements. The value__ field is removed by

            //specifying we only want the public, static fields.

            infos = enumType.GetFields(BindingFlags.Public | BindingFlags.Static);

            foreach (FieldInfo fi in infos)

            {

                Console.WriteLine(fi.Name);

            }

        }

    }

}

Thursday, March 22, 2007 10:16:48 AM (Central Standard Time, UTC-06:00)  #    Comments [0] -
.NET | Compact Framework
 Thursday, March 15, 2007
I needed to implement a dialog that could be used to stop from displaying over and over again. We've all seen countless variations on this theme. I also didn't want to go to the extent of using hooks to accomplish this.

I came across the SHMessageBoxCheck function, and it appears to give me what I need. Granted, it is far from perfect, but it works for me. I used the declaration from PInvoke.net, but I received a PInvokeStackImbalance exception from MDA. I modified the DllImport to use PreserveSig to true, and the error is gone. I did update the wiki to mention this finding, so hopefully others will be able to verify.

All in all, this function works well. But, by trying to be lazy and use a pre-existing solution, it definitely took longer than it would have had I written my own custom dialog. I'm sure that won't be the last time that happens. ;-)

Thursday, March 15, 2007 8:49:05 AM (Central Standard Time, UTC-06:00)  #    Comments [1] -
.NET
 Wednesday, March 14, 2007
I've been looking all over the place for a fairly simple file-sharing application. My needs are pretty simple: Have 2 users share a file repository where changed files get pushed to the other person over the Internet automatically. Like I said, simple, no? I'm not asking for an enterprise-level application, a generic solution like version control, or a tool to cure cancer. I came across a very promising application called Tubes.

Tubes has a nice web site, a good overview video, blogs, a community forum, and other nice touches. However, the application is absolutely dreadful. To start, they FORCE you to store all of the files in a "Documents and Settings" subdirectory. So if you use partitioning, or even would just like to store your files in another location or drive, you're just plain out of luck. I reported this deficiency months ago. They just released a new Beta 4 download of their tool, but this feature didn't make the cut. Tubes is written in .NET. Addressing this feature would taken all of about 1 hour of coding and testing. It's a shame, because I like the concept, and I like the supporting community artifacts. But I guess that's why the feature didn't make it - this product is all about hype, concept, and promise, and not little things like shipping with a feature set that actually is usable.

With that rant out of the way, what are your suggestions for a pretty simplistic file sharing tool? I don't want to take on yet another side project to do in my "spare time".

Wednesday, March 14, 2007 1:45:51 PM (Central Standard Time, UTC-06:00)  #    Comments [5] -

 Thursday, March 08, 2007
I read Scott Hanselman's well-written article HOW TO: Debug into a .NET XmlSerializer Generated Assembly. I can add a few more little (and most likely obvious) things to his article:
  • This still works in .NET 2.0.
  • If you just do an Add New Item to add a new Application Configuration File to your project in VS, you can just paste the debugging flags in, and the config file will get deployed to the application directory automatically.
  • You can just Step Into (F11) the call to x.Serialize, and you will be taken into the proper generated file. You may want to open the file manually as Scott mentioned, but I find it to be faster to press F11, and then go to the place in the file I want to debug.

In the end, we ended up writing our own serialization for .NET CF due to one too many bugs.

Thursday, March 08, 2007 2:26:21 PM (Central Standard Time, UTC-06:00)  #    Comments [0] -
.NET | XML
 Monday, March 05, 2007
I've been listening to more podcasts lately (e.g. .NET Rocks, Hanselminutes, etc.), and they certainly contain good information. When listening to podcasts on my PC via Windows Media Player, I tend to set the playback rate to a higher rate in order to compress time.

When playing back audio files on an iPod, you can do the same type of thing, but you have to know the secret. You need to have a 4th generation iPod, have your audiobook/podcast encoded as an AAC file, and change the Settings > Audiobooks setting in the iPod to Faster. After doing that, I am now traveling through time around 25% faster. :-)

Monday, March 05, 2007 1:14:42 PM (Central Standard Time, UTC-06:00)  #    Comments [1] -

 Wednesday, February 21, 2007
A while back, I wrote about how to use the Data Access Application Block (DAAB) in the Compact Framework. While this code works just fine, it turns out that Enterprise Library 3.0 will support this natively. I really like the TableExists method that they added, too.

David Hayden wrote a couple of articles about this here and here.

Wednesday, February 21, 2007 5:23:26 PM (Central Standard Time, UTC-06:00)  #    Comments [0] -
.NET | ADO.NET | Compact Framework
Navigation
Archive
<April 2007>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345
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 2008
Dan Miser
Sign In
Statistics
Total Posts: 310
This Year: 25
This Month: 0
This Week: 0
Comments: 605
All Content © 2008, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)