小编Med*_*edo的帖子

powershell 2.0尝试捕获如何访问异常

这是try catchPowerShell 2.0中的内容

$urls = "http://www.google.com", "http://none.greenjump.nl", "http://www.nu.nl"
$wc = New-Object System.Net.WebClient 

foreach($url in $urls)
{
    try
    {
        $url
        $result=$wc.DownloadString($url)
    }
    catch [System.Net.WebException]
    {
        [void]$fails.Add("url webfailed $url")
    }  
}
Run Code Online (Sandbox Code Playgroud)

但我想要做的就是在c#中

catch( WebException ex)
{
    Log(ex.ToString());
}
Run Code Online (Sandbox Code Playgroud)

这可能吗?

powershell try-catch

127
推荐指数
1
解决办法
10万
查看次数

wcf服务无法激活

它是一个带有ssl和成员资格的.svc IIS托管服务.

我的wcf客户报告:

System.ServiceModel.ServiceActivationException was unhandled
  Message="The requested service, 'https://www.greenjump.nl/WebServices/OrderService.svc' could not be activated. See the server's diagnostic trace logs for more information."
  Source="mscorlib"
Run Code Online (Sandbox Code Playgroud)

在我得到的服务器上:System.ArgumentException此集合已包含方案http的地址.此集合中每个方案最多只能有一个地址.参数名称:item

奇怪的是,这只发生在生产服务器上,localhost开发服务器上的相同代码和配置工作正常.我只更改端点地址,并从计算机名称更改为www.webdomain.com

更多服务器跟踪

<ExceptionType>
  System.ArgumentException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
</ExceptionType>
<Message>
  This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection.
  Parameter name: item
</Message>
<StackTrace>
  at System.ServiceModel.UriSchemeKeyedCollection.InsertItem(Int32 index, Uri item)
  at System.Collections.Generic.SynchronizedCollection`1.Add(T item)
  at System.ServiceModel.UriSchemeKeyedCollection..ctor(Uri[] addresses)
  at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
  at SharpShop.Web.StructureMap.StructureMapServiceHost..ctor(Type serviceType, …
Run Code Online (Sandbox Code Playgroud)

wcf iis-7

10
推荐指数
2
解决办法
7万
查看次数

标签 统计

iis-7 ×1

powershell ×1

try-catch ×1

wcf ×1