Thoughts from Dan Miser RSS 2.0
 Wednesday, September 13, 2006
It seems that COM interop isn't always a good thing. I have a problem that I don't have a solution for right now, so if you have any feedback, I'd sure appreciate hearing it.

I wrote a wrapper around Lucene.Net to provide simple API access to some very basic operations (index, search, delete) that will be used by a Delphi Win32 application. Everything was working fine, but deep in the bowels of the Lucene code, in one code path, I encountered a line like this:


      return (float) (System.Math.Log(numDocs / (double) (docFreq + 1)) + 1.0);

When there are no documents in the index, this essentially evaluates to a call to System.Math.Log(0.0), which according to the MSDN documentation, should return NegativeInfinity. In fact, when this library is called from a .NET client, it does just that. However, when called via COM interop, this results in an exception, "Attempted to divide by zero". I started to modify the Lucene source to do a check for this condition and just manually return NegativeInfinity, and that did get me past that point, but then later on in the Lucene code, I end up getting an "Arithmetic overflow/underflow" error when Lucene tries to do some math on the returned value. So rather than continue to band-aid this problem, I thought I'd try to dig to the root of the problem to see why this is happening.

You can find an extremely simple test case with a .NET Class Library, .NET test client, and Delphi test client here. Just build the .NET solution, and then you can run the createtlb.bat file in the LogClient directory to get the Delphi project ready.

