For cross-platform development, I\'m trying to make a .NET Core shared library. I used the Class Library (package)
project template in VS 2015. My library nee
If you don't want your original code full of #if ... #else ... #endif
statements, you could use a helper library like https://www.nuget.org/packages/ReflectionBridge/ which provides some extensions which define a bridge for the differences between Type and TypeInfo.
(Source code at https://github.com/StefH/ReflectionBridge)
I'm using .net Core 1.0. Try following snippet of project.json and see if works for you. I have also noticed that you are using beta API so if possible stay way from beta.
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23811",
"System.Reflection.TypeExtensions": "4.0.0"
},
"frameworks": {
"dnxcore50": { }
}
}
What am I doing wrong?
You are trying to access members that are available in .NET 4.5.1 but not in 5.4.
4.x Workaround in 5.x/Core
Delegate.Method. Delegate.GetMethodInfo()
Type.BaseType. Type.GetTypeInfo()
Type.FilterName -
Type.InvokeMember -
Type.FindMembers -
Visual Studio tells us this if we hover our mouse over the error.
It is also worth looking at the .NET Portability Analyzer. It is an extension that we can install from the Visual Studio Gallery.
Running it tells us, for instance, that Type.BaseType
is not available and recommends a workaround.