Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime exception on .NET 4.6.2 #58

Closed
jbrant opened this issue Jan 28, 2019 · 7 comments
Closed

Runtime exception on .NET 4.6.2 #58

jbrant opened this issue Jan 28, 2019 · 7 comments
Assignees
Labels

Comments

@jbrant
Copy link

jbrant commented Jan 28, 2019

I'm running Visual Studio 2013 targeting .NET 4.6.2 with GeneticSharp 2.4.0, and get the following runtime exception when attempting to instantiate a GeneticAlgorithm instance (specifically, when the task executor is set):

Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.

Is .NET Framework 4.6.2 still supported, or is .NET standard 2.0.0+ now required?

@jbrant jbrant changed the title Only .NET standard support? .NET 4.6.2 runtime exception Jan 28, 2019
@jbrant jbrant changed the title .NET 4.6.2 runtime exception Runtime exception on .NET 4.6.2 Jan 28, 2019
@giacomelli giacomelli self-assigned this Jan 28, 2019
@giacomelli
Copy link
Owner

If you are just using GeneticSharp from Nuget, you can use it on VS 2013, but if you are building the GeneticSharp's source code from scratch, then you need to follow our guide: Building the whole solution.

What is your case?

@jbrant
Copy link
Author

jbrant commented Jan 28, 2019

I'm installing via Nuget (i.e. not building from the source code).

@giacomelli
Copy link
Owner

giacomelli commented Jan 28, 2019

The Nuget package (https://www.nuget.org/packages/GeneticSharp/) seems to have the right dependencies.

Could you please send, a minimum project sample with this problem happening?

I don't have VS 2013 here, but maybe I can spot what is the problem.

@giacomelli
Copy link
Owner

I've created a console project targeting 4.6.2 and I could not reproduce the error.

Can you try the project attached and compare it with your project?
TestGeneticSharpNet462.zip

@jbrant
Copy link
Author

jbrant commented Jan 29, 2019

Thank you very much for the exemplar project. I actually did still get the above-referenced error, but at compile time. Interestingly, if I commented out the TaskExecutor override in the GeneticAlgorithm object initializer block (i.e. TaskExecutor = new ParallelTaskExecutor()), this resolved the compilation error. but the same runtime exception was still thrown.

Specifically, this is the compilation error:

error CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

@jbrant
Copy link
Author

jbrant commented Jan 30, 2019

Quick update on this: the infrastructure framework DLLs (i.e. GeneticSharp.Infrastructure.Framework.dll) for both the netstandard2.0 and net462 targets have the same hash. Perhaps Nuget has the .NET standard build for both targets. This isn't the case for the domain DLL (GeneticSharp.Domain.dll), which would explain why the above-referenced error only occurs when interface with properties or methods from the infrastructure project.

It looks like the infrastructure DLL that's bundled with the domain project build will always be .NET standard regardless of target framework, so if the GeneticSharp Nuget package is using the infrastructure DLL from the domain build, then maybe that's what's causing the issue.

@giacomelli
Copy link
Owner

Yes, you'are right. I opened the assemblies from geneticsharp.2.4.0.nupkg\lib\net462 in ILSpy:

GeneticSharp.Domain.dll

image

GeneticSharp.Infrastructure.Framework.dll

image

GeneticSharp.Infrastructure.Framework.dll from net462 folder is using .NETStandard instead of .NET Framework.

I'll investigate what is wrong with project files or with the nuget generation.

@giacomelli giacomelli added bug and removed question labels Jan 30, 2019
giacomelli added a commit that referenced this issue Jan 31, 2019
Fixed: Runtime exception on .NET 4.6.2 #58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants