Total Pageviews

Disclaimer

This is a personal web page. The views expressed on this blog are mine and do not necessarily reflect the views of my current employer.

I am currently employed by Morgan Stanley.

May 15, 2013

How to Interpret IIS 7+ 500 Error Page Correctly

Well, this blog post is a summary of my IIS.net discussion with a user.
So what should we do when IIS reports 500 error? You first idea might be posting "I meet an IIS 500 error" somewhere on IIS.net or StackOverflow.com. But is that enough to get the answer and help you want? Of course not. Of all IIS status codes, 500 is probably a category of its own, which can be caused by tons of root causes,

http://support.microsoft.com/kb/943891

Thus, I love the new design of IIS 7+ (7.0, 7.5, and 8.0) which provides a detailed error page for such issues. Sometimes by properly interpreting the error messages, you might identify the problem fully on your own. OK, below is an example,
Error Summary
HTTP Error 500.0 - Internal Server Error
Internal Server Error
Detailed Error Information
Module URLRewrite
Notification BeginRequest
Handler PageHandlerFactory-Integrated-4.0
Error Code 0x800703e9
IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.
IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.
IIS was not able to process configuration for the Web site or application.
The authenticated user does not have permission to use this DLL.
The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.
Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server's machine account.
Check the event logs to see if any additional information was logged.
Verify the permissions for the DLL.
Install the .NET Extensibility feature if the request is mapped to a managed handler.
Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click here.
Links and More Information This error means that there was a problem while processing the request. The request was received by the Web server, but during processing a fatal error occurred, causing the 500 error.
OK, how to interpret the above error page? I have already highlighted the portion we should focus on.

We start from the error code, as by using a simple command line tool published by Microsoft, you can easily know the meaning of it,

http://www.microsoft.com/en-us/download/details.aspx?id=985

Please download and extract the err.exe from this package. Running it at command prompt and ask what is 0x800703e9, you instantly know that stack overflow happened,
E:\Green\err>err 800703e9
# for hex 0x800703e9 / decimal -2147023895 :
  COR_E_STACKOVERFLOW                                           corerror.h
# MessageText:
# Is raised by the EE when the execution stack overflows as
# it is attempting to ex

# 1 matches found for "800703e9"



Do you know what is stack overflow? Wikipedia shows it clearly. Do you also know what is URL Rewrite? Microsoft makes it clear here. So if you are familiar with both like me, the root cause is almost clear. Right! If the rewrite rules lead to infinite redirection then the stack overflow is expected.

Next time when you hit a 500 error page, please make sure you digest the information inside actively. Only after that you can post your problem to an online forum and expect assistance from others. Or if you are lucky enough, you can locate the culprit before anyone else.

May 12, 2013

Jexus Series: How to Upgrade Jexus on Ubuntu

In last post we discussed how to install Jexus on a clean Ubuntu 13.04 machine. Here we discuss how to upgrade from Jexus 5.2 to 5.3.
What is Jexus?
Jexus Web Server is a free web server for Linux (it is free, but not open source). It is powered by Mono and aims to provide best support for ASP.NET applications (while it also provides excellent PHP support out of the box).

Its homepage is at http://www.linuxdot.net/ (in Simplified Chinese).

Upgrade Steps
1. Download and unpack Jexus
wget http://www.linuxdot.net/down/jexus-5.3.tar.gz
tar -zxvf jexus-5.3.tar.gz

Jexus binary package is downloaded from its official site, and extracted to a folder named "jexus-5.3" after this step.
2. Stop current Jexus 5.2 server,
cd /usr/jexus
sudo ./jws.stop

Assume the previous release was installed at /usr/jexus, we stop the service.
3. Copy new files to Jexus folder
cd ~/jexus-5.3
sudo ./upgrade

Now let's go back to the extracted folder and upgrade necessary files to /usr/jexus.
4. Fix startup commands
sudo vi /etc/rc.local

Press i on keyboard to enter edit mode.

Replace previous start command "/usr/jexus/jws.start" with "/usr/jexus/jws start".

Remove "/usr/jexus/state.start" if it presents.

Press Esc on keyboard to exit edit mode.

Type :wq and press Enter on keyboard to exit vi.
Here we remove the old entries, and use a new entry to start Jexus at startup.
5. Start Jexus HTTP service
cd /usr/jexus
sudo ./jws start

