Environment: C #, .NET 4.0 and mixed mode.
I have a complex application with several third-party dependencies. When we received some reports of the application crashing, we added some sanity checks to ensure that all dependencies exist by crossing the assembly dependencies. Unfortunately, this does not check for the existence of native DLL files that our application uses. Our intentional solution is to iterate over all the DLL names and make sure that there is at least a file with that name as a health check.
Problem
Both Directory.EnumerateFiles () and File.Exists () also cannot see these native DLLs. The code for reproducing this problem is as simple as the How to List Files tutorial:
foreach(string file in Directory.EnumerateFiles(Environment.CurrentDirectory, "*.dll")) { string entry = Path.GetFileName(file); if (! RequiredFiles.Contains(entry)) { } }
Being in the directory in which I listed the files, I could see the files that I wanted to detect. They are not marked as system files. However, whether I had filter text or not, only .NET DLL files were listed. I thought to rewrite the code section more directly and disappointingly received the same results:
foreach(string dependency in RequiredFiles) { string fileName = Environment.CurrentDirectory + '\\' + dependency; if(! File.Exists(fileName)) { } }
I got the exact results. All native DLL files seemed invisible to .NET.
Question
What causes this? And more importantly, how can I detect my own DLL files if I don't even see them in the file system?
source share