Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Dynamic code generation is not supported on this platform. #7386

Closed
ifew opened this issue May 2, 2019 · 2 comments
Closed

Dynamic code generation is not supported on this platform. #7386

ifew opened this issue May 2, 2019 · 2 comments

Comments

@ifew
Copy link
Contributor

ifew commented May 2, 2019

Hi

I using Dapper and NPoco for connecting database, and it's work on normal compile
but when I compile to native, I got the message Unhandled Exception: System.PlatformNotSupportedException: Dynamic code generation is not supported on this platform. of both libraries

Both, I using
<TargetFramework>netcoreapp3.0</TargetFramework>

<PackageReference Include="MySqlConnector" Version="0.53.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.7.0-preview4.19212.13" />

Dapper

Log: Start Connection
Log: _connection.ConnectionString: Server=localhost;User Id=root;Database=lab;Convert Zero Datetime=True
Log: ServerVersion After Open: 5.5.5-10.2.15-MariaDB-log
Log: State: Open
Unhandled Exception: System.PlatformNotSupportedException: Dynamic code generation is not supported on this platform.
   at System.Reflection.Emit.ReflectionEmitThrower.ThrowPlatformNotSupportedException() + 0x38
   at Dapper.SqlMapper.GetTypeDeserializerImpl(Type, IDataReader, Int32, Int32, Boolean) + 0xb5
   at Dapper.SqlMapper.TypeDeserializerCache.GetReader(IDataReader, Int32, Int32, Boolean) + 0x154
   at Dapper.SqlMapper.TypeDeserializerCache.GetReader(Type, IDataReader, Int32, Int32, Boolean) + 0x16c
   at Dapper.SqlMapper.GetDeserializer(Type, IDataReader, Int32, Int32, Boolean) + 0x14f
   at Dapper.SqlMapper.<QueryImpl>d__138`1.MoveNext() + 0x263
   at System.Collections.Generic.List`1..ctor(IEnumerable`1) + 0x10c
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1) + 0x43
   at Dapper.SqlMapper.Query[T](IDbConnection, String, Object, IDbTransaction, Boolean, Nullable`1, Nullable`1) + 0x1c6
   at Member.Program.Main() + 0x11c
   at bootstrap!<BaseAddress>+0xa8959b

NPoco

Log: Start Connection
Log: _connection.ConnectionString: Server=localhost;User Id=root;Database=lab;Convert Zero Datetime=True
Unhandled Exception: System.PlatformNotSupportedException: Dynamic code generation is not supported on this platform.
   at System.Reflection.Emit.ReflectionEmitThrower.ThrowPlatformNotSupportedException() + 0x43
   at System.Reflection.Emit.DynamicMethod..ctor(String, Type, Type[], Type, Boolean) + 0x30
   at NPoco.MemberAccessor.GetSetDelegate() + 0x225
   at NPoco.MemberAccessor..ctor(Type, String) + 0x357
   at NPoco.PocoDataBuilder.<>c.<GetMemberAccessors>b__32_0(MemberInfo) + 0x77
   at System.Linq.Enumerable.SelectListIterator`2.MoveNext() + 0x141
   at System.Collections.Generic.List`1..ctor(IEnumerable`1) + 0x212
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1) + 0x7c
   at NPoco.PocoDataBuilder.GetMemberAccessors(IEnumerable`1) + 0xb7
   at NPoco.PocoDataBuilder.<GetPocoMembers>d__28.MoveNext() + 0x708
   at System.Collections.Generic.List`1..ctor(IEnumerable`1) + 0x212
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1) + 0x7c
   at NPoco.PocoDataBuilder.Init() + 0xf5
   at NPoco.PocoDataFactory.BaseClassFalbackPocoDataBuilder(Type) + 0x55
   at NPoco.PocoDataFactory.<>c__DisplayClass3_0.<ForType>b__0() + 0x29
   at NPoco.Cache`2.Get(TKey, Func`1) + 0xd6
   at NPoco.PocoDataFactory.ForType(Type) + 0xc0
   at NPoco.AutoSelectHelper.AddSelectClause(Database, Type, String) + 0x108
   at NPoco.Database.<QueryImp>d__153`1.MoveNext() + 0x108
   at System.Collections.Generic.List`1..ctor(IEnumerable`1) + 0x212
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1) + 0x7c
   at NPoco.Database.Fetch[T](Sql) + 0x60
   at NPoco.Database.Fetch[T](String, Object[]) + 0x67
   at NPoco.Database.Fetch[T]() + 0x6d
   at Member.Program.Main() + 0x16a
   at corert-db-dapper!<BaseAddress>+0xfe4db9
   at corert-db-dapper!<BaseAddress>+0xfe4e2c
@MarcoRossignoli
Copy link
Member

AFAIK dynamic code generation is not fully supported at the moment.
Take a look at great @MichalStrehovsky's post https://medium.com/@MStrehovsky/fight-the-global-warming-compile-your-c-apps-ahead-of-time-9997e953645b

@MichalStrehovsky
Copy link
Member

Marco is right - this Reflection.Emit requires a JIT or an interpreter. We track the interpreter in #5011.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants