2014-02-24 2 views
-1

별도의 프로세스를 실행하고 dll로 winforms 응용 프로그램 인 dll을 사용하고 싶습니다. 이미 몇 살 때문에.Net dll을 실행하십시오.

Is it possible to execute a .NET dll without an exe to load it?

, 내가 질문을 새로 원 : 전에이 질문은 이미 요청했습니다. .Net 프레임 워크에서 사용할 수있는 것이 있습니까? 기술적으로 가능한가? 나는 자바에서 알고, 그래서 닷넷은 ... 너무

감사

추가 정보을 할 수 있는지 궁금 해서요 : 저는 여기에 달성하기 위해 노력하고있어입니다. 바로 지금 우리의 응용 프로그램 내에서 교착 상태를 감지 할 수있는 코드가 있습니다. 탐지는 obviosly 다른 트레드에서 실행됩니다. 그래서 이런 일이 생기면 사용자에게 대화 상자를 보여주고 교착 상태에 대해 알려주고 교착 상태의 응용 프로그램을 종료시키는 다른 프로세스를 실행하려고합니다.

대부분의 경우 메인 스레드가 교착 상태에 빠지기 때문에 사용자에게 대화 상자를 표시 할 수있는 다른 프로세스가 필요합니다. 내가 GUI를 주요 스레드가 차단되기 때문에 뭔가를 보여줄 수있는 방법이 없습니다.

+3

이 답변은 좋지 않다? http://stackoverflow.com/questions/2822326/a-dll-with-winforms-that-can-be-launched-from-a-main-app – Dayan

답변

0

이가 대답했습니다 여러 번 :

Killercam에서 :

// Execute the method from the requested .dll using reflection (System.Reflection). 
    Assembly DLL = Assembly.LoadFrom(strDllPath); 
    Type classType = DLL.GetType(String.Format("{0}.{0}", strNsCn)); 
    object classInst = Activator.CreateInstance(classType, paramObj); 
    Form dllWinForm = (Form)classInst; 
    dllWinForm.ShowDialog(); 

솔루션 탐색기에서

Code4life에서의 참조를 마우스 오른쪽 단추로 클릭하고 참조 추가를 선택합니다. 이것은 사용자 정의 된 C# DLL을 추가하는 지점입니다.

이제 개방 Program.cs 및 메이크업에서 다음과 같이 변경 :

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Windows.Forms; 
using ****your DLL namespace here**** 
namespace WindowsFormsApplication2 
{ 
    static class Program 
    { 
     /// <summary> 
     /// The main entry point for the application. 
     /// </summary> 
     [STAThread] 
     static void Main() 
     { 
      Application.EnableVisualStyles(); 
      Application.SetCompatibleTextRenderingDefault(false); 
      Application.Run(new [****your startup form (from the DLL) here****]); 
     } 
    } 
} 
+0

답장을 보내 주셔서 감사합니다. 나는 그것을 시도했지만 다른 프로세스에서 실행해야하는 양식의 호출을 디버깅 할 때 응용 프로그램과 동일한 ID를가집니다 ('Process.GetCurrentProcess(). Id'). 내 질문도 업데이트되었습니다. – derape

관련 문제