Whenever you want to test a REST API, Postman is a great tool. It allows configuring all aspects of a request: Method (GET, POST, etc), Headers, keeps previous attempts in history, manages collections of requests and saves them and it is installed as a Chrome extension, bringing it only two clicks away. It does everything! ... or does it? Short story long: no!

Reported as a problem here: Referer header is not sent when set in Postman, the issue appears to be that some headers are "protected" by Chrome, therefore unusable. Well, it is a bug in the sense that Postman should tell you that when you write something there it is completely ignored! There is a solution, that can be found as a link in the bug report, but it involves installing other crap and running Python scripts. Ugh!

Here is a list of the Chrome protected headers:
  • Accept-Charset
  • Accept-Encoding
  • Access-Control-Request-Headers
  • Access-Control-Request-Method
  • Connection
  • Content-Length
  • Cookie
  • Cookie 2
  • Content-Transfer-Encoding
  • Date
  • Expect
  • Host
  • Keep-Alive
  • Origin
  • Referer
  • TE
  • Trailer
  • Transfer-Encoding
  • Upgrade
  • User-Agent
  • Via

So whenever you believe that some web site has used a magical solution to detect your sneaky attempts to access their web API or site and you are wondering what, just remember that it is most likely a Referer header that Postman (via Chrome) silently ignored.

I was trying to do a simple thing: configure a daily rolling log for log4net, meaning that I wanted that log files would be created daily and the name of the files would contain the date. The log was already configured and working with a normal FileAppender, so all I had to do was find the correct configuration. There are several answers on the Internet regarding this. I immediately went to the trusty StackOverflow and read the first answers, copy pasted lazily, and it seemed to work. But it did not. So warning, the first answer on StackOverflow about this is wrong.

So, my logs had to be named something like Application_20150420.log. That means several things:
  • The name of the appender class has to be set to log4net.Appender.RollingFileAppender
  • The name of the log files need to start with Application_ and end in .log
  • The name of the log files need to contain the date in the correct format
  • The logger needs to know that the files need to be created daily

This is the working configuration:
<appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
<filter type="log4net.Filter.LevelRangeFilter">
<acceptOnMatch value="true" />
<levelMin value="DEBUG" />
</filter>

<file type="log4net.Util.PatternString" value="c:\logfiles\Application_.log" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyyMMdd" />
<preserveLogFileNameExtension value="true"/>
<staticLogFileName value="false" />

<lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %-5level %logger - %message%newline"/>
</layout>
</appender>

As you can see, it is a little counter-intuitive. You do not need to specify the date in the file name, it will be added automatically, and you absolutely need to use preserveLogFileNameExtension, otherwise your files would look like Application_.log20140420

and has 0 comments
Because of idiotic firewall rules at my workplace I am forced to use Hangouts rather than Yahoo Messenger as an instant messenger. I am not going to rant here about which one is best, enough to say that most of my friends are on YM and being on Hangouts doesn't help. Hangouts has many annoyances for me, like its propensity to freeze when you lose Internet connection often or the lack of features that YM had. In fact I was so annoyed that I planned to do my own professional messenger to rule them all. But that's another story.

I am writing this post because of a behaviour of the Google Hangouts instant messenger (which, to be fair, is only a Chrome extension), mainly that after a while, the green traybar icon of the messenger goes in the "hidden icons" group. I have to customize it every day, sometimes twice, as it seems to reset this behavior after a period of use, not just on restarts. There is a Google product forum that discusses this here: System tray icon resets every time Chrome is started where you also see a few comments from your truly.

I immediately wanted to create a script or a C# program to fix this, but at first I just searched for a solution on the web and I found TrayManager, a C# app that does what the "Customize..." tray link does and more. One of the best features is a command line! So here is what you do after downloading the software and installing it somewhere: TrayManager.exe -t "Hangouts" 2. Now, probably that doesn't solve the problem long term. It is just as you would go into the Customize... link, but it's faster. Also, it has no side effects if run multiple times, so you can use Task Scheduler to run it periodically. Yatta!

I've heard of for some time now, but never actually tried anything on the site. Today I tried a course that teaches the basics of R, a statistics programming language akin to Matlab, and I thought the site was great. I suspect it all depends on the quality of the course, but at least this one was very nice. You can see my "report card" here, although I doubt I am going to visit the site very often. However, for beginners or people who quickly want to "get" something, it is a good place to start, as it gives one a "hands on" experience, like actually coding to get results, but in a carefully explained step by step tutorial format.

