상대 경로를 가진 dll을 powershell로 가져 오려고합니다. 다음은 dll을 가져 오려고하는 코드 조각입니다.상대 경로를 사용하여 C 스타일 32 비트 API에 액세스하기위한 powershell의 DLLImport
$dirpath = split-path $MyInvocation.MyCommand.Definition
$testDllPath = "$dirpath\..\Test1\Test.dll"
$signatureGet = @'
[DllImport(@"$testDllPath",EntryPoint="TestMethod",ExactSpelling=false)]
public static extern bool TestMethod([MarshalAs(UnmanagedType.LPWStr)]string args1, [MarshalAs(UnmanagedType.LPWStr)]string args2);
'@
$typeFunc = Add-Type -MemberDefinition $signatureGet -Name "TestMethod" -PassThru
$ret = $typeFunc::TestMethod($args1, $args2)
하드 코딩 된 경로로 동일한 작업을 시도하면 DLL이로드 될 수 있습니다. 상대 경로와 동일하게 작동하지 않습니다. 잘못된 형식으로 인해 오류가 발생합니다.
이 작업을 수행하는 방법을 알려주십시오.
답변과 명확한 설명에 감사드립니다. 그것은 작동합니다 :-) –