简体   繁体   English

CS0012 类型“EventLogEntryType”在未引用的程序集中定义

[英]CS0012 The type 'EventLogEntryType' is defined in an assembly that is not referenced

currently I am using .net standard and .net framework in the project .目前我在项目中使用 .net 标准和 .net 框架。 In .net standard I have created a function在 .net 标准中,我创建了一个函数

public static void WriteEntryLog(string source, string message, EventLogEntryType entryType)

when I am trying to use it on .net framework installer class , that time it gives an error当我尝试在 .net 框架安装程序类上使用它时,它会出现错误

Error   CS0012  The type 'EventLogEntryType' is defined in an assembly that is not referenced. 
You must add a reference to assembly 'System.Diagnostics.EventLog, Version=4.0.2.0, Culture=neutral, 
PublicKeyToken=cc7b13ffcd2ddd51'.

if i install the latest nuget package of "System.Diagnostics.EventLog" it got work in compile time but during the installation its unable to find the System.Diagnostics.EventLog package and failed to install.如果我安装“System.Diagnostics.EventLog”的最新 nuget 包,它可以在编译时工作,但在安装过程中它无法找到 System.Diagnostics.EventLog 包并且无法安装。

you mentioned the latest version你提到了最新版本

if i install the latest nuget package of "System.Diagnostics.EventLog"如果我安装“System.Diagnostics.EventLog”的最新 nuget 包

Normally, the Visual Studio creates the assembly binding redirects automatically for you.通常,Visual Studio 会自动为您创建程序集绑定重定向。 You can find those binding redirects in the .config files in the project's target directory after build.构建后,您可以在项目目标目录中的 .config 文件中找到这些绑定重定向。 Those assembly redirects contain the infrmation for the runtime to use the exact version you have included at your project as "latest" when the 4.0.2 is requested by the application.当应用程序请求 4.0.2 时,这些程序集重定向包含运行时使用您在项目中包含的确切版本作为“最新”的信息。 When you creating the installer it is easy to miss the config file.创建安装程序时,很容易错过配置文件。

You may try either:您可以尝试以下任一方法:

  1. Ensure you have added all .config files into your installer,确保您已将所有 .config 文件添加到安装程序中,
  2. Or add the exact nuget package version (4.0.2) from your nuget manager.或者从您的 nuget 管理器中添加确切的 nuget 包版本 (4.0.2)。 This would make the binding redirection unnecessary.这将使绑定重定向变得不必要。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误CS0012:类型“DbConnection”在未引用的程序集中定义 - Error CS0012: The type 'DbConnection' is defined in an assembly that is not referenced CS0012 C#类型“ HttpContext”在未引用的程序集中定义 - CS0012 C# The type 'HttpContext' is defined in an assembly that is not referenced 错误CS0012:类型'TaskAwaiter <>'在未引用的程序集中定义 - error CS0012: The type 'TaskAwaiter<>' is defined in an assembly that is not referenced 错误CS0012:类型&#39;ConnectionStringSettings&#39;在升级到Visual Studio 2015后未引用的程序集中定义 - error CS0012: The type 'ConnectionStringSettings' is defined in an assembly that is not referenced after upgrading to Visual Studio 2015 .Net Core-CS0012&#39;对象&#39;在未引用的程序集中定义 - .Net Core - CS0012 'Object' is defined in an assembly that is not referenced 使用RazorTemplates库时发生错误:&#39;CS0012:类型&#39;System.Attribute&#39;在未引用的程序集中定义&#39; - Error when using RazorTemplates library: 'CS0012: The type 'System.Attribute' is defined in an assembly that is not referenced' CS0012 System.enum在未针对.NET 4.5的构建服务器上引用的程序集中定义 - CS0012 System.enum is defined in an assembly not referenced on build server targeting .NET 4.5 MSBuild错误CS0012 - MSBuild Error CS0012 FluentAssertions 错误 CS0012:您必须添加对程序集 System.Data 的引用 - FluentAssertions error CS0012: You must add a reference to assembly System.Data 使用C#代码生成问题-CS0012-IsLongModifier - Build issue with c# code - CS0012 - IsLongModifier
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM