Trying to add LogManager.LogFactory = new EventLogFactory()

Hello

I’m trying to add some logging to my solution, i have an internal server error that i’m trying to find.
But adding from nuget Servicestack.Logging.EventLog gives me this error:

The type ‘LogManager’ exists in both ‘ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null’ and ‘ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587’

This error indicates you’re trying to reference both the Signed .NET Framework ServiceStack.Interfaces and the unsigned .NET Standard version, you can only reference the same versions of ServiceStack packages in the entire solution. This is likely caused by referencing the wrong dependencies. If you’re trying to use EventLogFactory I’m assuming you’re trying to only reference .NET Framework builds? In which case one of your dependencies is transitively referencing the .NET Standard version of ServiceStack.Interfaces which you need to resolve by removing any .Core packages or ServiceStack.Kestrel which are the only packages which contains .NET Standard only builds.

Thanks for answer.
I’m confused on what is what really. I have to do some reading i think.
I have created the service project from

npm install -g @servicestack/cli

And then

dotnet-new template-name project-name

The model and the service project is .net 2.0 Standard, but the host is .net 4.7 and running as "Console Application.
Is this the “problem”?

What was the “template-name” that you created?

and what were the steps that caused the issue? i.e. did you try to reference any other packages?

Sorry for late reply.
The template i used was the selfhost-corefx.

I’m trying to reproduce the project and see what framework the projects have from the beginning.
But there is no ServiceStack template anymore on my machine. trying to install but nothing happens.
(Windows 10 build 16299)
First
npm install -g @servicestack/cli

And then just
dotnet new

However, now i have no ServiceStack template anymore at all.
npm uninstall -g @servicestack/cli and then a npm install -g @servicestack/cli but dosen’t help.

You need to run the dotnet-new command, take special note of the -.

Sorry, my misstake. Now i did the
dotnet-new selfhost-corefx TestSelf
And then i just do a rebuild and i got the same error:

Severity Code Description Project File Line Suppression State
Error CS0433 The type ‘IServiceClient’ exists in both ‘ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null’ and ‘ServiceStack.Interfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=02c12cbda47e6587’ TestSelf.Tests D:\slask\TestSelf\TestSelf.Tests\IntegrationTest.cs 33 Active

I can’t repro the issue, running dotnet-new selfhost-corefx TestSelf and rebuilding + running the solution works without issues:

The only thing I can suggest is try clearing out NuGet cache:

$ nuget locals all -clear

If that doesn’t resolve it try upgrading to the latest ServiceStack NuGet packages otherwise I can’t think of anything else except to make sure you have .NET Framework v4.7 properly installed.

Thanks. This worked for me:

$ nuget locals all -clear

Now it works.
Thanks again

Or not?
I added ServiceStack.Logging.EventLog and then i uppgraded to 5.0.3 and i got the same problem/error?
Do you have the same?

You can’t reference the https://www.nuget.org/packages/ServiceStack.Logging.EventLog package because it only contains ServiceStack .NET 4.5 Framework build whereas ASP.NET Core Apps can only reference ServiceStack’s .NET Standard 2.0 builds. The only packages you can reference in .NET Framework ASP.NET Core Apps are listed here, i.e. only packages that end in *.Core or ServiceStack.Kestrel.

Since you’re using the .NET Framework you can just manually copy the 2 classes in your solution instead of referencing the ServiceStack.Logging.EventLog NuGet package:

Thanks.
A bit “confusing” with different frameworks. Maybe in a future there could be a filtering in the visual studio/handling nuget packages that only showing compatible.
I will have to get better attention regarding this but i will learn eventually.

Best regards
greg

I’m not sure how to better explain it, the issue is that you’re creating an ASP.NET Core App in a .NET Framework v4.7 solution, this limits you to only be able to use NuGet packages that only contain .NET Standard 2.0 builds since ASP.NET Core Apps must reference .NET Standard 2.0 builds.

The list I linked to provides the definitive reference, but essentially the rule is that only .Core packages (and ServiceStack.Kestrel) contains only .NET Standard 2.0 builds.

NuGet shows you which builds each package contains under the Dependencies section:

Which shows .NETFramework 4.5 meaning that this package can only be used for classic ASP.NET or HttpListener Self Hosting Web Apps (i.e. not ASP.NET Core). Since you’re using .NET Framework v4.7 it will always try to reference .NET Framework builds over .NET Standard 2.0 which is not what you want.