.dll creation in solution

Posted on 2008-11-14
Last Modified: 2013-12-17
I have a solution with 2 projects in it; I'm using VS 2008 C#.  Is it possible to have one of the projects in the solution created as a .dll while the other (main project) is an .exe file with the previously mentioned .dll included?

If so, please give me the steps, or point to some docs.

Question by:rmmarsh
    LVL 22

    Accepted Solution

    If the projects are already created (specifically the one you want as a dll) it may be tricky.
    If you were starting from scratch:

    Create new project (Windows Forms Application)

    Right click on the solution in the solution explorer, and Add -> New Project (of type "Class Library") which will create the dll app

    Right click the PROJECT you created in step one, and go to Add Reference
    Click the "Projects" tab, and the dll proj you created in step 2 should appear.

    Select that one, and the dll will automatically be added.  All builds / debug / release versions will be in sync with each other as you build the solution.

    Author Comment

    OK... got that far on my own... now the question is:  is it possible for the .dll to reference objects in the .exe file?  If so, how?  (I've tried all kinds of stuff, like passing the mainForm to the .dll, but it doesn't find the objects.)
    LVL 22

    Assisted Solution

    So you want to reference functions / objects in the dll from the exe, AND reference functions / objects from the exe in the dll?

    With 2 projects you can't do that, as it would create a circular dependancy, but one way around would be to create a 3rd dll project, which contained Interfaces to the objects or functions you want to call.

    In both other projects, you can inherit the 3rd dll, and have the shared objects implement those interfaces.
    LVL 22

    Expert Comment

    Just re-reading that response, I realize I did a really horrible job explaining that.
    Let me know if it wasn't clear.

    Author Comment

    What I'm trying to do is break up this hugh (700 M) program into parts (one .exe and several .dlls) where the dlls are infrequently used.  Unfortunately, I need to have the .dll <--> .exe references, because that's the way it was originally written.  Was there a better way to write it?  (the .dll needs to reference some objects in the .exe like the database connection, but I can re-write that).  I guess the major question is:  can and how can the .dll reference objects in the main form?  or if they are re-written, what do I have to look out for (ie. do they have to "stand-alone"?


    Author Closing Comment

    Thank you... sorry for the delay in awarding points.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
    This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now