Search code examples
c#dlllibraries

Is it safe to include server logic in a library that's also used in client programs?


I recently started some coding again, this time in C#. Currently I'm writing a program where I have a dedicated server and client. However, currently I've been writing all the code in a class library. I'm using Visual Studio.

I have a namespace MyProgram (changed this one), inside that I have namespace Network, which contains a few classes, and in this namespace I have namespaces Server and Client, and I plan to make the server and client programs simply use the library.

Is this safe, or should I simply move the server code into the server program itself, away from the class library? I plan to have the library included in the client programs because the lib has all the functionality. (And I plan to have several different programs using the same lib with some differences, e.g. environment etc.)

Edit: My concern is that how easy is it to "crack" DLL (or EXE for that matter) to find the underlying code (and possibly some secrets).


Solution

  • Decompiling .NET code is easy as drinking a glass of water. You can try by yourself with tools like dotPeek or Reflector.

    You can obfuscate the code but il always be readeable so don't put secrets in client side assemblies.

    If you must do this ensure to do some encryption. You could use a tool like Intellilock to create a license file related to the hardware for managing secrets. Anyway you will never reach 100% of security.