내가 자신의 어셈블리의 손으로 쓴 WCF 프록시를 가지고, 그것은 매우 간단합니다구성 파일과 Powershell 스크립트에서 사용자 지정 WCF 프록시를 사용하는 방법?
public class MyServiceClient : ClientBase<IMyService>, IMyService
{
public MyServiceClient()
{
}
public MyServiceClient(string endpointConfigurationName) :
base(endpointConfigurationName)
{
}
}
내가 PowerShell 스크립트로이로드 오전 : 나는 다음 앱을 설정하려고
Add-Type -Path "$LocalPath\MyService.Client.dll"
Add-Type -Path "$LocalPath\MyService.Contracts.dll"
의 .config 클라이언트가 아니라 스크립트 자체보다, 설정에 정의 된 엔드 포인트 인스턴스화 할 수 있도록 (SO에 other posts 당) :
[System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", "$LocalPath\MyService.Client.dll.config")
I AppDomain을 확인했으며 구성 파일이 ConfigurationFile
속성으로 설정되었습니다.
나는 클라이언트의 인스턴스를 만들 :
Exception calling ".ctor" with "1" argument(s): "Could not find endpoint element with name 'MyServiceHttpEndpoint' and contract 'MyService.Contracts.IMyService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element."
어떤 아이디어 :
$endpointName = "MyServiceHttpEndpoint" # defined in the app.config file
$myclient = New-Object MyService.Client.MyServiceClient($endpointName)
그것은 말 전복을? 스크립트 파일에 수동으로 엔드 포인트를 작성하고 싶지 않습니다. config에서 읽어야합니다.
오류가 발생했습니다 : 구성 파일을보고 "MyServiceHttpEndpoint"라는 끝점을 찾을 수 없습니다. 의미있는 도움이 필요하면 실제 설정 파일을 게시해야합니다. – ErnieL
또한 '응용 프로그램에서 구성 파일을 찾을 수 없기 때문에 발생했을 수 있습니다.'라는 것이 문제입니다. config 파일은 문제가 없으며 Powershell 외부에서 작동합니다. – MalcomTucker
AppDomain을 확인했고 설정 파일이 존재하고'AppDomain.ConfigurationFile' 속성을 찾았습니다. 설정 파일을 클라이언트 프록시에 묶을 수 없습니다. 구성 추가 ... – MalcomTucker