A DLL is just a library of functions that are loaded at runtime. When your project crashes when loading the DLL, but does not crash when the DLL is not there, there are two possibilities. Either it's a crash in a DLL function itself. Or a script functions crashes when it calls a DLL function which returns something that is not expected.
If it happens randomly or only when the project is published, you can't debug your script directly. But you can debug the DLL if it's your own DLL. If it's a DLL of which you don't have the source code, check with diag outputs which of your script functions crash. This should normally give you an idea what's wrong.