Visual Studio adding executable file with same name as dll

后端 未结 1 994
生来不讨喜
生来不讨喜 2021-01-12 05:27

In Visual Studio 2008, I added WinScp.dll (in project root) as a reference and immediately there was a yellow icon. At compile-time:

  • The type or namespace name
相关标签:
1条回答
  • 2021-01-12 05:55

    WinSCP.dll and WinSCP.exe are two different files

    Not to the assembly loader, it doesn't pay attention to a filename extension. All it knows is that it needs to find an assembly with a display name of "winscp". When searching for a match, it first tries an EXE file with that name, next a DLL file. Something you can see with the Fuslogvw.exe utility. Display names are described in this blog post by the Microsoft guy that worked on the Fusion component:

    The "name" part is usually the file name of the assembly, excluding the extension. So for assembly foo.dll, the "name" part is "foo". Of course, since I said "usually", there are times when the "name" part is not the same as the file name excluding extension. I will discuss this in a bit.

    Emphasis added. So it finds WinSCP.exe first and that's a kaboom, it is not a valid .NET assembly. The simple workaround is rename the DLL, that changes the display name of the assembly.

    0 讨论(0)
提交回复
热议问题