Today when .NET Core 1.1 got released I wanted to make use of the new GC.GetAllocatedBytesForCurrentThread method which got exposed here by @jkotas .
However I can't do so, I get error CS0117: 'GC' does not contain a definition for 'GetAllocatedBytesForCurrentThread' error when trying to use it.
dotnet --version: 1.0.0-preview2-1-003155
My project.json file:
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
}
},
"imports": "dnxcore50"
}
}
}
The code:
using System;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine(GC.GetAllocatedBytesForCurrentThread());
}
}
}
I took a look at the System.Runtime.cs file and it's using the new moniker netcoreapp11 in few #ifdefs but none of these methods are exposed in System.Runtime. Moreover when I go to .nuget\packages\System.Runtime\4.3.0\lib I can see that there is no separate version for netcoreapp1.1. Anyway when I run the program an use typeof(GC).GetTypeInfo().Assembly.Location I get C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.0\System.Private.CoreLib.ni.dll which has the method exposed.
My question is: how can I use this method without reflection? Am I doing something wrong?
Today when .NET Core 1.1 got released I wanted to make use of the new
GC.GetAllocatedBytesForCurrentThreadmethod which got exposed here by @jkotas .However I can't do so, I get
error CS0117: 'GC' does not contain a definition for 'GetAllocatedBytesForCurrentThread'error when trying to use it.dotnet --version: 1.0.0-preview2-1-003155My project.json file:
{ "version": "1.0.0-*", "buildOptions": { "debugType": "portable", "emitEntryPoint": true }, "dependencies": {}, "frameworks": { "netcoreapp1.1": { "dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.1.0" } }, "imports": "dnxcore50" } } }The code:
I took a look at the System.Runtime.cs file and it's using the new moniker netcoreapp11 in few #ifdefs but none of these methods are exposed in System.Runtime. Moreover when I go to
.nuget\packages\System.Runtime\4.3.0\libI can see that there is no separate version for netcoreapp1.1. Anyway when I run the program an usetypeof(GC).GetTypeInfo().Assembly.LocationI getC:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.0\System.Private.CoreLib.ni.dllwhich has the method exposed.My question is: how can I use this method without reflection? Am I doing something wrong?