❔ need help loading in runtime
I want to be able to load c# projects as “internal libraries” in my language during runtime so that I can have multiple built in internal functions and stuff so then I can build the standard libraries in the Lang and I have no clue if I can load c# projects in runtime like that
10 Replies
in my languageYou're making a language?
indeed
You can compile to IL which would allow you to interop with C# practically flawlessly
alright thanks!
also cute pfp
Thanks you too!
The relevant namespace would be System.Reflection.Metadata which allows you to emit IL code. Note that this is very low-level, but I assume you're prepared for that if you're making a language.
https://learn.microsoft.com/en-us/dotnet/api/system.reflection.metadata?view=net-8.0
System.Reflection.Metadata Namespace
Provides low-level functionality for reading assembly metadata according to ECMA-335. This namespace is designed to be used by compilers and other tools that need to read assembly metadata.
You can output this into a DLL and then load it from C# or vice versa, or even run it using the .NET CLI.
Thank you!
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.