Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
Recently, I have written a simple LogParser Application in C# Using the COM Object LogParser.dll

C# Code is As follow
_______________________________________________________________________________________
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MSUtil;
namespace getHttpStatusCode
{
    class getHttpStatusCode
    {
        public static LogQueryClassClass LogParser = new LogQueryClassClass();
        public static COMIISW3CInputContextClass inputContext = new COMIISW3CInputContextClassClass();

        public static ILogRecordset rsLP = null;
        public static ILogRecord rowLP = null;

        static int Main(string[] args)
        {
               // Written a LogParser expression to Parse certain ISW3C Logs.
         }
}

The code work charmingly and I do not have any issue with it.

________________________________________________________________________
My Issue
Whenever I compile the code a DLL File is being generated

Interop.MSUtil.dll

Yes I understand because it is generated, as I am directly referencing the LogParser.dll COM
But I need to find ways to Using the Complied version without that "Interop.MSUtil.dll "

Let Us say, on Another Machine,
I registered the " LogParser.dll " and it is Successful and able to Find that registered class in the dcomcnfg as "MSUtil"
I tried registering the DLL with command

regsvr32 "Location of the LogPasrser.dll"

After that whenever I ran the Complied Execution it always, Look for"Interop.MSUtil"

C:\...\Desktop>getHttpStatusCode.exe
Unhandled Exception: System.TypeInitializationException: The type initializer for 'getHttpStatusCo
xception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Interop.MSUtil, V
 PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'Interop.MSUtil, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
   at getHttpStatusCode.getHttpStatusCode..cctor()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!En
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

   --- End of inner exception stack trace ---
   at getHttpStatusCode.getHttpStatusCode.Main(String[] args)
***************************************************************************

Yes, I also know that copying the Interop.MSUtil.dll file next to the exe the code executes properly.

My Question
• Why it need "Interop.MSUtil.dll" even though the COM "LogParser.dll" is registered.
• Need to Procedure, a compile my Executable without the requirement of the "Interop.MSUtil.dll"
Note:
I am Using the Visual Studio 2008
Version 9.0.21022.8 RTM ( .NET 3.5 SP 1)
And Interop.MSUtil.dll file is generated by the Visual Studio and I did not create that file.
I just directly referenced the LogParser.dll in my Project. That is all.

Any Help on this appreciated, as I tried lot of R&D but nothing seems to working for me.

Thanks and Regards
Durai Velan C
Posted
Updated 2-Dec-14 1:19am
v3
Comments
Mehdi Gholam 2-Dec-14 6:38am    
Try using a non com log parser written in .net instead.
Duraivelan Chockalingam 2-Dec-14 8:12am    
Hello Mehdi,
Thanks for Reply. But I have not known of NON Com Logparser Instead.
If you have kindly refer, me where I can find one
Thanks you.

If you can upgrade to VS2010 / .NET 4.0 or later, you could use the Embed Interop Types[^] option to avoid generating an interop assembly.

NB: If Visual Studio Express[^] isn't good enough, Microsoft recently released Visual Studio 2013 Community Edition[^].

If you can't upgrade, then you'll either have to switch to late-bound code, which is quite painful from C# in .NET 3.5, or put up with the interop assembly.
 
Share this answer
 
Comments
TheRealSteveJudge 2-Dec-14 10:54am    
Good idea! 5*
BillWoodruff 2-Dec-14 12:32pm    
+5
Hello

Thanks a Lot for the reply.
I have managed to Solve this.

1) Of-Course right, Embed Interop Type=True for the LogParser.dll.Seems to helping to go with my requirement.

2) Here are My Observation
VS 2010 and .NET 3.5
Along with Embed Interop Type=True,
Still generates the Interop.MSUtill.dll file

VS 2010 and .NET 4.0
Along with Embed Interop Type=True,
The Same C# Code, throws Compilation error
Saying Certain Method like LogQueryClass cannot be Embedded properly.

Solution was I Directly reference the Classes as follows.
And note it also required Microsoft.CSharp-Dll also.

C#
using Microsoft.CSharp;

public static LogQueryClass LogParser = (LogQueryClass)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("8CFEBA94-3FC2-45CA-B9A5-9EDACF704F66"))); 


In a way, everything is done by the Visual Studio and
I don´t have information of what exactly it does.

So It would be helpful if someone explains the basic or fundamentals behind this.
Suppose If I have to stay of the VS2008 and .NET 3.5

What should I do to overcome the situation ?

Like, "late-bound code" What does this mean.
May I have certain examples on this. Just example is enough and am not asking for directly solution though.

I am asking because, I wanted to understand rather saying Visual Studio fixed that issue :-)

Thanks and Regards
Durai Velan C.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900