Click here to Skip to main content
15,888,263 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In an interview i had a question how do u add a function into another dll or another 3rd party dll.

What I have tried:

is it possible to achieve by using extension method. if so how???
please give me some examples too...
Posted
Updated 27-Mar-16 22:44pm

It's certainly possible with some weird hacks but since this is a programmer's forum and not a hacker's forum, the general answer is: No, it's not possible unless you have the full source of the DLL and can recompile it. And extension methods don't add methods into a DLL.
 
Share this answer
 
Comments
rahulshek 28-Mar-16 5:21am    
if extension methods don't add methods into a DLL atleast is it possible to create a function and access it by using the class name???
Sascha Lefèvre 28-Mar-16 5:54am    
Sort of - extension methods are called on class instances (variables):
https://msdn.microsoft.com/en-us/library/bb383977.aspx
Yes you can add method to dll by using extensioon method by the following way:-
public class Demo
{
public static void MyExtension(this DllClass obj)
{
//Add your code.
}
}
for More details about Extension method visit:-
Extension Methods (C# Programming Guide)[^]
 
Share this answer
 
Comments
rahulshek 28-Mar-16 5:22am    
hi i tried myself this for eg. in log4net i tried it but nothing seems to work
Member 11884108 28-Mar-16 9:21am    
can you send me your code, so that i can check.

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