문제

C# 실행 파일에서 사용하는 클래스가 포함 된 관리 DLL (C ++/CLI로 작성)이 있습니다. 클래스의 생성자에서는 DLL을 참조하는 실행 파일의 전체 경로에 액세스해야합니다. 실제 앱에서는 응용 프로그램 객체를 사용하여이를 수행 할 수 있지만 관리되는 DLL에서 어떻게 할 수 있습니까?

도움이 되었습니까?

해결책

Assembly.GetCallingAssembly()

또는

Assembly.GetExecutingAssembly()

또는

Assembly.GetEntryAssembly()

당신의 필요에 따라.

그런 다음 위치 또는 코드베이스 속성을 사용하십시오 (나는 어느 것을 기억하지 않습니다).

다른 팁

@leppie: Thanks - that was the pointer I needed.

For future reference, in C++/CLI this is the actual syntax that works:

String^ appPathString = Assembly::GetEntryAssembly()->Location;

GetExecutingAssembly() provided the name of the DLL

GetCallingAssembly() returned something like System.Windows.Forms

GetEntryAssembly returned the full path, similar to GetModulePath() under Win32.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top