How Is .NET Used in S&Box

I suppose this is more of a question for the S&Box developers than anything because I am not sure that others would know. I was wondering what method S&Box uses to run C# in Source 2. The reason I was wondering is because I have been making a game for a while and as the modding/scripting language I am using C# via hosting the .NET 5 runtime with these APIs. I did this a while back in .NET Core and recently migrated to .NET 5. I suppose I am wondering if S&Box does this to see if I am going in the right direction or not with the game I am currently making (at least in terms of adding C# as a “scripting” language). If this is the case and the hosting API is used I may have some other questions because of some weird issues I have encountered and am curious if they were encountered when making S&Box.


Apparently, the C# source code files are compiled ingame with the Roslyn compiler. With this, only whitelisted namespaces can be used.
Then, the compiled IL stuff (which is still in memory I suppose) is executed on a .NET runtime, which is slapped on Source 2.
That’s just my assumption


After the prototyping potential even gmod had man i am excited to mess around with this, ESPECIALLY as someone who is absolutely obsessed with C#. This brings up a good question though, what version of .net is the scripting run time in S&Box using? If i had to guess i’d say .net core

.NET 5



The question I had is more or less how they are doing the interp between C# to C++. The C++ hosting APIs I mentioned above are for running (hosting) the .NET runtime in a C++ application. In my case if you go to the link I use the nethost method. I was more wondering how they are doing this in S&Box, are they using the nethost method or something else for example. Curious because there isn’t a lot of people who have C# as a “scripting” language like this and I am wondering what they are doing compared to me. In my case I have been making an infinite grid voxel engine and I just started recently adding a modding api to the game to make my life easier when I want to add things to it.

1 Like

It’s actually using .NET 6

1 Like

How do you know this is using .NET 6?