I have at work a very annoying HTTP proxy that requires a basic authentication. This translates in very inconsistent behaviour between applications and the annoying necessity of entering the username and password whenever the system wants it. So I've decided to add another local proxy to the chain that handles the authentication for me forever.

This isn't as easy as it sounds. Sure, proxies are a dime a dozen, but for some reason most of them seem to be coming from the Linux world. That is really bad user interaction, vague documentation and unhelpful forums where any request for help ends up in some version of "read the fucking manual". Hence I've decided to help out by creating this lovely post that explains how you can achieve the purpose described above with very little headache. These are the very easy steps that you have to undertake:
  1. Download and install Privoxy
  2. Go to the Program Files folder and look for Privoxy. You will need to edit two files: config.txt and user.action
  3. Optional: change the listen-address port, otherwise the proxy will function on port 8118
  4. Enter your proxy authentication username and password in the fields below and press Help me configure Privoxy - this is strictly a client base Javascript so don't worry that I am going to steal your proxy credentials...
  5. Edit user.action and add the bit of text that appeared as destined for that file.
  6. Edit config.txt, look for examples of forward and add to it the bit that belongs to config.txt and replace proxy:port and the domains and IP masks with the correct values for you
  7. Restart Privoxy
  8. Configure your internet settings to use a proxy on 127.0.0.1 and the port you configured in step 2 (or the default 8118)

This should be it. Enjoy!

Username:
Password:


and has 41 comments
I realize that the original format of the post was confusing, so, before you start reading it, here is a summary of solutions. You should read on afterwards in order to understand the context of each solution in part, though:
  • Torrents seem to keep a reference to some of the proxy settings when they started downloading. I don't have a clear solution for this, in my case changing the configuration of the proxy and restarting both proxy and Bittorrent eventually solved it. An aggressive solution is to remove all of your torrents and readd them later.
  • Sometimes the settings file gets corrupted or the settings don't make a lot of sense. Save all your ongoing downloads, remember all the relevant settings - like download folder -, stop Bittorrent, go to your user's Application Data folder and remove the settings.dat and settings.dat.old files in the Bittorrent folder. (usually C:\Documents and Settings\YourUser\Application Data\Bittorrent or.and C:\Users\YourUser\Application Data\Bittorrent). After restarting Bittorrent you will have a fresh set of settings, so change them to what you need and reload the list of torrents that you saved.
  • Check the connection settings. Sometimes you want to minimize the number of connections Bittorrent makes because your provider gives you only a limited connection pool. Make sure the value is not too small. Bittorrent needs a lot of connections: to find peers, to download and upload stuff, to open new connections in order to find the faster one, etc. In my case 15 was too little and I had to restore it to the original 150, even it 15 worked with previous versions of the program.
  • Solution from a comment: check your firewall settings and the firewall settings of your router/modem
  • Solution from a comment: check your internet provider. Some, like Comcast, are throttling some types of traffic. This link might help: Stop your ISP from Throttling Bittorrent Speeds
  • Solution from a comment: enable Bittorrent protocol encryption and restart the application
  • Solution from a forum: disable DHT from the Bittorrent client settings (or enable it, if it is disabled?)
  • Solution from YouTube: start the torrent client 'As Administrator', suggesting there may be some file access issues you have.
  • Solution from a comment: enable DHT. If only some torrents seem to be stuck, see if you can enable DHT in those torrents' properties.

Hope that helps. Now for the original post:

Update (again): While resetting the settings did solve my problem temporarily, I had the same problem the next day as well. The only meaningful thing that I had changed was the global maximum number of connections (Preferences -> Bandwith) from 150, which seemed excessive, to 15. I changed the value back to 150 and it started downloading immediately! This is strange, since the value was 15 for years, I think. Well, I am getting tired of these solutions that only work until the next day. Hopefully this is the last time the problem appears.

Update: The enthusiasm I had after making some of the torrents work faded when I noticed most of the other torrents were still not working. My only solution was to go to the Application Data folder, then Bittorrent, and delete settings.dat and settings.dat.old while the program was closed, then restart Bittorrent. Warning! You will lose all the torrents and settings so save them first (I selected them all and copied the magnet links, then added them back one by one afterwards). The weird thing is that, while it worked, the software also looked quite different from what I was used to. Perhaps just blindly updating the version of Bittorrent all the time is not the best option. Sometimes we need to reset the setting to take advantage of the new software settings.

