locked
API for DLL files RRS feed

  • Question

  • Hi,

    I need API for the following:

    1. As I understand it, a DLL file is basically a collection of code-generated files. I need an API to check if a DLL file has a specific file.

    2. I need an API to remove a file from a DLL file.

    3. I need to compile a source file and add the generated code file to a DLL file. I already know the basics of compiling in memory.

    Thank you

    Monday, April 29, 2013 4:58 PM

Answers

  • I wouldn't bother and would just compile csharp user defined code into its own DLL rather than to try to mix that with other unrelated application code.

    If the user has that much code, you could group those files in logical units and create multiple DLLs so that you just have to recompile the needed one(s). If you really want to look at modules try perhaps around http://msdn.microsoft.com/en-us/library/58scf68s.aspx . This way you could perhaps combine all user code into a single DLL (never tried).

    IMO DON'T try to combine with this with your own code. It will add complications (you would need to ship the module files for your own code etc...) for no obvious benefit and it could even cause issues (if you update your own code and want to ship updated code but now on the target machine you have the DLL to be replaced that includes also some user code etc..., it will be more difficult to handle)

    In short implement first the simplest solution that works. You'll always be able to enhance later if you really identify some strong reason for that...


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    • Marked as answer by FromJava Wednesday, May 1, 2013 7:13 AM
    Tuesday, April 30, 2013 11:05 AM

All replies

  • Hi,

    Try to explain your goal...

    A DLL doesn't "have a file" (?). This is a single file that contains code and data (it can use other files if this is what you meant ?). Or are you talking about "resources" (that is string, bitmap and other content) that can be embeded inside a DLL ?

    You usually don't add or remove content from a DLL. This is not how it is supposed to work. If you want to create your own DLL use a compiler and pack inside your DLL whatever you need. In some cases you can also place DLLs at a particular location so that they can be used by another app. Altering other DLLs even if you ever find how to do that is likely not something that is a good idea.

    For now I would suggest to explain what you are trying to do rather than how you think it should be done. It could help to raise better suggestions...


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".


    Monday, April 29, 2013 5:17 PM
  • Ok, I have a collection of .cs files. Using compiler API, I compile those .cs files and generate a DLL that groups the generated code(s). At a certain point of time (during the application runtime), I might have a .cs file that has no corresponding code in this DLL. If this is the case, I compile the missing .cs file and update the previously generated DLL.
    Monday, April 29, 2013 5:51 PM
  • Still unclear.

    I'm not sure if you try to build some kind of auto-updater inside your app (it usually works with binaries not with source code files) on an end-user machine or if you try to do what VS does on your own dev machine (rebuilding outdated DLLs from source code is what VS does).

    This is this kind of high level description I was looking for. Even from your last post I'm not sure to understand if you try to just do what VS does or if you really plan to do some kind of auto-updating app that would work from the source code ???!!!

    Or are you just building your own dev environment ? AFAIK this is not the generated DLLs that is updated. The compilation process gives several "modules" that are cached, the module that is changed by updating the source code is the only one which is updated  and then they are all combined to create a new DLL file (that is the basically the same one that the previous one but with the updated part). I don't think that any compiler just updates the DLL file (as once this is a DLL it's unlikely you really know from where each part came).

    So for now my understanding is that either you are trying to auto-update your app on an end-user machine or that you are creating your own development toolchain. Form your description, it seems basically to be what VS does already...

    Or if your app let your user to somewhat dynamically incorporate code inside your app, I wuld just compile the whole end user code as a DLL rather than trying to update one of mine with some code...


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    Monday, April 29, 2013 6:17 PM
  • Thanks for your patience.

    My goal is your last paragraph. However, compiling the whole end user code everytime the user changes one .cs file is just not practical.

    How about compiling .cs files as modules (not as a DLL), like generating java's .class files from .java files. Of course, there must be a way to eventually build a DLL out of all the modules, like building a java's jar file from a group of .class files. Will that work ?

    Monday, April 29, 2013 6:44 PM
  • I wouldn't bother and would just compile csharp user defined code into its own DLL rather than to try to mix that with other unrelated application code.

    If the user has that much code, you could group those files in logical units and create multiple DLLs so that you just have to recompile the needed one(s). If you really want to look at modules try perhaps around http://msdn.microsoft.com/en-us/library/58scf68s.aspx . This way you could perhaps combine all user code into a single DLL (never tried).

    IMO DON'T try to combine with this with your own code. It will add complications (you would need to ship the module files for your own code etc...) for no obvious benefit and it could even cause issues (if you update your own code and want to ship updated code but now on the target machine you have the DLL to be replaced that includes also some user code etc..., it will be more difficult to handle)

    In short implement first the simplest solution that works. You'll always be able to enhance later if you really identify some strong reason for that...


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    • Marked as answer by FromJava Wednesday, May 1, 2013 7:13 AM
    Tuesday, April 30, 2013 11:05 AM