Question

i wish to use LogParser.DLL assembly, so i test it over normal console application, it worked, then i put it into a server, send to win 2003 for testing(i have no more free space to install services like database), ... it always returned FileNotFoundException Error in eventViewer logs...

i tried to use stack trace to see what really happen, and i see the DLL does not import at all, afte some searching at google i find an answer in this web site, which told to use .Net command prompt, and then use import assembly command, if i'm write it was tblimp "file name" /out "new file"

i made my assembly, it was .net 4 so i went to my older VS, and done same to provide a .net 2.0.x compatible DLL, i use it and it worked, but...

New Error Apeared:

Error Msg: Retrieving the COM class factory for component with CLSID {8CFEBA94-3FC2-45CA-B9A5-9EDACF704F66} failed due to the following error: 80040154. StackTrace: at FileEventReaderService.EventReader.ReadEventsAndStoreInDatabase(String startDate, String endDate)

            ILogRecordset rs = null;
            try
            {
                ((DebugLogger) _logProviderDebugMode).Log("T1-2", "Debug-EventReaderClass",
                                                          EventLogEntryType.Information);
                LogQueryClass qry = new LogQueryClass();
                COMEventLogInputContextClass eventLogFormat = new COMEventLogInputContextClassClass();
                ((DebugLogger) _logProviderDebugMode).Log("T1-3", "Debug-EventReaderClass",
                                                          EventLogEntryType.Information);
                string query = "select * from security WHERE TimeGenerated >= '" + startDate +
                               "' and TimeGenerated <'" + endDate +
                               "' and (eventid=560 or eventid=540)";
                rs = qry.Execute(query, eventLogFormat);
                ((DebugLogger) _logProviderDebugMode).Log("T1-4", "Debug-EventReaderClass",
                                                          EventLogEntryType.Information);
                for (; !rs.atEnd(); rs.moveNext())
                {
                        //Processes
                }

            }
            catch(Exception ex)
            {
                ((DebugLogger)_logProviderDebugMode).Log(
                        "T1-5\nError Msg: " + ex.Message + "\nStackTrace: " + ex.StackTrace
                        , "Debug-EventReaderClass",
                        EventLogEntryType.Error);
            }
            finally
            {
                ((DebugLogger)_logProviderDebugMode).Log("T1-6", "Debug-EventReaderClass",
                                                          EventLogEntryType.Information);
                if (rs != null)
                    rs.close();
            }

i tried to catch the exception and see if any data is imported, but it seem rs return nothing, also without the if(rs!=null) in "finally" block again it's it self an error which mean rs is null

Event Type: Information Event Source: EventLoggerService Event Category: None Event ID: 0 Date: 8/5/2012 Time: 2:47:20 AM User: N/A Computer: HF-SERVER-PC Description: Debug-EventReaderClass: T1-2

Class Variable Information:

_logProvider: FileEventReaderService.Services.Logger.EventLogger _logProviderDebugMode: FileEventReaderService.Services.Logger.DebugLogger _licenceState: Ok _dataBase: deadManN _interval: 5 _timeGap: 1 _previousReadTime: 8/5/2012 2:40:19 AM _lastReadTime: 8/5/2012 2:46:20 AM _parserLock: System.Object _subtleTime: TimerLib.SubtleTime _parserService: FileEventReaderService.Services.Util.ParserService5 _connectionStringBuilder: FileEventReaderService.Services.Util.ConnectionStringBuilder _lastTime: 18 _minutes: 18

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

the above log, is last log i did before the error, and then it show the log which is logged in "catch" block, so error can be here:

        LogQueryClass qry = new LogQueryClass();
        COMEventLogInputContextClass eventLogFormat = new COMEventLogInputContextClassClass();

so i again start searching for my error msg, and found some things which i was not able to handle alone,

for example, i see some one said to you need to register the DLL manulay or using dllregisterservice or things about putting application to be compile only for 86X cpu type, but i dont wanna do this... cause i dont write this for single user with known hardware and software...

now any one can help? with dll registering while setup applciation or any thing else which may help about the matter? of "Interop.MSUtil.dll" library?

AND please Help, it's so important for me, and still there's too much of time i need, about months after this to just check for logical bugs, not compile ones :|

Was it helpful?

Solution

I were about to write a service, application, and i done some of it, i fall for bugs we talked about in question and also comments...

it's some time passed, so i cant tell you every thing that happend, but i'll give you the answer which put me out of this...


first thing first, i needed to work through dll and my own application not some one else applciation and not running for example log parser with hidden command and with the query as argument through Diagnostig.Process...

so i take the dll,

