I'm always referencing DLL's in my C# code but they have remained somewhat of a mystery which I would like to clarify. This is a sort of brain dump of questions regarding DLL's
I understand a DLL is a dynamically linked library which I understand means that at run time another program can access this library to get "functionality". However,,,
Consider the following ASP.Net project...
Web.dll Business.dll
Web.dll is the front end functionality and it references business.dll for types and methods.
1) At what point does web.dll dynamically link to business.dll? You notice a lot in Windows HDD thrashing for seemingly small tasks when using Word etc and I reckon that this Word going off and dynamically linking in functionality from other DLL's?
1a) Additionally what loads and links the DLL - the O/S or some runtime framework such as the .Net framework?
1b) What is the process of "linking"? Are checks made that there is compatibility? Loading into the same memory? What does linking actually mean?
2) What actually executes the code in the DLL? Does it get executed by the processor or is there another stage of translation or compilation before the processor will understand the code inside the DLL?
2a) In the case of a DLL built from C# .net what is running this? The .Net framework or the operating system directly?
3) Does a DLL from say Linux work on a Windows system (if such a thing exists) or are they operating system specific?
4) Are they specific to a particular framework? Can a DLL built using C# .Net be used by a DLL built with Borland C++ (example only)?
4a) If the answer to 4 is "no" then really what is the point of a DLL? Why dont the various frameworks use their own formats for linked files? E.g. a .exe build in .Net knows that a file type of .abc is something that it can link into its code.
5) Going back to the web.dll / business.dll example. To get a class type of customer I need to reference business.dll from web.dll. This must mean that business.dll contains a specification of some sort of what a customer class actually is. If I had compiled my business.dll file in say Delphi would C# understand it and be able to create a customer class - or is there some sort of header info or something that says "hey sorry you can only use me from another delphi dll".
5a) Same applies for methods.. can I write a CreateInvoice method in a DLL, compile it in C++ and then access and run it from C#? What stops or allows me from doing this.
6) On the subject of DLL hijacking, surely the replacement (bad) DLL must contain the exact method signatures, types as the one that is being hijacked. I suppose this wouldnt be hard to do if you could find out what methods etc were available in the original DLL.
6a) A bit of a repeat question here but this goes back to what in my C# program is deciding if I can access another DLL? If my hijacked DLL contained exactly the same methods and types as the original but it was compiled in another lanugage would it work?
Just a few more things that came to me at the last minute...
- What is DLL importing? and dll registration?
Thats it for now!
Thanks.