I've had a problem with a router which prompted me to remove it and put the Internet cable directly into my computer port. I wouldn't recommend it for you, since a router adds a level of protection against outside access, but still, I was not home and a friend of mine "fixed" the problem. Since then, I couldn't download anything on Bittorrent, as it got stuck at "Connecting to peers", even if it connected to the trackers, and saw all the seeds and leechers. Googling around I found a suggestion to remove "resume.dat" from the Bittorrent Application Data folder, but it didn't work for me. I tried a lot of things, but none worked until I found an obscure forum asking about a proxy server. And it dawned on me that it could be from there.
You see, I had previously installed a free proxy program called Privoxy, but I had bound it to the previous IP address of the computer. As a result, it didn't load anymore. The Internet settings were OK, I had removed any reference to a proxy, but strangely enough something in the Bittorrent client kept some information relating to the proxy. After I only bound the proxy to the local address, Privoxy started and miraculously also did the Bittorrent downloads (after a restart of the program).

So, if you have issues with the Bittorent client getting stuck at "Connecting to peers", check if you have recently changed your Internet proxy settings.


Update 23 Oct 2023: Here are the latest files to directly download and use. Do read the rest of the article, as these files might not be what you are looking for:
user.action
user.filter

Update 12 Feb 2016: As an alternative, if you have access to your hosts file, you can use a generated list of domains to immediately block any access to those IPs, courtesy of Steven Black: StevenBlack/hosts, and you don't have to install anything and works on most operating systems.

Now for the rest of the article:

