Ben kendi mecliste bir elle yazılmış WCF vekil var, çok basit:Bir yapılandırma dosyasıyla birlikte bir Powershell komut dosyasında özel bir WCF proxy'si nasıl kullanılır?
public class MyServiceClient : ClientBase<IMyService>, IMyService
{
public MyServiceClient()
{
}
public MyServiceClient(string endpointConfigurationName) :
base(endpointConfigurationName)
{
}
}
Ben bir PowerShell komut dosyası içine bu yükleme ediyorum: Sonra App ayarlamak çalışıyorum
Add-Type -Path "$LocalPath\MyService.Client.dll"
Add-Type -Path "$LocalPath\MyService.Contracts.dll"
.Config müşteri yerine komut kendisi daha yapılandırma tanımlanmış bir bitiş örneklenebilmektedir böylece (böylece other posts uyarınca):
[System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", "$LocalPath\MyService.Client.dll.config")
I AppDomain'i kontrol ettiniz ve config dosyası ConfigurationFile
özelliği olarak ayarlandı.
Bir müvekkilin bir örneğini oluşturun:
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."
Herhangi bir fikir:
$endpointName = "MyServiceHttpEndpoint" # defined in the app.config file
$myclient = New-Object MyService.Client.MyServiceClient($endpointName)
Bu şunu demek yere düşer? Komut dosyasında son noktayı el ile oluşturmak istemiyorum - yapılandırmadan okunması gerekiyor.
Hata diyor: yapılandırma dosyasına baktı ve "MyServiceHttpEndpoint" adlı bir son nokta bulamadı. Anlamlı yardım istiyorsanız, gerçek konfigürasyon dosyasını göndermeniz gerekecek. – ErnieL
Ayrıca 'Uygulamanız için bir yapılandırma dosyası bulunamadı' - bu da sorun diyor. Yapılandırma dosyası gayet iyi, Powershell'in dışında sorunsuz çalışıyor. – MalcomTucker
AppDomain'i kontrol ettim ve config dosyası var ve AppDomain'de doğru.ConfigurationFile' özelliği, bu yüzden, sadece config dosyasını tüketen istemci proxy'sine bağlayamıyorum. Yapılandırma eklendi ... – MalcomTucker