I tried to use this code in a NetStandard 1.3 class library:
foreach (Type mytype in System.Reflection.Assembly.GetExecutingAssembly().GetTypes()
.Where(mytype => mytype .GetInterfaces().Contains(typeof(myInterface)))) {
//do stuff
}
but a compilation error is raised:
Error CS0117 'Assembly' does not contain a definition for 'GetExecutingAssembly'
I reached What is the equivalent of Assembly.GetEntryAssembly() in .NET Core?, but it can't help.
I know that this service may be available in NetStandard 2, but until it's released(it's now in preview):
What is the modification to be done to the above code to support NetStandard 1.3
Update:
The question isn't a duplicate, i mentioned this link in my question and said it doesn't help.
Based on the comment of @ mjwills, it's probably worth adding that it's best to avoid using netstandard 1.5 or 1.6, as they won't be compatible with netstandard 2.0 https://blogs.msdn.microsoft.com/dotnet/2016/09/26/introducing-net-standard/#div-comment-136675
C# library for .NET Core and .NET Framework
I ask for an equivalent code (not necessary using GetExecutingAssembly):
How I get all classes that implement an interface in NetStandard 1.1 up to 1.4 ?
Assembly.GetEntryAssembly() is available in .NET Standard 1.5, but not in versions 1.0 through 1.4.You need to use a newer version.