May 11, 2013

Jexus Series: How to Install Jexus Web Server 5.3 on Ubuntu 13.04

This is a series of posts regarding the free Linux web server called Jexus.
What is Jexus?
Jexus Web Server is a free web server for Linux (it is free, but not open source). It is powered by Mono and aims to provide best support for ASP.NET applications (while it also provides excellent PHP support out of the box).

Its homepage is at http://www.linuxdot.net/ (in Simplified Chinese).

Install Steps
1. Install Mono runtime
sudo apt-get install mono-complete
As Jexus requires Mono runtime, in this step we install latest stable Mono runtime (2.10.*) via apt-get. Mono 3.0.* is recommended if you know how to get it compiled and installed.
2. Download and unpack Jexus
wget http://www.linuxdot.net/down/jexus-5.3.tar.gz
tar -zxvf jexus-5.3.tar.gz

Jexus binary package is downloaded from its official site, and extracted to a folder named "jexus-5.3" after this step.
Jexus install package
3. Create default web site
sudo gedit /var/www/default/index.html
When gedit is opened, type in some text, such as "Hello World from Jexus". Save and close the file.
/var/www/default is the default web site path for Jexus. In this step we create a test page using gedit. You might use any other Linux text editor to create this test page.
4. Install and launch Jexus
cd jexus-5.3
sudo ./install
cd /usr/jexus
sudo ./jws start

Here we put Jexus binary to /usr/jexus folder, grant the jws shell script file execution permission, and then use it to register Jexus modules in Mono GAC and launch the HTTP service. If you want to install Jexus to another location, please change the commands accordingly.
Now if we open Firefox and navigate to http://localhost, the test page we created is displayed correctly,
Jexus test page in Firefox

In the next post in this series, we will see how to upgrade from an older Jexus release to a new release. Stay tuned.

If you are interested in Jexus, but do not understand Chinese well, you can contact me directly via support@lextm.com. I know its developers and can help you communicate with them.

(Updated: Below is the alternative way in step 3 to create the test page using vi,)
  1. sudo vi /var/www/default/index.html
  2. Press i on keyboard to enter edit mode.
  3. Type "Hello World from Jexus" and press Esc on keyboard to exit edit mode.
  4. Type :wq and press Enter on keyboard to exit vi.

May 04, 2013

#SNMP Pro: Private Beta is Ready and Early Access Program Starts

After the original announcement on April 6th, I have been working hard on finishing the 1.0 feature set of #SNMP MIB Compiler Pro. Now I believe the time is right and let's kick off the Early Access Program (EAP).

You are welcome to write to support@lextm.com using the following email template,
Hi Lex,

Please add me to the early access program of #SNMP Compiler Pro. Below are my registration information,

* Full Name: *** ****
* Nationality: *****
* Email Address: ***@***
* Phone Number: ***-****-****
* Mailing Address: ********, ****, *****

Your Name

Then please wait till you receive the invitation.

Once you are added to the private beta mailing list and receive the private beta files, please follow the these steps to request a license file.

Generate License Hint
  1. Launch the compiler by double clicking Compiler.exe.
  2. Go to Help | Register Product menu item.
  3. In Register dialog, fill in the User name field and click Generate Hint button. The hint data will be generated in the Hint field.
  4. Click Copy Hint button to copy the data to clipboard.
  5. Paste that data to an email and send to me.
  6. Exit the Register dialog by clicking the red cross on top right corner.
Register Product menu item
Product Hint tab
License Activation
I will send the license key back via email. Then you just need to perform the following steps to get the compiler activated,
  1. Launch the compiler by double clicking Compiler.exe.
  2. Go to Help | Register Product menu item.
  3. In Register dialog, switch to Product Key Registration tab.
  4. Paste the license key to the text box and click Register.
  5. Exit the Register dialog by clicking the red cross on top right corner.
Product Key Registration tab

The goal of this EAP is to test out the licensing system, and also show you what has been implemented so far in the Pro edition.

A reviewer's guide (user manual) is in progress (will be ready in the coming weeks) which summarizes details on some of the important features.

DockPanel Suite: A Summary on Visual Studio 2012 Light Theme

