application.exe to big

Hi all,

I'am just a beginner in .net and I build an application.
After adding several forms to the project, to .exe starts to grow

Question 1:
What is the best solution to split up the program (dll's  ) or are there other possiblities to do that.

Question 2:
I'am looking for an article how explains how to create and handle a dll

Thanks
AXH


Answer this question

application.exe to big

  • s_ursan

    First of all, splitting an application into several dll's won't make it smaller. The code would still be there, only in a different file. For the application to run, you will need all dll's, so you haven't won anything...

    A better way would be to look for often repeated code in your application, then try and write some generic code to replace it. You will end up with re-usable code, that can be put in a dll. In later projects, you can use the code from that dll again.

    Creating a dll is quite simple. Just add a new project to your solution and select the class library type. Then add a reference to it to your main app.

  • iPlexor

    Hi, I'll try to give a broad answer to your question, and you can drill down where you want more information.

    Creating new DLLs and using them is very easy in VS.NET. Here are the high level steps:

    1) Create the DLL project: Add a new project to your solution, making the project type "Class Library". That project will now build a DLL, instead of an EXE. Now you need to get your main EXE project to know about this DLL.

    2) Create a reference to the new DLL: In the solution explorer, right click on the project for your main EXE, and select "Add Reference". A dialog will show up, with 3 tabs at the top. Select the third tab named "Projects". This means you want to create a reference to an existing project on your local machine.

    Now select the name of the new class library project you created, and click "Select", then click Ok to dismiss the dialog.

    At this point, you can refer to classes in your DLL from within your main EXE as if they were local. There is a note here, though:

    If you use the same namespace in the DLL as in the EXE, then the class access will be transparent. However, if the names are different then you will need to add a "using" directive in your EXE to use the namespace for your DLL.

    3) Now, you can write classes in the DLL project, and they will be usable from your main EXE. However, they will compile into a separate DLL.


    Note: The new project you added will create a directory beside you main solution directory, and its DLL will be output under that. I prefer to keep all my output in the one directory, so when I create my new project in step (1), I do two things:

    i) Create the project under the existing directory for the main EXE.
    ii) Modify the project properties to set the output directory to the same one as for the main EXE.

    Hope this helps!

  • application.exe to big