the dll alone worked in win application which i provide for test, in the O/S vs was in it, it may was for certificate reason.. but it didnt worked in my other server OS, ... also inside the service application it come up with a log which told me i have an IO : FileNotFoundException so i put try catch block and then print the stack trace, the exception told me that once assembly is missing... so i start to search and find that i should import dll in kinda way, So Step 1:

  • see what kinda dll you need, i mean .net version for example i needed .net 2.x based for more support in older OS, but VS 2010 gived me a .net 4.x based DLL, so i refer to Visual studio 2005 in program file
  • open visual studio folder from all program menu of Start menu, the go to "visual studio tools" folder, and in the end run "visual studio command prompt"
  • next put your logparser.dll file in a reachable place like c:\temp\
  • run this command: tlbimp "c:\temp\logparser.dll" /out:"c:\temp\Interop.MSUtil.dll"
  • Notice the "Interop.MSUtil.dll" is the assembly name that application looking for, but you cant directly rename logparser.dll to it
  • put this into your project, and switch all references from logparser.dll to Interop.MSUtil.dll (it's becasue name spaces are different)

till here i fixed some error, but it's not like service work succcesfully, new error appeared while runing log parser, and caused that class instances return Nulls,.. the error is here:

Error Msg: Retrieving the COM class factory for component with CLSID {8CFEBA94-3FC2-45CA-B9A5-9EDACF704F66} failed due to the following error: 80040154. StackTrace: at FileEventReaderService.EventReader.ReadEventsAndStoreInDatabase(String startDate, String endDate)

This Step may Cause nothing, but since i experience changes in error msg i put it here

since i wanted to package my application for many users, it wasnt like i tell all of them to run commands, so i searched even more, some people said about registering the dll, but you cant put logparser.dll in the global assembly catch folder of setup, also later i find out that the registration we do is different than putting assembly in GAC...

also i find out if we want put a dll into GAC first we cant put logparser cause it exported, but the Introp.MSUtil.dll also the setup returned error for putting Interop.MSUtil.dll in the GAC folder The error was about assembly naming, and after some search i find out that the error is for something different, and it happen where assembly is not signed with a pair key...

you can create pair key through cmd, each os you install have a random key that it generate, and also you can export and import these keys for special certificate matter, naturally these commands have their network engineering user, but we software also use it here... So Step 2:

Read this section if you exprience 8007007E / 8007007F errors... they are naturally for the reason of registration of assembly and i dont know but maybe also the shared key which dll is signed with also one more thing you can perform before doing these is test regsvr32 "[dll file address]" which register a dll, and if aapplication doesnt directly use and search for dll you can put it in any folder before registering for example in our project we point to Introp.MSUtil.dll not logparser.dll though we also need it for registration, and then we run regsvr32 command on logparser.dll (this command is just for testing, and have no use in setup and deploying your application, also you can use /u switch to un-register the dll for further testing)

  • create a pair key file using CMD with following command: sn -k [file name] it create the file in the address you are inside
  • next again go to step one, but instead of the old command use this new command which also mix key pair to generate the dll tlbimp "[logparser.dll address]" /out:"[address]\Interop.MSUtil.dll" /pr imary /keyfile:"[pair key file address]"
  • now use new signed dll instead of the one we create before ... ( Interop.MSUtil.dll )

there was also error exist... so i find out that GAC (Global Assembly Catch) wont work alone, and after fixed all bug, i noticed that i can, but i don't need to put Interop.MSUtil.dll in GAC folder of my setup... but this registering matter, the regsvr32, was it the problem? ah yes, it was, thoughi hear this is same to putting assembly into GAC, but it wasn't right, the registration of dll as Global Assembly was different than using regsvr32 to register it... if you want to know your dll is already registered, i think you need to now the namespace or the main assembly inside of it, so you can go through following step to see if it is registered:

  • go to start menu and open up "run" tools
  • type dcomcnfg and press "enter" to open Component Service tools
  • lead to this directory: Console Root->Component Services->Computers->My Computer->DCOM Config
  • now for example for seeing if log parser.dll is registered, look for names like "Interop.Msutil" or "MSUtil"
  • if it is exist, the dll is registered, else it's not

ok, let back to the subject, we need to register the dll, and it cause some errors which i dont remember... cause classes dont work well and return nulls if you register logparser.dll using the command and it worked, for packaging your setup you need to do following things So Step 3:

  • put logparser.dll assembly (which setup know it as file not assembly) in the reachable folder, like Application Folder of your setup project...
  • right click over the file inside Solution Explorer and select Properties
  • click over register section, and over drop down button to see all the available option...
  • select vsdrfCOMSelfReg from the list, notice that some option like this one is not provided for some assembly like the one we create (Introp.MSUtil.dll) so we cant register it, you also cant register that dll with regsvr32... other option wont register the dll as i test

I hope this help you :)

PS: notice that the logparser.dll and the Interop.MSUtil.dll wont detect by project automatically, and you have to add them manually to your Setup and MSI project... you also need both dll as i explained

i hope this work for you...

With many thanks to @Andrii Kalytiiuk
Regarded by Hassan Faghihi

OTHER TIPS

This is an old question but I ran into this error and found the accepted answer somewhat difficult to parse.

Ultimately I had to ensure that LogParser was installed and LogParser.dll was registered on the machine where the code is being run. Else I would receive the error shown in the original question.

From my experience, Interop.MSUtil is not a replacement for LogParser.dll but a facilitator.

It's also worth mentioning that Interop.MSUtil is now available via nuget, but after installation you will have to manually add a reference to the DLL in your solution's packages folder, then right-click the reference and set Embed Interop Types to false.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top