C
C#5mo ago
Ruttie

Custom System libraries

I am on .NET Framework 4.7.1 and have some custom System.* libraries and a custom mscorlib. I'd like to use these dlls instead of the 'standard' system libraries that come with .NET. Is there any way to do this?
16 Replies
Angius
Angius5mo ago
I have no idea how to do it, I only have a question: why?
Ruttie
RuttieOP5mo ago
Because I have to use custom System.* libraries and a custom mscorlib?
Angius
Angius5mo ago
That was what my question was about, yes. What's the point of that?
Ruttie
RuttieOP5mo ago
Some types/methods/fields might have been changed, and I'd rather know at compile time than have a typeloadexception or smth at runtime
Angius
Angius5mo ago
Yeah, sorry, I still have no clue why you'd want to use a custom System.Encoding or whatever over the built-in one The only thing that comes to mind that would make this atrocity possible would be some IL weaving via Fody or something I'd maybe ask in #roslyn
Lex Li
Lex Li5mo ago
It depends on heavily what kind of experience you want to achieve. If merely for experiments with compilers, you can follow the classic approach of creating a reference assembly profile, https://erictummers.com/2012/01/25/target-mono-from-visual-studio/ But if you want your own ".NET Framework distribution" with those custom BCL assemblies, that's much more complicated.
jcotton42
jcotton425mo ago
… but why do you need/want custom ones?
Angius
Angius5mo ago
Maybe you will get an answer to that question, fingers crossed lmao
Ruttie
RuttieOP5mo ago
I'm just given the libraries, I have to work with them do I want custom ones? rather not, but I have to it's a unity game I want to mod, it has its own System.* libraries and mscorlib, and I'd like to work with those instead of gambling with the idea that it matches some version perfectly the engine can compile code with the custom System.* and mscorlib binaries, so I assumed it would be possible for me to do so as well I'm not the one distributing the libraries, so what you linked could work, but I'm on vscode and linux while your guide targets vs and mentions registry editing
jcotton42
jcotton425mo ago
Aren't you supposed to use tools like Bepin for Unity modding? Do they handle this?
Ruttie
RuttieOP5mo ago
'supposed to' maybe, but it's not mandatory to use them I prefer to just use monomod as far as if they handle that, don't think so
jcotton42
jcotton425mo ago
given this is unity stuff, might be best to ask in #game-dev or $unity
jcotton42
jcotton425mo ago
i've never heard of system replacing the bcl libs before
MarkPflug
MarkPflug5mo ago
I've never done it, but there is a compiler switch to the CSharp compiler (csc.exe) that instructs it not to reference mscorlib.dll: <NoStandardLib>/-nostdlib https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/advanced Presumably, you'd need to pass that and then reference the third-party version manually.
Compiler Options - advanced scenarios - C# reference
Advanced C# Compiler Options. These options are used in advanced scenarios.
Lex Li
Lex Li5mo ago
Unity still uses Mono (unless they complete migration to .NET one day), so what I mentioned is one of the best options for you to get started. You might be able to get something similar with VS Code on Linux, but I am not aware of that. Details of the C# extension/Dev Kit were not very well documented.

Did you find this page helpful?