Most recent post

Sunday, March 9, 2008

Freeware - LogParser.SampleQFE

I decided to have a go at writing a Log Parser COM Input Format Plugin using VB.NET. The COM Input Format Plugins allow you to write your own data custom parser of a data source. Note: This is different from the Log Parser COM Interface where you can call Log Parser methods from code.

I decided to look for some VB.NET examples, however couldn't see any out there so I thought that I'd convert the VBScript SampleQFE (which is available in the .\Log Parser 2.2\Samples\COM\QFE folder).

Couple of points I found in my travels.
1. Log Parser needs components that expose COM interfaces, therefore if you are using VB.NET you need to do the following :-
a. Mark the Class you build as a 'COM Class' and 'COM visible'
b. If you want it having a sensible COM name then use the code below :-

<System.Runtime.InteropServices.ProgId("Gluegood.LogParser.SampleQFE") _
, Microsoft.VisualBasic.ComClass()> _
Public Class SampleQFE


c. Bit of a gotcha for young players is that the AssemblyInfo.vb file of your project you must also have this line :-

<Assembly: ComVisible(True)>

See this artcile for more information on COM in .NET
Calling .NET From COM

2. Additionally you must install it in the Global Assembly Cache (GAC). To install into the GAC you need to provide it with a Strong Key Name.
a. Run this command to generate a new Strong Key Name

"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sn" -k .\your folder\SampleQFE.snk

b. Add the SampleQFE.snk (which contains the Strong Key Name) to you project using the following line in code :-

<Assembly: AssemblyDelaySign(False)>
<Assembly: AssemblyKeyFile("C:\LogParser.SampleQFE\Code\SampleQFE\My Project\SampleQFE.snk")>


See this article for more info on this.

3. Compile
4. Register the COM interfaces into the Registry using REGASM.EXE. e.g. the following command :-
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe" "C:\LogParser.SampleQFE\Code\SampleQFE\bin\Release\SampleQFE.dll"

5. Install the Compiled DLL into the GAC using GACUTIL so it can be universally accessed. e.g.

"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil" /i .\Code\SampleQFE\bin\Release\SampleQFE.dll

Hopefully this is enough to get someone else out there through the intial hurdles. Incidentally I've made the SampleQFE available here for download.

Now to call from Log Parser run the following command :-

"C:\Program Files\Log Parser 2.2\LogParser.exe" "Select * From ." -i:COM -o:DataGrid -iProgId:Gluegood.LogParser.SampleQFE -iCOMParams:ExtendedFields&eq;ON -e:10

Download. VB.NET source is included in download.

0 Comments:

Post a Comment

<< Home