I discovered today a new tool called Privoxy. It is a proxy software that has extra features, like ad blocking and extra privacy. What that means is that you can install the proxy, point your browser to that proxy and have an almost ad free untracked by marketing firms or FaceBook experience. The only problem, though, is that the default filters are not so comprehensive. Would it be great if one could take the most used list for ad blocking (Adblock Plus' Easylist) and convert it to Privoxy? Well it would, only that no one seems to want to do it for Windows. You get a few folks that have created Linux scripts to do the conversion, but they won't work for Windows. Nor do they deem it necessary to make an online tool or a web service or at least publish the resulting files so that we, Windows people, can also use the list!

Well, I intend to do a small script that will allow for this, preferably embedded in this blog post, but until then, I had no script, no files, only Privoxy installed. Luckily, I also have Cygwin installed, which allows me to run a ridiculous flavour of Linux inside Windows. I had to hack the script in order for it to work on Cygwin, but in the end, at last, I managed to make it work. For now, I will publish the resulting files here and give you instructions to install them. When they become obsolete, send me a comment and I will refresh them.

So, the instructions:

  • Install Privoxy
  • Go to the installation folder of Privoxy and look for files named 'user.action' and 'user.filter'
  • Download the user.action file from here and replace the default one.
  • Download the user.filter file from here and replace the default one.
  • Restart Privoxy
  • Of course, then you have to go to your browser settings and set the proxy to Privoxy (usually localhost, port 8118)


Warning! The filter file is quite big and it will cause some performance issues. You might want to use only the action file with the filter actions removed.

Update: If you can't download the files, let me know. I am using Github pages and it seems sometimes it doesn't work as I expected.

Also, I have lost faith that AdBlockPlus rules can be completely and correctly translated to Privoxy and I lack the time, so I am publishing my crappy program as it is and if you want to use it or fix it, be my guest. You can find the program here: AdblockPlus to Privoxy. I would ask that you share with me those modifications, though, so that everybody can benefit from them.

Update October 2023: Other people have contributed by making their own translation software. Here are the links for the binary and source code of adblock2privoxy made by Zubr, in Haskell mind you, which is pretty cool:

Binary: https://www.dropbox.com/s/69u1iqbubzft1yl/adblock2privoxy-1.2.4.rar?dl=0
Source code: https://projects.zubr.me/wiki/adblock2privoxy

The original software is not available anymore, but here is a GitHub fork for the same: https://github.com/essandess/adblock2privoxy

It all started with this site that got stuck in the Google Chrome's DNS cache so that any changes to the Windows/System32/drivers/etc/hosts file were ignored. I didn't want to close all Chrome windows (since the DNS cache is application wide in Chrome), so I googled for an answer. And here it was, a simple url that, typed in the Chrome address bar, would allow me to clear the cache: chrome://net-internals#dns.

But there are a lot more cool things there: testing of failed sites, a log of browser network events, control over open connections and so much more. That got me curious on other cool chrome:// URLs and I found some links listing a lot of them.

I don't have the time to parse all these cool hidden Chrome URLs and review them in this blog entry, so I will just list some links and let you explore the goodness:
Google Chrome’s Full List of Special about: Pages
12 Most Useful Google Chrome Browser chrome:// Commands
About and Chrome URLs

Update: The Chrome url containing all others can be found at chrome://about/.

and has 0 comments
UAC is the most annoying feature of Windows 7, one that just has to be specifically designed to annoy the user with useless "Do you want to" alerts. Not even regular alerts, but screen dimming modal panic dialogs. I want it off. There are several options to do that, but the automated way to get rid of UAC is to change a value in the registry. Here is the reg file for it:
Windows Registry Editor Version 5.00



[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]

"EnableLUA"=dword:00000000



Warning! If you don't know what a registry entry is, then you'd better not do anything stupid! Now, if I could dim the screen while you read that, I would be Microsoft material.



But I digress. In order to execute the reg file above you need to save it into a file with the .reg extension (let's say nouac.reg) and then load it with regedt32 /s nouac.reg. The /s switch removes any confirmation messages and silently loads the file into the registry effectively disabling UAC.



However, my laptop is in a domain with some ridiculous policies enforcing the UAC setting so that when I next restart the computer I get the annoying popups again. Now if I could only run nouac.reg at logoff, I would be all set. And we can do that, also. Just run gpedit.msc, go to User Configuration -> Windows Settings -> Scripts (logon/logoff) and double click logoff. Create a batch file that contains the line to load the registry file and then add it as a logoff script. All set.



Update: Hold the celebration. After I restarted my computer, the hated UAC was back. Either the script was not executed, or it doesn't work like that because the policy is enforced after logoff scripts or before logon. Drat it!

As I was blogging before, RedGate are assholes. They bought Reflector, promised to keep it free, then asked money for it. But every crisis can be turned into an opportunity. JetBrains promised a free decompiler tool and they have kept their word as they have released an early build. A total news to me, but not really a surprise, other software companies decided to build their own version in order to boost their visibility in the developer world. Telerik, for example, has just released JustDecompile, beta version.

It is no secret that JetBrains is a company that I respect a lot, as they made ReSharper, the coolest tool I've ever had the pleasure to work with, but I will try to be as unbiased as possible in comparing the options. I have tried dotPeek on WPF's PresentationFramework.dll from the .NET framework 4.0, as I often need to check the sources in order to understand functionality or bugs.

As a footnote, Reflector, just before it went commercial, could not decompile some of the code there. Not only it did not decompile it, but it presented empty methods like that was all there was in the code, with no warnings or errors or explicative comments. So, even if free, I bet Reflector would have sucked in the end, after getting into the money grabbing hands of RedGate.

dotPeek has seen and decompiled the code that Reflector did not. Also, I have to say that similar functionality like in ReSharper, finding usages, going to declaration, etc are making dotPeek a very nice tool to work with. What I did not quite like is that it doesn't have yet the functionality to save the sources to text files. But I am sure this is just a detail that was not implemented yet. Hopefully, they will provide a rich plugin model like old Reflector did.

Unfortunately, to download JustDecompile, they need you to have a Telerik login in order to download, which, as everyone knows, simply sucks. No one likes a registration form, folks! Especially one that presents you with wonderful prechecked checkboxes for permission for Telerik to send you all kind of stupid promotions and newsletters. Also, the download is of a .msi file. Most developers like to see what they are installing and preferably just copy it from a file archive. Running the .msi took forever, including the mandatory 100% CPU utilization bit that I will never understand in installation products. (coming from the .NET runtime optimization service, mscorsvw, called by ngen) But that's just the delivery system. Let's check out the actual thing.

JustDecompile starts reasonably fast and it also has a nice look, being build with Telerik controls and what not. The decompilation is a bit weird at first, since it shows only the method names and for a second there I thought it was as bad as Reflector was, but then I noticed the Expand All Members button. The context menu is not nearly as useful as dotPeek's, but there are a lot of options in the top toolbar and the navigation via links is fast and intuitive. It also has no text saving options yet.

As the decompiled sources were, I noticed these differences:
  • JustDecompiler places inline member declarations in constructors, dotPeek shows it inline. It might not seem an important thing, but an internal class gains a weird public constructor in order to place the declaration there, instead of using the only internal constructor that the class had. It looks strange too as its last line is base(); which is not even legal.
  • dotPeek seems to want to cast everything in the source code. For example List list = (List) null;
  • JustDecompiler shows a Dictionary TryGetValue method with a ref parameter, dotPeek shows the correct out.
  • dotPeek creates really simple names for local scope variables like listand list1, JustDecompiler seems to create more meaningful names like attachedAnnotations
  • JustDecompiler shows a class internal as dotPeek shows it as internal abstract.
  • JustDecompiler seems to fail to decompile correctly indexer access.
  • JustDecompiler doesn't seem to handle explicit interface implementations.
  • JustDecompiler doesn't seem to decompile readonly fields.
  • JustDecompiler transforms a piece of code into an if with a return in it and then some other code, dotPeek decompiles it into an if/else.
  • JustDecompiler doesn't seem to handle Unicode characters. dotPeek correctly encodes them in source like "\x001B".
  • dotPeek seems to join nested ifs in a single one, as opposed to JustDecompiler.
  • JustDecompiler uses base. in order to access members coming from base classes, while dotPeek uses this.


I will stop here. I am sure there are many other differences. My conclusion is that dotPeek could do with the naming algorithm JustDecompiler seems to use for local scope variables, but in most other ways is superior to JustDecompiler for now. As both programs are in beta, this could quickly change. I do hope that healthy competition between these two products (and, why not, shady developer meetings in bars over tons of beer and pizza, in order to compare ideas intercompanies) will result in great products. My only wish is that one of these products would become open source, but as both use proprietary bits from commercial products, I doubt it will happen.

Have fun, devs!

Update 23 Feb 2012:
Spurred by a comment from Telerik, I again tried a (quick and dirty, mind you) comparison of the two .Net decompilation tools: JetBrains dotPeek and Telerik JustDecompile. Here are my impressions:

First of all, the Telerik tool has a really cute installer. I am certainly annoyed with the default Windows one and its weird error codes and inexplicable crashes. Now, that doesn't mean the Telerik installer does better in the error section, since I had none, but how could it not? The problem with the installation of JustDecompile is that it also tried to install (option checkboxes set by default) JustCode and JustTrace. The checkboxes themselves were something really custom, graphically, so I almost let them checked, since they looked as part of the background picture. If it weren't for my brain spam detector which went all red lights and alarm bells when seeing a really beautiful installer for a free tool, I might have installed the two applications.

Now for the decompilation itself. I was trying to see what the VisualBasic Strings.FormatNumber method contained. The results:
  • dotPeek showed xml documentation comments, JustDecompile did not
  • dotPeek showed default values for method parameters, JustDecompile did not
  • JustDecompile could decompile the source in C#, VB and IL, dotPeek did only C#
  • JustDecompile showed the source closer to the original source (I can say this because it also shows VB, which is probably the language in which Microsoft.VisualBasic was written), dotPeek shows an equivalent source, but heavily optimized, with things like ternary operators, inversions of if blocks and even removals of else sections if the if block can directly return from the method
  • There are some decorative attributes that dotPeek shows, while JustDecompile does not (like MethodImplAttribute)
  • dotPeek has a tabbed interface that allows the opening of more than a single file, JustDecompile has only a code view window
  • dotPeek shows the code of a class in a window, in order to see a method, it scrolls to where the method is; JustDecompile shows a class as a stub, one needs to click on a method to see the implementation of only that method in the code window


My conclusion remains that dotPeek is a lot more usable than JustDecompile. As a Resharper user, I can accept that I am biased, but one of the major functionalities of a .Net decompiler is to show you usable code. While I can take individual methods or properties with JustDecompile and paste them in my code, I can take entire classes with dotPeek, which makes me choose dotPeek for the moment, no matter all the other points above. Of course, if any of the two tools would give me a button that would allow me to take a dll and see it as a Visual Studio project, it would quickly rise to the top of my choices.

Update 26 Apr 2013:
I've again compared the two .Net decompilers. JustDecompile 1.404.2 versus dotPeek EAP 1.1.1.511. You might ask why I am comparing with the Early Access Program version. It is because JustDecompile now has the option to export the assembly to a Visual Studio project (yay!), but dotPeek only has this in the EAP version so far.
I have this to report:
Telerik's JustDecompile:
  • the installer is just as cute as before, only it is for a suite called DevCraft, of which one of the products is JustDecompile
  • something that seemed a bit careless is the "trial" keyword appearing in both download page and installer. If installing just JD, it is not trial
  • again the checkboxes for JustCode and JustTrace are checked by default, but at least they are more visible in the list of products in the suite
  • a Help Improve the Telerik Installer Privacy Policy checkbox checked by default appeared and it is not that visible
  • the same need to have an account to Telerik in order to download JD
  • when installing JD, it also installs the Telerik Control Panel a single place to download and manage Telerik products, which is not obvious from the installer
  • the install takes about two minutes on my computer to a total size of 31MB, including the control panel
  • if a class is in a multipart namespace like Net.Dns, it uses folders named Net.Dns if there is no class in the Net namespace
  • not everything goes smoothly, sometimes the decompiler throws exceptions that are then logged in the code as comments, with the request to mail to JustDecompilePublicFeedback@telerik.com
  • it creates the AssemblyInfo.cs file in a Properties folder, just like when creating a project
  • resolves string concatenation with string.Concat, rather than using the '+' operator as in the original code
  • resolves foreach loops into while(true) loops with breaks when a condition is met
  • uses private static methods in a class with the qualified class name
  • resolves inline variables, leaving the code readable
  • overall it has a nicer decompiled code structure than dotPeek
  • adds explicit default constructors to classes
  • places generic class constraint at the end of constraints list, generating an exception
  • it doesn't catch all reference assemblies, sometimes you have to manually add them to the list
  • decompiles enum values to integer in method optional parameters default values, generating compilation errors
  • decompiles default(T) to null in method optional parameters default values, generating compilation errors
  • decompiles class destructors to Finalize methods which are not valid, generating compilation errors
  • types of parameters in calls to base constructors are sometimes wrong
  • places calls to base/this constructors at the end of constructor code blocks, which of course does not work, when you place more complex code in the calls
  • doesn't understand cast to ValueType (which is somewhat obscure, I agree)
  • really fucks up expressions trees like FluentNHibernate mapping classes, but I hate NHibernate anyway
  • resolves if blocks with return in them to goto/label sometimes
  • resolves readonly fields instantiated from a constructor to a mess that uses a local variable to set the field (which is not valid)
  • doesn't resolve corectly a class name if it conflicts with the name of a local method or field
  • inlines constants (although I don't think they can solve this)
  • switch/case statements on Enum values sometimes gain weird extra case blocks
  • sometimes it uses safe casting with value types (x as bool)

JetBrain's dotPeek:
  • the EAP version has a standalone executable version which doesn't need installation
  • the whole install is really fast and installs around 46MB
  • as I said above, it does not have the Export to Project option until version 1.1
  • the decompilation process is slower than JustDecompile's
  • if a class is in a multipart namespace like Net.Dns, it uses a folder structure like Net/Dns
  • sometimes things don't go well and it marks this with // ISSUE: comments, describing the problem. Note: these are not code exceptions, but issues with the decompiled code
  • it inlines a lot of local variables, making the code more compact and less readable
  • weird casting of items in string concatenations
  • a tendency to strong typed casting, making the code less readable and generating compilation errors at times
  • the AssemblyInfo.cs file is not created in a Properties folder
  • when there are more classes in a single file, it creates a file for each, named as the original file, but prefixed with a number, instead of using the name of the class
  • it has an option to create the solution for the project as well
  • it creates types for anonymous types, and creates files with weird names for them, which are not really valid, screwing the project.
  • it has problems with base constructor calls and constructor inheritance
  • it has problems with out parameters, it makes a complete mess of them
  • tries to create a type for Linq IQueryable results, badly
  • it has problems with class names that are the same as names of namespaces (this is an issue of ReSharper as well, when it doesn't present the option to choose between a class name and a namespace name)
  • resolves while(method) to invalid for loops
  • it doesn't resolve corectly a class name if it conflicts with the name of a local method or field
  • problems with explicit interface implementations: ISomething a=new Something(); a.Method(); (it declares a as Something, not ISomething)
  • problems with decompiling linq method chains
  • I found a situation where it resolved Decimal.op_Increment(d) for 1+d
  • indirectly used assemblies are not added to the reference list
  • it sometimes creates weird local variables like local_0, which are not declared, so not valid
  • adds a weird [assembly: Extension] in the AssemblyInfo file, which is not valid
  • a lot of messed up bool values resolved as (object) (bool) (value ? 1 : 0), which doesn't even work
  • inlines constants (although I don't think they can solve this)
  • __Null local1 = null; - really?

After decompiling, solving the issues and compiling again an assembly in the project I am working on I got these sizes:
JustDecompile: 409088
dotPeek: 395776
The original: 396288

Of course, this is not really a scientific comparison between the two. I was excited by the implementation of Export to Project in both products and I focused mainly on that. The navigation between types and methods is vastly improved in JustDecompile and, to my chagrin, I have to admit that it may be easier and safer to use than dotPeek at this time. Good job, Telerik! Oh, and no, they have NOT paid me to do this research :-)

Short version: open registry, look for file association entry, locate the command subkey and check if, besides the (Default) value, there isn't a command multistring value that looks garbled. Rename or remove it.

Now for the long version. I've had this problem for a long time now: trying to open an Office doc file by double clicking it or selecting "Open" from the context menu or even trying "Open with" and selecting WinWord.exe threw an error that read like this: This action is only valid for installed products. This was strange, as I had Office 2007 installed and I could open Word just fine and open a document from within; it only had problems with the open command.

As I am rarely using Office at home, I didn't deem it necessary to solve the problem, but this morning I've decided that it is a matter of pride to make it work. After all, I have an IT blog and readers look up to me for technical advice. Both of them. So away I go to try to solve the problem.

The above error message is so looked up that it came up in Google autocomplete, but the circumstances and possible solutions are so varied that it didn't help much. I did find an article that explained how Office actually opens up documents. It said to go in the registry and look in the HKEY_CLASSES_ROOT\Word.Document.12\shell\Open\command subkey. There should be a command line that looks like "C:\Program Files\Microsoft Office\Office12\WINWORD.EXE" /n /dde. The /dde flag is an internal undocumented flag that tells Windows to use the Dynamic Data Exchange server to communicate the command line arguments to Word, via the next key in the registry: HKEY_CLASSES_ROOT\Word.Document.12\shell\Open\ddeexec which looks like: [REM _DDE_Direct][FileOpen("%1")]. So in other words (pun not intended) WinWord should open up with the /n flag, which instructs to start with no document open, then execute the FileOpen command with the file provided. If I had this as the value of the command registry key, it should work.

Ok, opened up the registry editor (if you don't know what that is or how to use it, it is my recommendation to NOT use it. instead ask a friend who knows what to do. You've been warned!), went to where the going is good and found the command subkey. It held a (Default) value that looked like it should and then it held another value named also command, only this one was not a string (REG_SZ), but a multi string (REG_MULTI_SZ), and its value was something like C84DVn-}f(YR]eAR6.jiWORDFiles>L&rfUmW.cG.e%fI4G}jd /n /dde. Do not worry, there is nothing wrong with your monitor, I control the horizontal, vertical and diagonal, it looked just as weird as you see it. At first I thought it was some weird check mechanism, some partial hash or weird encoding method used in that weird REG_MULTI_SZ type, which at the moment I didn't know what it meant. Did I mention it was weird? Well, it turns out that a multi string key is a list of strings, not a single line string, so there was no reason for the weirdness at all. You can see that it was expecting a list of strings because when you modify the key it presents you with a multiline textbox, not a singleline one.

So, thank you for reading thus far, the solution was: remove all the annoying command values (NOT the command subkeys) leaving the (Default) to its normal state. I do not know what garbled the registry, but what happened is that Windows was trying to execute the strange string and, obviously, failed. The obscure error message was basically saying that it didn't find the file or command you were trying to execute and has nothing to do with Office per se.

Of course,you have to repeat the procedure for all the file types that are affected, like RTF, for example.

and has 3 comments
I am the kind of guy that uses a piece of software until he has a really good reason to change it. I don't try new stuff if I am satisfied with what I've got and I am all for second chances when mistakes are made. After all, I am not immune to the occasional error. However, from this day on I am fully switching from Internet Explorer to Chrome.

Wipe that smirk off your face, I happen to think that IE is a reasonable browser and, given the hypothetical situation where Google would have made their browser compatible with Internet Explorer rather than the standards, you would all curse at FireFox right now. Besides, this is not about the standards at all. Firefox is still not on my list of available choices. It is sluggish, pretentious and buggy.

The thing is that parameters have changed. I now use the browser to quickly get answers to questions or to open RSS feed blog articles. Before I was using it to make ASP.Net applications and web applications and I still think Internet Explorer 8 developer tools are nicer and easier to use than Firebug, not to mention the horrible confusing developer tools on Chrome. Now I am free (partially) of web development and I can rejoice. Also, sites were more compatible with IE than any "standard" browser and it is not the case any more.

The downloading window from Internet Explorer always made more sense to me: have an option of Open, Save and Cancel and do it in another process so you can close the windows that spawned the download. Then it opens or you just go to the file and use it, you know where you saved it. I think this is the only thing I will miss from Internet Explorer, though.

Let's summarise:
  • Chrome opens instantly, letting you write something in the address bar immediately and having autocomplete for search term as well as web addresses. Internet Explorer blocks the CPU for a second or two and, even if it lets you write something in the address bar, it hickups just so that what you wrote is truncated. Firefox is so keen to update every fucking extension that it takes forever to start. Yeah, I know, FF4 is way better. Not compared to Chrome it isn't.
  • Internet Explorer is supposed to support the new Silverlight wonder technology. Unfortunately, every single SL video I open is sluggish, blocks my mouse, doesn't respond to simple commands like Space to pause and arrows to skip and every Silverlight app is alower than their Flash counterpart. I've just wasted one hour today to uninstall with a special tool the older Silverlight version as the installer for the new one brutally stopped with a "generic error message". Well, screw that! I would rather download the videos and run them in a "generic" video player
  • Javascript: it works 8 times faster on Chrome that on Internet Explorer 8. I know they've just released Internet Explorer 9, but it won't work on Windows XP. I have an old computer, it works fine, I want a browser for it without buying a trillion dollar Windows 7 license. You can't provide it for me, Microsoft!
  • HTML5: it is supported in Chrome. If I ever want to start web dev again, I would go with that
  • Extensions: I am not a big fan of extensions as they slow the browser down. I do prioritize speed. However, I have AdBlock Plus installed on Chrome and I couldn't install it (even if I have tried emulating it) on Internet Explorer. Having no flashing nonsense on a page when I am reading the text on it is wonderful. Try it!


I could find even more reasons if I think about it longer. Like a long relationship going bad, you start noticing all the things you hated only after you break up, but break it up I do. So there it is, found me a new girlfriend and she is chrome shiny.

As you know, the uberuseful tool Reflector, originally developed by Lutz Roeder, was bought by Red Gate, with promises that the tool will always remain free for its users. Of course, the first thing they did is to create a commercial version of it with some extra features, but they did keep their word by allowing people to use a free version. Recently they changed their minds again, practically saying "Fuck you, developers!" and asking for money for any version of Reflector. The community was outraged.

Enter Jetbrains, my favourite company, the one that would have replaced Google and Microsoft at the top of the development world if they weren't so busy actually developing. They are also the makers of ReSharper, which you should download and use if you are any decent C# programmer. What did they think of this Reflector fiasco? They've decided to build a version of their own! They did bundle it in ReSharper 6, which is a commercial tool, but then... they promised to make it a free standalone tool! Thumbs up, guys!

Here is the blog entry announcing this: ReSharper 6 Bundles Decompiler, Free Standalone Tool to Follow

Update: in order to execute a script in any open tab inside Chrome, use the executeScript method of the tabs API.

Chrome browser extensions are so cool, that they protect you from accidentally running and adding script to a page that might interfere with the original code of the page. Unfortunately, they don't give you a parameter or option to actually do that, if it is what you actually want. All you can do, by default, is to access the elements in the page document, but not change direct members of window or even document.

I have found the solution on this page: Writing a Google Chrome extension: How to access the global context of the embedding page through a content script.. There is code and explanations for the code, but basically it is a function that injects another function in the real page context and also returns a result.

and has 0 comments
A while ago I wrote a post detailing how to install Windows XP on a laptop with SATA drivers without using any floppy disk. Today I had to do such installation again and I've met with some annoying errors.

The laptop was an Acer Aspire, so I did everything in my old post and started the computer. It is important to use the correct drivers, as in my case the installation met with a blue screen with code 0x0000007B. It was like it tried to use some of the SATA drivers I had loaded on my WindowsXP CD, but not the right ones.

After the installation went ok, Windows XP would not boot up, not even in safe mode. In order to check what the hell is going on (because the default behaviour is to show a blue screen and immediately reboot) you need to start the computer and press F8, then disable the automated restart in case of error from the menu.

The problem is that the laptop had "AHCI mode" enabled in BIOS. Apparently, Windows XP doesn't support this mode. Set it to IDE BEFORE you start installing Windows XP. After that, you can enable AHCI after you install some stuff and change some registry entries, but it seems XP doesn't really have much use of this mode of access anyway. Here is a forum discussing this, but I haven't got around to trying the things described there yet.

Good luck with your installation. I almost went for installing Windows 7. Phew!