June 30, 2005

Info on tracing in .NET

Note: All methods of tracing mentioned here will work both in release and debug builds.

If you type the following code, you are actually invoking Page.Trace (TraceContext type) object. This object takes care of writing trace messages to trace.axd (page level tracing). For this object to work, make sure trace is enabled in web.config.

Trace.Write("test")

To use trace listeners, use the following code. Using this code, the trace messages will go to any listener you add to the trace listener collection. The messages will not go to trace.axd. The default listener will output the messages to OutputDebugString (normally the output window of IDE). The other options are Eventlog or text file.

System.Diagnostics.Trace.Write("test");

You can also use conditional tracing using the following code. For this code to work, make sure a BooleanSwitch (for e.g. EnableTrace) is set to 1 in web.config under System.diagnostics section.

BooleanSwitch enableSwitch = 
     new BooleanSwitch("EnableTrace", "Some info on switch");
System.Diagnostics.Trace.WriteIf(enableSwitch.Enabled, "test");

June 14, 2005

Implementing WS-Security in .NET Web Services

This is an informative article on Implementing WS-Security in .NET Web Services using X.509 certificates. http://www.codeproject.com/webservices/WS-SecurityII.asp

May 27, 2005

SQL for retreiving rows in a Paging mode

The following statements can be useful which developing a Page or Screen which shows users X rows per page and allows the user to navigate to previous or next page (Paging).

These SQLs can be used to retrieve only the required minimum rows from the database. However, the syntax is vendor dependent.

In the following examples, the query retreives only a sub set of employees (40th - 50th logical rows) ordered by name.

SQLServer: (Source: MSDN Documentation)
First selects the top 50 rows ordered by the name. Then orders that result in descending order and gets the top 10, giving the rows from 40 to 50. NOTE: The results are in descending order.
SELECT TOP 10 *
FROM (SELECT TOP 50 *
      FROM emp
      ORDER BY emp_name ASC) Table1
ORDER BY emp_name DESC

Oracle: (Source: asktom.oracle.com)
First orders the table by name, then retrieves the top 50 rows. Then uses the retrieved rownum value to get all rows equal to or greater than 40.
SELECT *
FROM (SELECT A.*, rownum r from (SELECT * FROM emp order by emp_name) A 
      WHERE rownum < 50)
WHERE r >= 40

As far as I am concerned, these statements only avoid the processing on the client side. The database will still have to process incremental amount of data especially as the user navigates towards the last page.

March 25, 2005

ConnectionString formats

This site gives a list of all possible ConnectionString formats. I don't have to remember them anymore. http://www.connectionstrings.com

March 08, 2005

Multiple ways to add SVG streams in .NET

The following are some of the ways to add SVG objects in a .NET application. In fact, the first two methods can be applied to plain old html files. When using aspx to generate SVG streams, make sure the stream starts with SVG data.

Embedding an svg object in HTML:
<embed name="svg" pluginspage="http://www.adobe.com/svg/viewer/install/" src="graph.svg" width="600" height="320" type="image/svg+xml">

Using ASPX to generate svg stream:
<object codebase="http://www.adobe.com/svg/viewer/install/" type="image/svg+xml" height="320" width="600" data="graph.aspx" name="svg>

Another way of using ASPX to generate svg stream:
<asp:image id="svg" height="450" width="450" imageurl="graph.aspx" runat="server">

January 26, 2005

Event viewer messages not showing up

If Event log messages generated by Web applications are not showing up in the Event Viewer (Windows), then check this page from Microsoft support.

Setting the RestrictGuestAccess DWORD value under the following registry key to 0 instead of 1 did the trick for me:
HKLM\System\CurrentControlSet\Services\EventLog\Application\

December 17, 2004

List of XSL-FO processors

XSL-FO is a W3C recommendation for describing layout information. In other words, by attaching a XSL-FO stylesheet to an XML file (content file), we specify how the content should be laid out on an output medium complete with headers/footers, table of contents, indexes etc. With XSL-FO, we can also flow text around images, add footnotes etc. Of course, none of the browsers currently supports this standard. We cannot use XSL-FO for web pages yet. However, we have XSL-FO tools which convert a given XML file to PDF, PS etc.

Here is a list of currently available XSL-FO processors and tools. Please check the respective websites for updated information and pricing.

Apache - FOP (I tested this tool)
  • An open-source free tool.
  • Written in Java.
  • Java interface.
  • PDF, PS, RTF outputs etc.
  • Very good support for XSL-FO specifications.
  • Extensive SVG support. (Yes, you can embed on-the-fly images in PDF using SVG. Helpful for creating dynamic charts and graphs).
  • No major updates to the project since 2003. However, actively maintained for bug fixes.
Antenna House – XSL Formatter V3.2 (I tested this tool)
  • Commerical tool. $5000 per CPU. $3000/$900 developer license.
  • Extensive support for XSL-FO specifications.
  • PDF output.
  • .NET / JAVA interfaces.
  • Very good SVG support.
RenderX – XEP Engine (I tested this tool)
  • Commerical tool. $4000 per CPU.
  • Very good support for XSL-FO specifications.
  • PDF, PS outputs.
  • Java interface. (Connectivity kit for other platforms)
  • Extensive SVG support
Inventive Designers – Scriptura XBOS 3.1
  • Commerical tool. Expensive.
  • PDF, PS, HTML, RTF outputs etc.
  • Requires a Java application server.
  • Java/C++ interfaces.
  • GUI layout designer. (No need to hand code XSL-FO stylesheets)
  • Lots of features
Unicorn Enterprises SA - Unicorn Formatting Objects
  • Commerical tool.
  • PDF, PS, HTML outputs.
  • Very little information on their website.
Visual Programming Limited - Ibex XSL-FO Formatter 3.0
  • Commerical tool. An inexpensive tool.
  • .NET / JAVA interfaces.
  • PDF output.
  • SVG support.
Adobe - Adobe Document Server
  • Commerical tool.
  • C++ interface.
  • PDF output.
  • SVG support.
Ecrion - XF Rendering Server
  • Commerical tool. $805 - $995 per cpu.
  • .NET / COM+ / SOAP interfaces.
  • PDF, HTML, PS outputs.
  • SVG support.
  • GUI designer.
  • Built-in charting feature.
Lunacil - Xinc XSL-FO formatter
  • Commerical tool. $495 per cpu.
  • JAVA/COM interfaces.
  • PDF output.
Altova - Stylevision 2005
  • Commerical tool. Starts at $599 per cpu.
  • No interface listed on their website.
  • PDF/HTML/RTF outputs.
  • GUI designer.
ALTSOFT - Xml2PDF.NET
  • Commerical tool. $49 - $1599(depending on the editions).
  • .NET interface.
  • PDF output.
  • SVG support.
  • GUI tool for formatting.

In the mulberrytech mailing list, I was told that http://www.xmlsoftware.com/xslfo.html has a better listing of xsl-fo tools.

UPDATED: Jan 10, 2005.