.NET 4.x Внедрение managed dll в стороннее приложение - C#
Формулировка задачи:
Помогите пожалуйста с созданием .dll при инжекте которой в Определённое приложение [определить по имени .exe] ...
ну вот при инжекте этой .dll появилась винформа... которая не будет как бы в отдельном exe а будет записана в .dll
Подскажите как такое осуществить... заранее благодарю...
Решение задачи: «.NET 4.x Внедрение managed dll в стороннее приложение»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace keys
{
public class Class1
{
public void Start()
{
Form1 MyFrm = new Form1();
MyFrm.ShowDialog();
}
public static void Main()
{
Assembly testAssembly = Assembly.LoadFrom("keys.dll");
Type curType = null;
object currentAssembly;
foreach (Type type in testAssembly.GetTypes())
{
if (type.IsClass)
{
currentAssembly = testAssembly.CreateInstance(type.FullName);
curType = type;
}
}
Type ExtAssemblyType = testAssembly.GetType(curType.FullName);
object ExtAssembly = Activator.CreateInstance(ExtAssemblyType);
curType.InvokeMember("Start", BindingFlags.Default | BindingFlags.InvokeMethod, null, ExtAssembly, new object[] { });
}
}
}