I've been spending a lot of time on .NET 3.0 lately. One of the areas that is a lot of fun for me to dig into is WPF, since it's such a departure from my usual data/service/remoting pigeon-hole. I know a lot of people hate grids as a metaphor, but when I saw this free WPF grid demo, I knew grids would be with us for yet another generation of user interfaces. Long live the grid!!
I wanted to generate a script that would both create a copy of my database schema and also populate it with the data that is already in the tables. In the past, this meant you needed another application (e.g. Database Workbench; although it does much more than just that one thing, and is a very useful tool), or you could use a stored proc to generate a script.
Last month, Microsoft released the MSSQL Database Publishing Wizard. This tool can easily generate a script with the database schema and corresponding INSERT statements. It also has integration to VS.NET 2005, which is a very nice bonus.
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
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?
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); } } } }
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.
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".
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.
|