Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Quick Reply
Search this Thread
Lab Assistant
Original Poster
#1 Old 11th Sep 2021 at 3:53 AM
A stripped down mscorlib library
Hi all, I was close to it. I need more help.

I decided to explore my new level in modding. I downloaded the Harmony library version 1.2 to change "immutable" methods (for example, to change the CanBeKilled method in the Sim class so that all the Sims in the world never die).
I created the usual mod and built this library, but when you run the game crashed. Then I remembered that I forgot to insert mscorlib into the Harmony library. Unfortunately, when trying to build the modified library, Visual Studio tells me that some classes are not found. I found that mscorlib weighs much less than the original one (~800KB vs. 4.5MB). EA cut this library down.

What should I do in this situation? Is it even possible to do this?
Advertisement
Space Pony
#2 Old 11th Sep 2021 at 7:02 AM
Quote: Originally posted by Onebeld
Hi all, I was close to it. I need more help.

I decided to explore my new level in modding. I downloaded the Harmony library version 1.2 to change "immutable" methods (for example, to change the CanBeKilled method in the Sim class so that all the Sims in the world never die).
I created the usual mod and built this library, but when you run the game crashed. Then I remembered that I forgot to insert mscorlib into the Harmony library. Unfortunately, when trying to build the modified library, Visual Studio tells me that some classes are not found. I found that mscorlib weighs much less than the original one (~800KB vs. 4.5MB). EA cut this library down.

What should I do in this situation? Is it even possible to do this?


I don't know if it's impossible, but unfortunately it seems very unlikely that this would work. Looking at the source, it looks like the Harmony DLL relies heavily on the System.Linq and System.Reflection.Emit namespaces, both of which are completely absent from the game's scripting core. LINQ is all syntax sugar, so it's pretty easy to create a shim for it using LINQBridge, but there seem to be some CLR methods (e.g. "create_dynamic_method", which is called by "CreateDynMethod") in Reflection.Emit that may or may not be present in the game's MONO runtime. You could try porting over a C# implementation of Reflection.Emit, but if those external methods aren't in the runtime, then I don't know where you'd go from there. Perhaps @Battery might have some thoughts on that.

"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had." - Eric Schmidt

If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Lab Assistant
Original Poster
#3 Old 11th Sep 2021 at 11:39 AM Last edited by Onebeld : 11th Sep 2021 at 12:11 PM.
Quote: Originally posted by gamefreak130
I don't know if it's impossible, but unfortunately it seems very unlikely that this would work. Looking at the source, it looks like the Harmony DLL relies heavily on the System.Linq and System.Reflection.Emit namespaces, both of which are completely absent from the game's scripting core. LINQ is all syntax sugar, so it's pretty easy to create a shim for it using LINQBridge, but there seem to be some CLR methods (e.g. "create_dynamic_method", which is called by "CreateDynMethod") in Reflection.Emit that may or may not be present in the game's MONO runtime. You could try porting over a C# implementation of Reflection.Emit, but if those external methods aren't in the runtime, then I don't know where you'd go from there. Perhaps @Battery might have some thoughts on that.


Okay, I'll try to do that. Is it possible to build the mscorlib library into the mod itself, instead of the one from EA? (The original one, in which Reflection.Emit is supported there)

UPD: Just checked, it doesn't work
Back to top