I want my class library conditionally compiled so that it is in debugging mode when my project is, and is not when my project isn't.
For example, I have this Module in my class library:
Sub print(ByVal msg As String)
Debug.Print(Now.ToString("yyyy-MM-dd HH:mm:ss.fff") & " " & msg)
Sub debugEnd(Byval bool As Boolean)
'My Project' -> the 'Compile' tab -> 'Advanced Compile Options'
Bin -> Release
If you keep the class library project in the same solution as your main project it will use the same configuration (
Release) as every other project in that solution. This means that you won't have to manually check/uncheck
Define DEBUG constant as it will not be defined anyway if you have set the configuration to
Even if your projects are not in the same folder you may still add your class library project to your solution. Here's how to do it:
Right-click your solution in the
Solution Explorer and goto
Add > Existing Project.
In the file browsing dialog that opens, locate the
.vbproj-file of your class library and click
Now when you change compilation configuration it should be reflected over the entire solution and your class library shall only have its
DEBUG constant defined if you set the configuration to
If you cannot see your solution in the
In Visual Studio, goto
Tools > Options > Projects and Solutions > General.
Always show solution and press
For the above to work you must also change the way you reference your class library. The way you are currently doing it is correct, but it won't work in this case as then you'll only be referencing the
Release version of your dll.
Start by removing your current reference to your class library.
Add Reference dialog and go to the
Select your class library's project and press
This should now reference the class library's output from the solution's current compilation configuration.