10

I noticed that I can add a reference not only to a DLL but also to an EXE in Visual Studio and access all classes in the EXE as it if were a DLL.

Is there any reason to create a DLL or can I just as well reference the EXE?

I am asking because I often write .net programs that I run both under Windows and under Mac OS and my usual solution is to create a DLL with the functionality and then two GUIs, one for each target.

However, it now seems to me as if I could just write a Windows version of my app and then add that Windows version (the EXE file) to my Mac project and reference the Windows EXE rather than a DLL. It also has the added advantage that I can run the Windows version from the Mac folder without adding another file.

Is there any good reason not to do it that way?

starblue
  • 55,348
  • 14
  • 97
  • 151
Andrew J. Brehm
  • 4,448
  • 8
  • 45
  • 70

3 Answers3

2

It depends on how much maintenance/update you would end up doing to the applications. I like the cleanliness of the original model, where the UI is separated based on platform, and the DLLs contain the classes that are shared. I would find it less confusing for maintenance/refactoring.

Jennifer S
  • 1,419
  • 1
  • 24
  • 43
  • Perhaps. But even within the one project GUI and business logic are still in separate classes and files. And it does have the advantage that the plain .net version (that uses Windows Forms) is a single EXE file with no required support files. The Mac version needs lots of support files but comes in a bundle.app. – Andrew J. Brehm Aug 24 '11 at 15:03
1

If you wish, you can build your all your assemblies as executables (.exe) and references them. There is no diffrence for .NET if a assembly is compiled as executable (.exe) or class library (.dll).

The only diffrence is that an executable has an additional Portable Executable (PE) format and header, so that they can be executed on windows systems. Primarily is this header used to launch the CLR Runtime.

Note: You can also build .dll assemblies as Portable Class Libraries

Jehof
  • 34,674
  • 10
  • 123
  • 155
  • So in my case where it is an advantage to reference an EXE file rather than a DLL (namely that a fully functioning Windows program travels with the Mac version) there is no real downside to doing so except the usual downsides of not having split the EXE into a DLL and an EXE? – Andrew J. Brehm Aug 26 '11 at 12:01
0

I see at least two reasons why one should still split/

  • Versioning - it is good to have independent version numbers for the dlls and exse - it is especially good to change the version number when the interface changes
  • Single responsibiliy and testing
weismat
  • 7,195
  • 3
  • 43
  • 58
  • Those are arguments for splitting up an application into separate EXE and DLL files, not necessarily reasons not to reference an EXE file. I need to know whether there are reasons not to reference an EXE file, obviously besides general reasons to split an application into GUI and business logic files. – Andrew J. Brehm Aug 26 '11 at 12:00