I had a similar problem wherein, the release mode was still picking up debug mode settings though I configured debug mode settings in the debug preprocessor directive. Turns out the problem was with how the reference dll of the class library project was added to my project. There are 2 ways to add a reference to your project.
Option1: Add .dll from debug/release folder of the project to the
project that is dependent on it.
Problem: This introduces a problem, where in if you have added reference to the
debug version of the dll, even if you run the application in release
mode, its still going to refer to the debug version.
Fix: You will have to replace the .dll corresponding to what mode you want to run
in. Eg: If you are going to want to run in release mode, you will have
to replace the dependency dll with its corresponding release version.
Option2: Add the project reference (.csproj) file of the project you want to refer.
Advantage: This ensures when the whole solution is
built in release mode, it correctly resolves all dependencies to be in
release mode and when you build the solution in debug, it gets all
dependency projects in debug mode. This doesn't need your
intervention.
Where is option1 useful? -> When the projects your project wants to
reference don't exist in the same solution as yours.. Think of
scenarios where you want to use 3rd party dlls.. In this case you
either don't have the 3rd party code but got only the dlls or it lies
in a different solution.
When is option2 useful? -> When both
referencing project and referenced project exist in the same solution
(this is my scenario). If you remember, all my projects exist in the
same solution.
Link that explains how to add project references in 2 ways:
https://www.c-sharpcorner.com/article/project-reference-vs-dll-reference-in-visual-studio/