Previously I have posted about the new theme several times, such as
Today I made a few more changes to the theme and I believe it is a stable milestone. So this post will serve as a summary of all the works on this new theme.
Visual Studio 2012 Light theme can be seen as one of the biggest features we will introduce in DockPanel Suite upcoming 3.0 release. However, the story of it is very interesting.

Initial Patches Received at GitHub
8 months ago @wvdvegt posted an issue on GitHub asking whether anyone has a new skin for DPS. At that time, both Ryan and I were busy working on other tasks, so we could not spare time on this specific one.

3 months ago, we suddenly received a lot of patches from another guy (I don't want to name him/her and you will see why). I was really interested in the patches, as they look fantastic and we could finally turn DPS to look modern and awesome.
Original VS 2012 Light theme by Kamen
Well, it is strange that when we tried to discuss with the submitter so as to better understand the patches, he/she no longer replied. We were able to work with other contributors in the past and we appreciated those valuable conversations, but this time was really unexpected.

I had to create a separate branch to maintain the patches and started my own hacking on it from time to time.

The Real Patch Owner at CodePlex
I frequently perform Internet search of DockPanel Suite, in order to understand whether our fork right now becomes popular enough. It was a month ago that I suddenly noticed a CodePlex project called DockPanel Suite VS2012 Look. I began to wonder if I had discovered where the patches originally come from. I sent a mail to its author 
Hi,

I just noticed your project on CodePlex. Are you https://github.com/******?

I am writing to see if you can review our changes made in this branch,

https://github.com/dockpanelsuite/dockpanelsuite/tree/gh59

We attempted to incorporate most patches submitted to us by @******,

https://github.com/dockpanelsuite/dockpanelsuite/issues/59

However, we are not certain whether all necessary changes are made.

Wish you can reply soon.

Regards,

Lex Li
and got a reply as below,

Hi Lex,

I’m not the owner of https://github.com/******?

My project at Codeplex is thought to implement only VS2012 visual style for DockPanel. However it doesn’t incorporate the latest changes form https://github.com/dockpanelsuite/dockpanelsuite.

Greetings,
Kamen
My guess was confirmed 3 days ago when I finally had time to review all the source code. Every line of changes now can be tracked down and gladly I could tell that I made almost all changes correctly.

Thus I immediately sent a second mail to Kamen,
Hi Kamen,

Thank you for your explanation.

I have done a review of your patches to DockPanel Suite 2.5. I can confirm that the patches we got from @****** in fact all come from you.

Thus, I added you to our contributor list.

I have done necessary refactoring to integrate the theme into our latest DPS code base (development_3.0 branch) and also tuned a few settings to better match VS2012. So if you like you can take a look.

Thanks again for your great contribution.

Lex
Of course, Kamen kindly replied again,
Hi Lex,

I've looked at the code of development_3.0 branch. It is definitely my code. You have done a good job integrating it, and creating a new theme files. I have noticed that you have not ported the colors of the theme as they were, may be to prevent from hardcoding them. The whole theme now looks "lightgrey" without the typical blue for VS2012. If that was your intention, it is fine for me.

Another issue is inherited from my code, and i could not fix it till now, so I've filed an issue report at the GIT hub (https://github.com/dockpanelsuite/dockpanelsuite/issues/124).

Greetings,
Kamen
He pointed out two new issues and confirmed that our changes look good,
  1. The flicker problem (GitHub#124), which I fixed earlier today.
  2. The changes I made to some of the colors, which I revisited and re-tuned earlier today (I have to uninstall  Productivity Power Tools as it makes extra changes to the theme).
I would like to thank him again, as without his initial works or his review we could not get so far on this important feature.

Close Button on Document Tabs (Updated: May 5)
Well, I did not expect that in such a short period of time I finished the last important bit of VS2012 Light theme, the close button on document tabs.

It was more than 2 years ago that a guy (paralleloeter) posted on SF.net his patches for DPS to add close button on tabs,

http://sourceforge.net/p/dockpanelsuite/discussion/402316/thread/c45070d3

Well, that patch was not accepted by the coordinator Steve Overton, because DPS only had VS 2003/2005 themes then. I support Steve's decision, as it really looks weird to have close button on tabs.

However, Microsoft seems to choose such a design in Visual Studio 2010/2012, so to finish a complete VS 2012 theme, we will have to revisit this patch.

24 days ago, @dotAge sent us a pull request on GitHub, which he/she claimed contains the original patch by paralleloeter. Both Ryan and I reviewed the pull request, and we could not accept it at that time.

A few hours ago, I was finally passionate enough to continue working on this patch, as hacking on tab colors and resolving #124 have given me enough knowledge on how the strip was designed. So this time I could better control when this close button should appear. Interestingly, it should appears on active tabs, both focused and not focus, and inactive tabs, only when the tab is under mouse. The button also changes color when mouse is hovered. So totally we need to handle five different states.

To avoid flickers when either the tab color or the close button state changes, the calls to Invalidate has also been minimized.

Dock Indicators (Updated: May 11)
In previous alpha builds the dock indicators for VS2012 theme are still those for VS2005. This has been a major problem but we could not do much due to the following technical challenges,
  • VS 2012 dock indicators use transparency, which cannot be simulated by DPS using the current PictureBox based image containers. One possible approach is to use transparency enabled controls (which I did for M8 Theme Builder project), but I did not yet have time to fully explore in that area.
  • VS 2012 adds some new dock indicator elements (in fact since VS 2010), such as the nine element dock indicator. This has no counter part in DPS, as DPS only implements a five element dock indicator to simulate VS 2005.
Nine-element dock indicator

Thus, it is really not easy to implement all required elements for VS 2012 theme in a short period of time without performing heavy refactoring.

Luckily today I spared several hours in this field, and did some initial work
  1. Make dock indicator replaceable via theme.
  2. For VS 2012 theme, replace VS 2005 images with VS 2012 images.
In the near future I might investigate on how to tune the architecture so as to support the new VS 2012 elements and hope we can finally support the nine-element indicator.

Final Words
Please download and try out the latest Alpha 6 of DockPanel Suite 3.0 and let us know if there is any issue you meet,

https://nuget.org/packages/DockPanelSuite/3.0.0-alpha6

VS 2010 Light theme in 3.0 Alpha 6

We will keep working hard on this new theme to make it even better. There are only a few minor issues remaining, which should be easy to solve.

Stay tuned.

April 28, 2013

#SNMP Pro: A Better Obfuscar, Side Project

Open source developers of .NET platform should not care much about obfuscation of the assemblies, as they even have the source code publicly available. However, if an open source project begins the commercialization, an obfuscater is needed to encrypt the secrets of the code base. That's what this blog post is going to talk about.

What is Obfuscation?
Simply speaking, after obfuscation the assembly becomes harder to understand. It won't stop anyone from decompiling it via ILSpy or any similar decompilers. It just makes the decompiled result strange enough. What about an example?
  1. Download JustDecompile from Telerik.com.
  2. Decompile itself to a project with source files.
Now if you try to compile the project, you will see what I mean.

What You Should Not Expect From Obfuscation
You should not expect obfuscation to hide everything, as the openness of MSIL makes it even possible to reverse part of obfuscation, via an open source project,

https://bitbucket.org/0xd4d/de4dot

As it says on the homepage,
If you don't count "don't distribute it" as a solution, the best obfuscator feature is symbol renaming. It's impossible to restore the symbols unless they're part of the assembly. All of the other "protections" are 100% reversible.
I am fully aware of the limitation of obfuscation, but for #SNMP Pro editions I will have to obfuscate the code base. So all I need now is just an obfuscator that can perform symbol renaming for me. Well, that means Obfuscar,

https://code.google.com/p/obfuscar/

What I Did On Obfuscar
As the original project was long dead (last commit was in 2010 Dec), I have to fork it. Luckily other guys already did this, including RemObjects who built a product called Oxfuscator,

http://www.remobjects.com/oxfuscator.aspx

Thus, I just need to fork from one of them, and merge all patches from the forks to my own fork. Because I have been in the open source world for so long, it all becomes nature and here is my fork on GitHub,

https://github.com/lextm/obfuscar

I might charge users for a fee, as now this tool is fully functional, but I rather keep it open source and focus on my SNMP compiler.

So, if you are also looking for a free and useful obfuscator, come and get Obfuscar from my fork. I believe with all the patches, many of the previous bug reports on Google Code have been resolved.

Let me know if there is any new bug, https://github.com/lextm/obfuscar/issues.

April 20, 2013

#SNMP Pro: Second Compiler Sneak Preview

In the first preview I demonstrated the basic building blocks of the Compiler Pro. In this post, we are going to review the new additions.
Object Tree Panel
After having the documents compiled, your first question must be "how can I see the objects?" and here comes the answer, the Object Tree panel is now added also in the compiler.

To make it even more convenient to use, double-clicking any node on the tree, you will be redirected to the document that defines this node and the exact line and column. I call this function "Jump to Definition".

The reverse jump needs some time to implement, so it will not ship in the initial release.

Error List Panel
The problem of reading errors and warnings from the Output panel is obvious. There are far too many things written there, and it is very difficult to locate exactly what you want.

Well, now with the Errors List panel you can focus more, because you can select whether both errors and warnings should all appear, and by ordering the list by columns you can fully focus on a single file or a single category of errors.

Consolidated Menu Items
You might notice that some menu items have been removed. Yes, they are removed because they are no longer useful.
  • Compile and Compile All are now merged as a single Compile menu item, which means to compile all documents in the solution. The original design to use separate items was stupid, as there is almost no difference between the two.
  • Reset is removed, because now if a loaded module is modified and compiled again, the compile can automatically unload the previous version and attempt to load the new version. This means the Module List and Object Tree panels will be taken care by the compiler, instead of the user who manually clicks Reset. Thus, this menu item is now obsolete.
Various Improvements Under the Hood
The type resolution has been redesigned to extract type inheritance information out, and in this way we can perform type verification on receiving SNMP packets in the future or provide better format of those data received (such as displaying PhysAddress as HEX).

Table entities detection is now more accurate as we no longer rely on the authors to use standard naming convention, but use metadata extracted such as types of the entities to tell which is a table, which is an entry and which are the columns.

There are already tons of changes made to the ANTLR grammar file (to simplify a few rules), and more is coming.

Stay tuned.

April 07, 2013

#SNMP Pro: A Sneak on Upcoming Compiler Pro

In this blog post I am going to demonstrate how the Pro edition of #SNMP MIB Compiler is different from the open source edition.

Brand New Look and New Menu Items
Besides, the theme has been changed from Visual Studio 2005 to Visual Studio 2012 Light theme. Of course this is powered by DockPanel Suite 3.0 (currently in alpha).

By cloning Visual Studio look and feel, you can see from the screen shots that more menu items are added (and also more icons on the tool bar). The new ones provide the following functionality,
  • Close current solution (which contains the MIB documents you are working on).
  • Abandon compilation result (which clears the contents in Module List panel and allow you to recompile all documents in solution).
They might not sound fancy, but once you start to write your own MIB documents, and edit others' work, you will find them very useful to keep the workflow smooth. As without them you will have to restart the whole compiler often.

The MIB documents can now be edited directly in the compiler. With syntax highlighting and the improved compiler back end, the Output panel always generates accurate errors/warnings.

By double-clicking on an error or warning, you will be redirected to the problematic file, and more friendly at the correct line and column.


Rich Metadata Extraction and Accurate Error Reporting
Starting from 2008, the #SNMP MIB Compiler is capable of extracting OIDs from MIB documents. This serves #SNMP users well, as they can easily translate OIDs to names and vice verse. This might meet 80%-90% daily needs as most SNMP users won't touch the metadata on an object or a type.

However, if your work is to develop a commercial SNMP agent or manager, you need the following features seriously,
  • Type information extraction so that for every objects we know their basic types (Counter32, OCTET STRING, and so on), and also know about the intermediate types (such as DisplayString). As constraints can be added at each level, those constraints should be extracted too, so as to build data validation. [in progress]
  • Cross module dependency resolution, type resolution, and entity validation. They can provide more accurate error reports and help fix broken MIB documents. [in progress]
  • MIB to C# compilation, which is similar to Net-SNMP's mib2c utility (who compiles MIB documents to C code). The output C# source files can be used to turn snmpd sample to a simulator for those MIB documents. [Not yet implemented]
  • Alternative compiler input and output. You might need SMIv1/v2, plus SMIng as input, while YAML, XML, database file and others as output. [Not yet implemented]
  • Wizards to generate MIB document building blocks. [Not yet implemented]
  • Better integration with the #SNMP MIB Browser. [Not yet implemented]
If you like to join the beta test program (which might start in May), please write to support@lextm.com.

Stay tuned.