编译C#代码,不需要TLB Interop.MSUtill.dll文件 [英] Complie C# Code without requirement of TLB Interop.MSUtill.dll file

查看:93
本文介绍了编译C#代码,不需要TLB Interop.MSUtill.dll文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

最近,我用C#编写了一个简单的LogParser应用程序使用COM对象LogParser.dll



C#代码为As关注

_______________________________________________________________________________________

Hello
Recently, I have written a simple LogParser Application in C# Using the COM Object LogParser.dll

C# Code is As follow
_______________________________________________________________________________________

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.
         }
}



代码工作迷人,我没有任何问题。



________________________________________________________________________

我的问题

每当我编译代码时,都会生成DLL文件



Interop.MSUtil.dll



是的我理解,因为它是生成的,因为我直接引用了LogParser.dll COM

但我需要找到使用没有Interop.MSUtil.dll的Complied版本的方法



让我们说,在另一台机器上,

我注册了LogParser.dll,它是成功的,能够通过Fi并将dcomcnfg中注册的类称为MSUtil

我尝试使用命令注册DLL




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"



之后每当我运行Complied Execution时,请查找Interop.MSUtil




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)
***************************************************************************



是的,我也知道复制exe代码旁边的Interop.MSUtil.dll文件正确执行。



我的问题

•为什么它需要Interop.MSUtil.dll即使COMLogParser.dll是注册。

•需要程序,编译我的可执行文件而不需要Interop.MSUtil.dll

注意:

我我正在使用Visual Studio 2008

版本9.0.21022.8 RTM(.NET 3.5 SP 1)

Interop.MSUtil.dll文件由Visual Studio生成,我做了不创建该文件。

我直接引用了Project中的LogParser.dll。这就是全部。



任何对此的帮助都很受欢迎,因为我尝试过很多R& D但似乎没有任何东西适合我。



谢谢和问候

Durai Velan C


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

推荐答案

如果你可以升级到VS2010 / .NET 4.0或者稍后,您可以使用嵌入互操作类型 [ ^ ]选项,以避免生成互操作程序集。



注意:如果 Visual Studio Express [ ^ ]不够好,微软最近发布了 Visual Studio 2013社区版 [ ^ ]。



如果你无法升级,那么你要么必须切换到后期绑定代码,这对于.NET 3.5中的C#来说非常痛苦,要么忍受互操作程序集。
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.


Hello



非常感谢您的回复。

我设法解决了这个问题。



1)当然,对于LogParser.dll.Seems来说,嵌入Interop Type = True可以帮助我满足我的要求。



2)以下是我的观察

VS 2010和.NET 3.5

与Embed Interop Type = True,

仍生成Interop.MSUtill.dll文件



VS 2010和.NET 4.0

与Embed Interop Type = True,

相同的C#代码,抛出编译错误

说某些方法如LogQueryClass无法正确嵌入。



解决方案是我直接引用类如下。

并注意它还需要Microsoft.CSharp-Dll 。



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.

using Microsoft.CSharp;

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





在某种程度上,一切都是由Visual Studio完成的,并且

我没有相关信息到底是做什么的。



所以如果有人解释了这背后的基本或基本原理,那会很有帮助。

假设我必须留下VS2008和.NET 3.5



我该怎么办才能克服这种情况?



比如,后期代码是什么意思。

我可以举一些这方面的例子。只是示例已经足够了,我不是要求直接解决方案。



我问,因为,我想理解而是说Visual Studio修复了这个问题:-)



谢谢和问候

Durai Velan C。



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.


这篇关于编译C#代码,不需要TLB Interop.MSUtill.dll文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