Open siddhsql opened 1 month ago
The error you're encountering suggests that you're trying to open a file that was built as a Static Library (typically with the .lib extension) instead of a Dynamic Link Library (DLL, with the .dll extension), and tools like depends.exe or Dependency Walker are expecting a valid Portable Executable (PE) file in the form of a DLL or EXE.
Reason for the Error: A Static Library is not a PE file, and it doesn't contain the necessary headers and structures that PE-COFF (Portable Executable - Common Object File Format) files like DLLs or EXEs have. When using the StaticLibrary configuration in MSBuild, you're generating a .lib file (static library), not a .dll. This is why Dependency Walker and similar tools are unable to open it, as they expect PE-COFF files.
Change the Project Configuration:
Ensure that you're building the project as a Dynamic Link Library (DLL) and not as a Static Library. To do this: Open your project in Visual Studio. Right-click on the project in Solution Explorer and select Properties. Under the Configuration Properties > General, look for the Configuration Type setting. Change the Configuration Type from Static Library (.lib) to Dynamic Library (.dll). Rebuild the project. Check Output Files:
After rebuilding the project, ensure that the output is a .dll file. You should now be able to open the .dll file in Dependency Walker without the PE-COFF error. Verify MSBuild Configuration:
If you're using MSBuild directly (without Visual Studio), ensure your .csproj or .vcxproj is set to create a DLL. You can verify this in the project file:
I build a DLL using
msbuild
and StaticLibrary configuration type. However when I try to open it in dependencies I get this error:Invalid PE
xxx.dll is not a valid PE-COFF file
OK
How can I fix this? The old depends.exe also gives an error.