Click here to Skip to main content
15,891,841 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to create a dll, which opens the form from Form1.cs

I tried so much things that I'm so pissed right now, nothing was working.

What I have tried:

google
codeproject
always a stupid "i want to load a dll" thread
Posted
Updated 23-Nov-16 22:09pm
Comments
Mehdi Gholam 24-Nov-16 3:24am    
Show your code.
Richard MacCutchan 24-Nov-16 3:50am    
Don't! That is the wrong way to do it. A DLL is a support library that provides common routines for multiple applications to access. Your Windows.Form should be in your main application.

1 solution

If your form is contained inside the DLL, then that's not complicated to create and display it from your app - just add a reference to the DLL to your application project and edit the Program.cs file:
C#
static class Program
        {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
            {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MyDLL.Form1());
            }
        }

If you are trying to display a form from inside a DLL file then as Richard says, that's the wrong way to do it - a DLL should not be concerned with user interface as it could well be used in an environment where Forms are not used: a website for example.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900