Closed FloPadrone closed 3 years ago
I just created a .NET Std 2.0 class library and add the TaskScheduler 2.9.0 NuGet package. I created the following method in the library and it builds without any errors. Could you need to clean up the NuGet packages and build directories?
using System;
using System.Diagnostics.Eventing.Reader;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Win32.TaskScheduler;
namespace TestTSwithNETStd2
{
public static class Class1
{
public static async System.Threading.Tasks.Task WatchEventsAsync(ManualResetEvent stopEvent, Action<string> onEvent)
{
await System.Threading.Tasks.Task.Run(() =>
{
using (var w = new TaskEventWatcher())
{
w.EventRecorded += (s,e) => onEvent?.Invoke($"{e.TaskEvent.EventRecord.TaskDisplayName}");
w.Enabled = true;
stopEvent.WaitOne();
}
});
var ses = new EventLogSession();
}
}
}
I cleaned already everything even deleted the obj and bin folders manually and also closed VS and rebooted my machine. Did not help. The thing is I have to add the package-ref "System.Diagnostics.EventLog" itself and that conflicts somehow with the builtin package of TaskScheduler.
<ItemGroup>
<PackageReference Include="System.Diagnostics.EventLog" Version="5.0.0" />
<PackageReference Include="System.DirectoryServices" Version="5.0.0" />
<PackageReference Include="System.DirectoryServices.AccountManagement" Version="5.0.0" />
<PackageReference Include="System.DirectoryServices.Protocols" Version="5.0.0" />
<PackageReference Include="System.Management" Version="5.0.0" />
<PackageReference Include="TaskScheduler" Version="2.9.0" />
</ItemGroup>
Thanks. That helps a lot. I am using System.Diagnostics.EventLog
for .NET Core and .NET 5.0, but not .NET Std 2.0. Let me see if I can do that for the next release.
I believe this is fixed in the most recent commit and will release in the next day or so with 2.9.1.
I released 2.9.1 last night. Please confirm the issue is resolved.
Changed my current Class-Lib project to "netstandard2.0". Unfortunately this resulted in getting multiple build errors saying that types exists in both Namespaces "Sysem.Diagnostic.EventLog" and "Microsoft.Win32.TaskScheduler".
Error CS0433 The type 'EventLogSession' exists in both 'Microsoft.Win32.TaskScheduler, Version=2.9.0.0, Culture=neutral, PublicKeyToken=e25603a88b3aa7da' and 'System.Diagnostics.EventLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' How can this beeing resolved?