❔ ✅ Unhandled Exception: EETypeRva:0x0017C798: Reflection_Disabled on startup?
Hi all!
I'm trying to build an AOT-compiled project with reflection disabled, using
<IlcDisableReflection>true</IlcDisableReflection>
. However, I'm getting the following exception on startup:
The project compiles fine without IlcDisableReflection
. This exception only appeared when I added GUI functionality to my project with the help of ImGui.NET.
The NuGet packages I'm using are:
Can anyone help me out? Thanks in advance! 40 Replies
hmmm, looks like this comes from a generated class in here: https://github.com/SharpGenTools/SharpGenTools/blob/461a942deb05c6f82489d11eccfb3c05b2d85def/SharpGen.Generator/SharpGenModuleGenerator.GenerateModule.cs#L237
GitHub
SharpGenTools/SharpGenModuleGenerator.GenerateModule.cs at 461a942d...
Accurate and high performance C++ interop code generator for C#. - SharpGenTools/SharpGenModuleGenerator.GenerateModule.cs at 461a942deb05c6f82489d11eccfb3c05b2d85def · SharpGenTools/SharpGenTools
if i may, i would suggest using TerraFX.Introp.Windows instead of Vortice
it does not do any reflection
i looked into it but Vortice simplified a lot of things
like i'm not sure what to do here
(i mean what's the "correct" way to get IDXGIFactory)
thats kinda scary
but thanks! :p
or, rather
using var dxgiDevice = device.As<IDXGIDevice>()
sorry, i forgot about that
uh
that's what i meant
it has been a whileuuuum i don't have an
As
method ^^'>oh
i'm porting this from vortice code so the types remained the same
(for context)
oh, i see
yeah, it's going to be painful
:(
i was thinking of making an IL weaving shim that just replaces all
System.Type.GUID
accesses with a GUID that's generated using the runtime type handle lolis there a reason you want to use IlcDisableReflection
but then i noticed it has so much more reflection code scattered everywhere
mainly to protect the source code, i guess
w/ a hex editor i noticed that all type names and stuff like that are included in the executable (which is expected behavior of course)
it would be nice to have something like "partial reflection" XD
maybe something like a
[DontReflect]
attribute
so i could mark my codebase as "please dont include type info of this assembly ty <3"
i guess i could use an obfuscator..... but i figured that i'd try doing it without reflection firstto be clear, the NativeAOT compiler only keeps required reflection metadata
so if it's in the executable it's because there are codepaths that will use it
sooo if i just obfuscate the names of all members + types + namespaces, that would be enough to protect something from reverse engineering?
(i know that with enough patience everything can be reverse engineered but i just want to dismay casual onlookers i guess lol)
the casual onlookers will already be dismayed because there is no IL
and the native code will be incomprehensible in any binary reverse engineering toolkit you can find, becuase none of them are tuned for RyuJIT. which will dismay almost all of the less casual ones
i mean. renaming everything is free and easy. so, sure, why not
but you are already reaching the tail end of protections here
yeah i already have IL weaving set-up for string encryption so i think i can easily plug member name obfuscation in there
i guess i was a bit paranoid about reflection giving away a bit too much info lol
alright, thanks for the help!!
you can probably try to debug why the reflection metadata is being preserved
i mean stuff that wasnt used wasnt included so that was working correctly
stuff that is used but not by reflection should not be included
it was just that it included names of internal classes so i was a bit spooked ;P
the compiler will remove the name and metadata for a method while keeping its native code if it sees that the method is never accessed with reflection. (same for classes and so on)
so if it's there, something is keeping it there. which means reflection-free was broken anyway
(and, i know this is a bit of a dumb question, but... are you sure you turned off stack trace metadata as well)
uuuuuuuuuhhh
weeelll
lets just say
i forgot to do that because i disabled reflection and that took care of it XD
you may want to try with
<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
and see how many strings are there
it is harmless, your exception stack traces will just be mostly offsets instead of namesi see theres a lot of fancy properties like that
is there documentation that lists them?
everything that begins with Ilc is not "officially" supported
but there is some "internal" documentation about the flags here https://github.com/dotnet/runtime/tree/c32bee11a457151e5c400107ababed54dcd70438/src/coreclr/nativeaot/docs
yeye i saw that but i couldnt find any docs about IlcScanReflection for example
IlcGenerateStackData was on the optimization page
the reflection-free mode is sort of a dud. it breaks all sorts of code that is not even related to reflection, like HttpClient, Process.Start, some crypto stuff, there's more. if you can get it to work without using it then your day will be much brighter
and you will be able to use Vortice
oh, i see...
i mean. it breaks them because they use reflection. it's just that you wouldn't expect it
yeah i've given up on reflection-free mode, it'll be less painful to use reflection rather than try to port all the DX code I have from Vortice to TerraFX lol
honestly i would rather spend a day tweaking build properties than spending a day rewriting everything in TerraFX
it's just painful, i would rather use C or C++
for these the documentation is the source code
IlcScanReflection
controls the thing that scans for reflection patterns (the thing that determines whether to keep reflection metadata for each member). i don't know what will happen if you set it to falseeh i mean i'm used to reading the runtime docs at this point when i was writing my own bare metal runtime xd
it won't burn your computer so i suppose there is no harm in trying it
(it still would be nicer to have a markdown file listing it just sayiinggggg ⚆_⚆)
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.