Wednesday, September 13, 2006 10:11:00 AM (Central Standard Time, UTC-06:00)  #    Comments [3] -
Delphi
Tracked by:
http://9nt-information.info/84692651/index.html [Pingback]
http://9ny-information.info/99514918/index.html [Pingback]
http://9nb-information.info/67688867/index.html [Pingback]
http://9nx-information.info/27983903/index.html [Pingback]
http://9nv-information.info/46728496/index.html [Pingback]
http://9nw-information.info/11898771/index.html [Pingback]
http://9nk-information.info/84303507/index.html [Pingback]
http://9nb-information.info/24003836/car-retail-values.html [Pingback]
http://9ns-information.info/58391515/index.html [Pingback]
http://9ns-information.info/35582443/asia-pacific-panama-travel.html [Pingback]
http://9ng-information.info/67072344/index.html [Pingback]
http://9nt-information.info/71436764/index.html [Pingback]
http://9na-information.info/49349336/cathedral-christian-school-and-birmingham-a... [Pingback]
http://9nw-information.info/94879880/index.html [Pingback]
http://9oa-information.info/49707287/index.html [Pingback]
http://9qh-information.info/30203111/index.html [Pingback]
http://9qf-information.info/73384706/mrp-m650.html [Pingback]
http://9ov-information.info/17457439/index.html [Pingback]
http://9ok-information.info/65164362/honda-motorcycle-front-brake-re-build.html [Pingback]
http://9oh-information.info/78036263/conservative-hinduism-versus-modern-hinduis... [Pingback]
http://9qt-information.info/55221514/watson-s.html [Pingback]
http://9sk-information.info/52275447/index.html [Pingback]
http://9se-information.info/04027799/index.html [Pingback]
http://9sg-information.info/32496913/index.html [Pingback]
http://9rj-information.info/79504831/arizona-estate-investment-real-scottsdale.h... [Pingback]
http://9rf-information.info/33887899/market-basket-grocery-stores-locations-in-m... [Pingback]
http://9st-information.info/44724043/telefonini-milano.html [Pingback]
http://9sb-information.info/44010111/edonkey-1-4.html [Pingback]
http://9rt-information.info/76262680/bell-customer-service.html [Pingback]
http://9sg-information.info/95629150/index.html [Pingback]
http://9sa-information.info/26030653/comuni-italiani-lista.html [Pingback]
http://9ri-information.info/59552263/motorized-panel-equipment.html [Pingback]
http://9sl-information.info/57671930/aspirapolvere-aspiraliquidi.html [Pingback]
http://9sn-information.info/68542417/nu-8a.html [Pingback]
http://9rg-information.info/44386472/99-ford-f-150-blinking-check-engine-light-u... [Pingback]
http://9rw-information.info/66631291/index.html [Pingback]
http://9rr-information.info/25422678/index.html [Pingback]
http://9rk-information.info/95939994/index.html [Pingback]
http://9sd-information.info/28543469/index.html [Pingback]
http://9rt-information.info/50146007/index.html [Pingback]
http://9sd-information.info/87990474/index.html [Pingback]
http://9rb-information.info/26986060/index.html [Pingback]
http://9rd-information.info/88787720/index.html [Pingback]
http://9rb-information.info/71684793/index.html [Pingback]
http://9rn-information.info/50887734/index.html [Pingback]
http://9uaee-le-informazioni.info/65148044/costo-variabili-business-plan.html [Pingback]
http://9uafq-le-informazioni.info/98690546/index.html [Pingback]
http://9uafd-le-informazioni.info/28603531/index.html [Pingback]
http://9uaeo-le-informazioni.info/71213120/index.html [Pingback]
http://9uaej-le-informazioni.info/47858348/educazione-sentimentale-eugenie-sched... [Pingback]
http://9uael-le-informazioni.info/47606918/caratteristica-dei-cavaliere.html [Pingback]
http://9uafd-le-informazioni.info/60572376/index.html [Pingback]
http://9uafg-le-informazioni.info/94758937/baccio-scultore.html [Pingback]
http://9uafj-le-informazioni.info/60655378/index.html [Pingback]
http://9uafe-le-informazioni.info/06181801/carmen-martinez-bordiu-franco-2006.ht... [Pingback]
http://9uafh-le-informazioni.info/54429840/index.html [Pingback]
http://9uaej-le-informazioni.info/42354150/acquisto-biglietti-spettacolo.html [Pingback]
http://9uaer-le-informazioni.info/71365983/giochi-medioevo.html [Pingback]
http://9uafn-le-informazioni.info/83022232/index.html [Pingback]
http://9uafj-le-informazioni.info/56956111/index.html [Pingback]
http://9uaft-le-informazioni.info/87728617/index.html [Pingback]
http://9uafj-le-informazioni.info/01271618/index.html [Pingback]
http://9uafe-le-informazioni.info/68222010/arzona-altervista-org.html [Pingback]
http://9uaeg-le-informazioni.info/27077327/live-soccer-risultati.html [Pingback]
http://9uaed-le-informazioni.info/62269279/index.html [Pingback]
http://9uaed-le-informazioni.info/50563026/dancing-dog.html [Pingback]
http://9uafk-le-informazioni.info/97167298/index.html [Pingback]
http://9uaen-le-informazioni.info/18623397/piano-di-lavoro-amianto.html [Pingback]
http://9uaef-le-informazioni.info/38265876/volo-brasile-lauda.html [Pingback]
http://9uafh-le-informazioni.info/97601947/geox-negozio-padova.html [Pingback]
http://9uafb-le-informazioni.info/15154432/lavastoviglie-bosch-skt-5102.html [Pingback]
http://9uaed-le-informazioni.info/74251226/sicilia-porto.html [Pingback]
http://9uagb-le-informazioni.info/56913863/psyco-wand.html [Pingback]
http://9uagg-le-informazioni.info/16774569/index.html [Pingback]
http://9uaht-le-informazioni.info/17203273/index.html [Pingback]
http://9uags-le-informazioni.info/85697073/index.html [Pingback]
http://9uahq-le-informazioni.info/63257601/index.html [Pingback]
http://9uagr-le-informazioni.info/64851384/index.html [Pingback]
http://9uags-le-informazioni.info/34930234/index.html [Pingback]
http://9uags-le-informazioni.info/08378400/home-putting-green.html [Pingback]
http://9uahr-le-informazioni.info/35384974/monitor-lcd-touch.html [Pingback]
http://9uahg-le-informazioni.info/40223097/comitato-fiera.html [Pingback]
http://9uahg-le-informazioni.info/79972025/index.html [Pingback]
http://9uahq-le-informazioni.info/75417807/index.html [Pingback]
http://9uahk-le-informazioni.info/36681043/make-avenue-script-pdf.html [Pingback]
http://9uagm-le-informazioni.info/13059419/index.html [Pingback]
http://9uagp-le-informazioni.info/04572341/file-rep.html [Pingback]
http://9uago-le-informazioni.info/17626955/index.html [Pingback]
http://9uagh-le-informazioni.info/06438997/index.html [Pingback]
http://9uahn-le-informazioni.info/70761941/biografia-thomas-becket.html [Pingback]
http://9uaht-le-informazioni.info/45374311/index.html [Pingback]
http://9uahq-le-informazioni.info/32696348/breve-storia-dell-educazione.html [Pingback]
http://9uahk-le-informazioni.info/46722072/fusco-via-s-gregorio-armeno-napoli.ht... [Pingback]
http://9uagq-le-informazioni.info/97053112/index.html [Pingback]
http://9uahi-le-informazioni.info/32882370/index.html [Pingback]
http://9uahc-le-informazioni.info/90782316/ih-winnie-the-pooh.html [Pingback]
http://9uagq-le-informazioni.info/10973287/vendita-casale-cascia-fondo-rustico.h... [Pingback]
Thursday, September 14, 2006 8:25:00 AM (Central Standard Time, UTC-06:00)
I have run into simular problems, where specific parameters for some 3rd party .NET assemblies required me to code a special "helper" function in C#, then invoke that helper using Managed.VCL. (http://www.managed-vcl.com/). The nice thing about the managed-vcl part, is that I no longer have to worry about making my wrapper "com interop" compatible...I just code the class and then call it directly from my Win32 Delphi app using the Managed.VCL calls. This also alowed me to eliminate the messy EXEFILE.EXE.config files, which were causing problems under situations where customers have various versions of the framework installed, and different versions of the 3rd party application which use different framework versions. Now I have ONE executable, ONE C# helper DLL and it works across ALL versions (so far at least).
Thursday, September 14, 2006 8:55:00 AM (Central Standard Time, UTC-06:00)
Thanks for the feedback. Does ManagedVCL make my test case work any better?
Tuesday, September 19, 2006 9:41:00 AM (Central Standard Time, UTC-06:00)
Couldn't it be a 8087 control word issue? Maybe COM Interop uses a different exception mask?
Matt
Comments are closed.
Navigation
Archive
<August 2008>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Dan Miser
Sign In
Statistics
Total Posts: 307
This Year: 22
This Month: 1
This Week: 1
Comments: 604
All Content © 2008, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)