英文:
System.Diagnostics.EventLog.dll assembly not on machine and .NET Framework is installed
问题
根据Microsoft文档,System.Diagnostics.EventLog
类是.NET Framework的一部分,它在System.Diagnostics.EventLog.DLL
程序集中定义。
我在我的计算机上安装了.NET Framework 4.8,并且期望我的应用程序能够在运行时绑定到这个引用的程序集,而不需要提供我的安装程序集。然而,由于文件未找到(指的是程序集本身),它无法绑定到它。也就是说,运行时查找的位置之一中不存在这个程序集。我正在使用fuslogvw.exe来查看这些信息。
我已经在我的计算机上手动搜索了这个程序集,它既不在GAC中,也不在C:\Windows\Microsoft.NET\Framework\v4.0.30319目录下。
由于它应该是.NET Framework的一部分,我不清楚为什么它不在我的计算机上。
我应该指出,需要绑定到EventLog程序集的是安装程序本身(一个使用自定义操作的wix安装程序,最终引用了EventLog)。
我想我的问题是:如果它是.NET Framework的一部分,为什么它不在计算机上呢?或者也许我正在错误的位置查找,我应该在哪里找到它?
如果能提供任何见解,将不胜感激。
编辑:
引用EventLog类的FirstLib目标是.NET Standard 2.0。SecondLib引用了FirstLib,它的目标是.NET Framework 4.8。
在.NET Standard中,EventLog
类在System.Diagnostics.EventLog.dll
程序集中。在.NET Framework 4.8中,它在System.dll
程序集中。我认为这可能是问题的原因,我需要告诉它查找System.dll而不是其他地方。
我不确定解决方案是什么,但Hans的评论让我意识到我对原始描述的一部分理解错误。
英文:
According to Microsoft documentation the System.Diagnostics.EventLog
class is part of the .NET Framework and it is defined in the System.Diagnostics.EventLog.DLL
assembly.
I do have .NET Framework 4.8 installed on my machine and I expected my app to be able to bind to this referenced assembly at runtime without needing to provide the assembly with my installation. However, it is failing to bind to it due to file not found (referring to the assembly itself). I.e. the assembly is not in one of the locations the runtime is looking. I am using fuslogvw.exe to see this information.
I have manually searched for this assembly on my machine and it is not in the GAC and it is not in C:\Windows\Microsoft.NET\Framework\v4.0.30319.
Since it is supposed to be part of the .NET Framework, I am unclear why it is not on the machine.
I should note it is the installer itself that is needing to bind to the EventLog assembly. (a wix installer using a custom action that ends up referencing EventLog).
I suppose my question is: why is it not on the machine if it is part of the .NET Framework? Or maybe I am looking in the wrong location, where will I find it?
Any insight that can be provided is appreciated.
Edit:
The FirstLib that references the EventLog class targets .NET Standard 2.0. SecondLib references FirstLib and it targets .NET Framework 4.8.
With .NET Standard the EventLog
class is in the assembly System.Diagnostics.EventLog.dll
. With .NET Framework 4.8 it is in System.dll
assembly. I believe this may be the cause of the problem and I need to tell it to look in System.dll instead.
I am not sure what the solution is but Hans comment made me realize I got part of the original description wrong.
答案1
得分: 1
所以你有:
- 一个.NET Framework 4.8项目,引用
- 一个.NET Standard 2.0库,引用
- 来自Windows扩展的System.Diagnostics.EventLog
- 一个.NET Standard 2.0库,引用
然后你的框架项目也需要那个EventLog DLL。当针对Framework(因此隐式地是Windows)时,这将导致一个“shim” DLL 部署到你的应用程序旁边。这将把它的类型转发到适当的Framework DLLs。
英文:
So you have:
- A NET Framework 4.8 project, referencing
- A .NET Standard 2.0 library, referencing
- System.Diagnostics.EventLog from the Windows Extensions
- A .NET Standard 2.0 library, referencing
Then your framework project also needs that EventLog DLL. When targeting Framework (and therefore implicitly Windows), this will result in a "shim" DLL to be deployed next to your application. This will have its types forwarded to the appropriate Framework DLLs.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论