Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
i want to build dll file that deals with system.windows.forms.form how can i override any form method from dll class such as (WndProc)?

C#
public partial class MyDll
{
    public MyDll(System.Windows.Forms.Form form)
    {
        // i want to override WinProc form from my dll file.
    }
}
Posted
Updated 20-Mar-14 9:53am
v3

1 solution

In exact same way as it was in EXE file. There is no difference.

In .NET, the difference between "EXE" or "DLL" is almist insignificant. Everything are assemblies; and "EXE" or "DLL" files are modules (usually, main modules) of the assemblies. EXE has an entry point (Main) to be executed as an application. EXE can be used exactly as class library (referenced); and one can build some alernative hosting system where DLLs could play the roles of executable.

Let's say, you have application ("EXE"), and it uses some library ("DLL"). The best way to do it is having them in the same solution, and reference by the tab "Projects" of the "Add Reference" window (if this is Visual Studio; other environments will have similar features). Then you can simply forget about boundary between these two assemblies; write everything as it would be monolithic assembly. The only requirment is the public or protected access modifiers, to have types and members accessible in a different assembly.

However, if you want dynamically, during runtime, change some implementation by changing implementind DLL, this would much more difficult problem solved using reflection. If you are interested, we can discuss it, but it will require more serious knowledge and deeper understanding of the fundamentals.

—SA
 
Share this answer
 
Comments
Rabee Rabee 21-Mar-14 11:09am    
thank you so much
just i want to know if i can override any form method from a dll file, my project is a "ClassLibrary" not a "WindowsFormsApplication"

public partial class MyDll
{
public MyDll(System.Windows.Forms.Form form)
{
// i want to override WinProc form from my dll file.
}
}
Sergey Alexandrovich Kryukov 21-Mar-14 12:27pm    
You are not explaining what else do you want to know. Do you understand what does it mean, override a method? You are writing something unrelated, in a constructor...
—SA

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