World IPv6 Launch
Tomorrow is World’s IPv6 launch. Are you ready?
If you are using InnoSetup for your installation needs you might be familiar with AppMutex parameter. You just give it SomeUniqueValue and make sure that Mutex with same value is created within your application. That way setup will warn you if your application is already running. Useful function indeed.
Simplest way to implement this would be:
static class App {
private static Mutex SetupMutex;
[STAThread]
static void Main() {
using (var setupMutex = new Mutex(false, @"Global\SomeUniqueValue")) {
...
Application.Run(myForm);
}
}
}
And this code will work if you deal with single user. In multi-user environment this will throw UnauthorizedAccessException. Why? Because Mutex is created within current user security context by default. To have behavior where any instance, no matter which user, will keep our Mutex alive, we need to adjust security a little.
Since making null security descriptor in .NET is real pain, we can do next best thing - give everybody an access. With slightly more code we can cover multi-user scenario.
static class App {
static void Main() {
bool createdNew;
var mutexSec = new MutexSecurity();
mutexSec.AddAccessRule(new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null),
MutexRights.FullControl,
AccessControlType.Allow));
using (var setupMutex = new Mutex(false, @"Global\SomeUniqueValue", out createdNew, mutexSec)) {
...
Application.Run(myForm);
}
}
}
P.S. No, giving full access to mutex that is used purely for this purpose is not a security hole…
Tomorrow is World’s IPv6 launch. Are you ready?
Last week I finished my work in Virginia. Next week I have to start anew in Washington. Since that leaves one week and couple of thousand miles in between, road-trip seemed like perfect choice for wife, kids and me. How hard can it be?
One of items that I brought on trip to keep kids occupied were DVDs with Croatian cartoons and, since car did have a DVD player, third day of a trip seemed like a perfect time to introduce that possibility to kids. We hyped them a little just to bring anticipation levels to brand new high.
Daddy placed DVD into slot. Player took it and churned a little. And then threw DiscRegionError. No play for you. My kids were full of joy when I informed them that our ORIGINAL DVDs were not playable.
What is solution? Buying brand new DVDs in order to bring another boost to dying american movie industry was not really a choice. It seems that US market is quite limited when it comes to Croatian cartoons.
Another obvious one would be removing region protection. Of course this is quite illegal in US since DMCA and it’s protection circumvention clause. It is only logical that while KKK has right to freedom of speach, I would be forbidden to play my own original DVDs. Nice to see priority management in action.
And even if I was in mood for breaking law, I had no DVD media with me. We were on major interstate roads and entering a town in order to search for writtable DVD media seemed like a time wasting move. Single laptop with DVD writter would anyhow run out of battery long before I could copy them all.
I just gave up. Kids had more fun with their toys and we all learned valuable lesson. If I have only brought pirated DVDs I would not have this issue.
VHD Attach is updated once more.
One personal annoyance is finally fixed. It was always difficult for me to find auto-mounted disks. I auto-mount them right after installation and then, month later, I cannot find where they are exactly. Now all those disks will be added to list of recently used files.
With that sorted out I proceeded with adding taskbar progress for creation of fixed drive. Funny thing that someone who wrote how easy adding it to your application can be took sweet time to do it himself. Regardless of shame, now operation progress can be checked with just quick taskbar glance.
For detail-obsessed there is parsing of dynamic disk header. Not much, but it will make someone happy.
Of course there was some generic bug bashing but let’s not get into it.
Check pages for download or use built-in upgrade.
[2012-05-31: Yes, there is bug-fix out already. :)]
Quite often I see code that overrides ToString()
just for the sake of a tooltip when debugging. Don’t misunderstand me, I like a good tooltip but, if that is single reason for override, there is other way to do it.
.NET has [DebuggerDisplay](http://msdn.microsoft.com/en-us/library/x810d419.aspx)
attribute. Simple class could implement it like this:
[DebuggerDisplay("Text={Text} Value={Value}")]
internal class XXX {
public string Text { get; private set; }
public float Value { get; private set; }
}
And that will result in debugging tooltip Text="MyExample" Value=3.34
. Not too shabby. But what if we want our display without quotes and with different rounding rules?
There comes in expression parsing part of that attribute. Anything withing curly braces ({}) will be evaluated. So let’s change our example to:
[DebuggerDisplay(@"{Text + "" at "" + Value.ToString(""0.0"")}")]
internal class XXX {
public string Text { get; private set; }
public float Value { get; private set; }
}
This expression will result in tooltip that shows MyExample at 3.3
. And I see that as an improvement.
Nice thing never comes without consequences. In this case advanced formatting is dependent on language used. If you stick to single language you will not see anything wrong. However, if you mix and match (e.g. C# and VB) you might end up in situation where DebuggerDisplay expression is evaluated by language currently being debugged regardless of language which it was written in.
I usually ignore that risk for sake of convenience.
P.S. And anyhow worst thing that could happen is not seeing your tooltip in very rare situations. Your actual program will not be affected in any manner.