Saturday, December 31, 2011

Convert Arabic and Persian (Farsi) PDF documents to Word documents

I've been using TeX for typesetting my technical documents and reports, it is a lot of fun!
Recently one of my reports needed to be converted into a Word documents. There are lots of tools for doing so, but most of them are not working with Arabic and Persian (Farsi) documents. I've tested lots of tools and found "PDF Grabber" a very good tool for converting Arabic and Persian (Farsi) PDF documents into Word documents. It is a product of PixelPlanet. You can find more information at: http://www.pdfgrabber.com/

Tuesday, July 19, 2011

The server committed a protocol violation. Section=ResponseStatusLine

Recently while I was working with an IP camera from my C# application and trying to get the image, I come to this problem:
The server committed a protocol violation. Section=ResponseStatusLine
According to http://blog.webmastersam.net/post/Solution-for-The-server-committed-a-protocol-violation.aspx, the problem is caused by:

Unsafe header parsing is an option you can turn on on your ASP.Net website (in the web.config) to allow the framework to parse responses. But what is an unsafe header ? It is a header in which the keys contains one or more spaces (that is not allowed in the HTTP 1.1 specifications).
The common case is having a space in the "content-length" header key. The server actually returns a "content length" key, which, assuming no spaces are allowed, is considered as an attack vector (HTTP response split attack), thus, triggering a "HTTP protocol violation error" exception.
In most weblogs, the solution to this problem is just a simple change in web.config file for ASP .NET projects:
Just add the following code to the web.config file:
<system.net>
   <settings>
      <httpWebRequest useUnsafeHeaderParsing="true" />
   settings>
system.net>


BTW, my solution is a desktop application, not a web application, so I do not have any web.config file. An alternative way to solve this problem is:

public static bool SetUseUnsafeHeaderParsing(bool b)
{
    Assembly a = Assembly.GetAssembly(typeof(System.Net.Configuration.SettingsSection));
    if (a == null) return false;

    Type t = a.GetType("System.Net.Configuration.SettingsSectionInternal");
    if (t == null) return false;
           
    object o = t.InvokeMember("Section",
        BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.NonPublic, null, null, new object[] { });
    if (o == null) return false;
    FieldInfo f = t.GetField("useUnsafeHeaderParsing", BindingFlags.NonPublic | BindingFlags.Instance);
    if (f == null) return false;

    f.SetValue(o, b);
    return true;
}

You just need to add this function and call it passing true to it. That's all, it is done!

Wednesday, December 15, 2010

AJAX Control Toolkit AsyncFileUpload Error: Unhandled Exception: Server Response Error: 'Unknown Server error'

A new file upload control is recently added to AJAX Control Toolkit.

AsyncFileUpload is an ASP.NET AJAX Control that allows you asynchronously upload files to server. The file uploading results can be checked both in the server and client sides.
You can save the uploaded file by calling the SaveAs() method in a handler for the server UploadedComplete event.

A common error for this control is:
Unhandled Exception: Server Response Error: 'Unknown Server error'

There is a simple workaround to solve this problem. But first of all be sure that you are using its latest version. You can download the latest version from http://www.asp.net/ajaxlibrary/download.ashx

Also be sure that you are using the correct version according to your target .NET framework version.

If you're sure about those two steps and still you get the same error, the simple workaround is to change the value of "ClientIDMode" to "AutoID".

That's all. Enjoy using this great control!

Sunday, November 7, 2010

Dialogic TAPI / WAVE Installation

Installation of Dialogic TDM Boards which offer TAPI access can be tricky. Although Dialogic in 2006 had announced that their boards will no longer support TAPI (starting from system release 6), but existing boards are still working with TAPI when using system release 5.1.

Hardware installation of Dialogic board in Windows XP and 2000 are tricky. Here is a complete step by step guide for installing the properly in Windows XP and 2000.

These steps are taken from NCH Software.

Before Installing the Board
Make sure that you have the instructions from Dialogic and the drivers on CD. Be prepared to take some time to follow Dialogics complex instructions for installing the TAPI and Wave drivers. You will need to install latest Dialogic drivers and service packs from http://support.dialogic.com. You need to also install Dialogic TAPI drivers and the Dialogic sample programs which are handy for making sure that the drivers and the board are working properly. Please note that "Talker32.exe" is the only Dialogic sample program that uses TAPI. The others access the card directly and do not use TAPI and so do not test whether the TAPI and Wave drivers are correctly installed.

Board Installation
Shut the computer down and install the board into the computer following carefully the instructions that come with the board. When this is complete then turn the computer back on.

Dialogic Software Installation
Insert the the CD that you obtained with the board into your disc drive and run the file called "setup.exe" then follow the setup wizard.
Missing CD-ROM with Drivers: Most suppliers ship the Dialogic CD-ROM with drivers with each board. Some (the cheaper) do not. If you do not have the driver CD-ROM you should contact your supplier and ask them to provide it.
Now you need to install feature pack 1 (or some times called service pack 1). After installing and restarting your computer, you'll need to install the card specific software which should be included in the CD.

Dialogic Configuration Manager (DCM)
Near the end of the Dialogic software installation you are offered an option to run the "Dialogic Board Configuration" or you can run it from the Windows Start menu. This program is also known as "Dialogic Configuration Manager (DCM)".
Make selections appropriate to your situation, paying careful attention to the Dialogic Instructions. The board must be 'started' (and set to auto-start on startup).
You might at this stage run one of the simpler Dialogic programs or diagnostics to confirm that the board has been successfully installed. Do not expect the board to cooperate with our software because the TAPI Service Provider Driver and the Wave Drivers have not yet been installed.

Dialogic TSP and Wave Driver Configuration
These are the important steps that are often missed on installation...
The Dialogic TAPI Service Provider (TSP) drivers allow other software (eg. NCH Swift Sound's Software) to use control the board. To install the TSP follow these steps.

  1. In Windows 2000, open Control Panel -> Phone and Modem Options and select Advanced->Add->Dialogic Generation 2 service provider for NT4/W2000->advanced.
  2. From the "Configuration Service" Dialog box select "call Parameters and change the configuration from "default" to "custom". Select "700" for the "Ringback Timeout" . Some customers have suggested that the "perfect call" box should be left unchecked. Select "DX_PVDOPTNOCON(6)" for the "Call progress analysis flags".
  3. Close down the Control Panel and reboot the computer.
The Dialogic Wave drivers allow other software to play audio to and record from the board. To install the Wave drivers follow these steps. This step is essential.
  1. From the Control Panel select Add/Remove Hardware -> Add/Troubleshoot a device -> Add a new device -> "No, I want to select the hardware from a list" -> Sound, video and game controllers -> Have Disk.
  2. Browse to "D:\Program Files\Dialogic\Lib" and select "Dialogic Wave Driver 1.x" . Complete the installation, close the Control Panel and reboot the computer.
  3. Open the Control Panel and select "Sound and Multimedia" -> "Hardware" -> "Dialogic Wave Driver 1.X" -> "Properties".
  4. Select the "Properties" tab and from the "Audio Devices" select "Dialogic Wave Driver 1.X" -> "Properties" ->"Settings".
  5. Select the appropriate number of channels (phone lines). We suggest that you might start with 1 and add the others when the first is working.
  6. Click OK, close the Control Panel and reboot the computer.

Friday, July 30, 2010

Linux NFS Communication Common Problems

Today, I've been asked some questions about NFS communication problems, the very first was: RPC: Program Not Registered.
This is caused mainly by the fact that NFS service is not running on the server, you can run the service using: "/etc/init.d/nfs start"
For a comprehensive list of error, have a look at: NFS Troubleshooting Guide
Another common problem is permission and access problems, such as: System Error: No route to host.
The resolve this, simply check whether you can ping the server or not, if you can ping, then the problem is with your servers firewall configuration. For a detailed manual on how to configure firewall, have a look at: How To Configure NFS, appendix A. (If you can not ping the server either, refer to the NFS Troubleshooting Guide to find the cause and a workaround to solve it)
In case of firewall blocking, you can simply turnoff the firewall using "service iptables stop". Although this is the easiest way, but also the worst way! You can go further and disable the iptables firewall service from boot time using "ntsysv" command. (Not recommended at all!)
If you would like to read a comprehensive guide about setting up NSF and better understand things, have a look at this manual.

Thursday, July 22, 2010

SQL SERVER – FIX : ERROR Msg 1803 The CREATE DATABASE statement failed. The primary file must be at least 3 MB to accommodate a copy of the model database

When creating new data base, its size should be at least the size of the model database, otherwise the CREATE DATABASE statement fails with this error:
The CREATE DATABASE statement failed. The primary file must be at least 3 MB to accommodate a copy of the model database. (Microsoft SQL Server, Error: 1803)

If you like, you can increase the initial size of your new db to at least the size of model database. If not, you can shrink the model database to reduce its size.

To check the available space of a database you can use:
SELECT name ,size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0 AS AvailableSpaceInMB
FROM sys.database_files;

About shrinking, have a look at:

DDBC SHRINKDATABASE
DDBC SHRINKFILE

Common Confusing Error with SVN Clients

There is an error message in SVN, which is quite confusing:
OPTIONS of '': 200 OK
This error is mostly caused by mistyping the repository address.

Workaround:
Check you typed the address correctly, you can try the address in your browser and check weather you see correct pages. Some SVN server tools such as Visual SVN Server, provide some HTML pages, so that you can log-in and check the repository tree using your browser. One thing to remember, when specifying paths, you should specify the full path to your files in repository server.

Hope this helps!