6

MSDNのWCFページの初心者向けのデモビデオをフォローしようとしています。

最初のビデオは多かれ少なかれうまくいきました。私は今、2番目のビデオの終わりに近づいています。私はVS2010/.NET 4.0を使用していますが、ビデオはVS2008を使用しているようです(.NET 3.5を想定していますが、思い出せません)。

次のデモを使用しています

プレーンhttp、net.tcp、net.pipeの3つのエンドポイントを追加しました。プロジェクトを実行しようとすると、Webサービスが開始されません。

System.InvalidOperationException: Cannot load the X.509 certificate identity specified in the configuration.
   at System.ServiceModel.Description.ConfigLoader.LoadIdentity(IdentityElement element)
   at System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress)
   at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection)
   at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, String configurationName)
   at System.ServiceModel.ServiceHostBase.ApplyConfiguration()
   at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)
   at System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses)
   at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
   at Microsoft.Tools.SvcHost.ServiceHostHelper.CreateServiceHost(Type type, ServiceKind kind)
   at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)

私のGooglefuに基づいて、私はこのスレッドに出くわしました:「構成で指定されたX.509証明書IDをロードできません」

私はまだ基​​本を試しているだけなので、まだ証明書に関与したくありませんでした。そのため、その投稿のアドバイスに従い、<dns value="localhost" />タグを追加しました。例外の変更:

Please try changing the HTTP port to 8732 or running as Administrator.
System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL http://+:8080/EvalService/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details). ---> System.Net.HttpListenerException: Access is denied
   at System.Net.HttpListener.AddAllPrefixes()
   at System.Net.HttpListener.Start()
   at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
   --- End of inner exception stack trace ---
   at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
   at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
   at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
   at System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.HttpChannelListener.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.DatagramChannelDemuxer`2.OnOuterListenerOpen(ChannelDemuxerFilter filter, IChannelListener listener, TimeSpan timeout)
   at System.ServiceModel.Channels.SingletonChannelListener`3.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Security.NegotiationTokenAuthenticator`1.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Security.CommunicationObjectSecurityTokenAuthenticator.Open(TimeSpan timeout)
   at System.ServiceModel.Security.SecurityUtils.OpenCommunicationObject(ICommunicationObject obj, TimeSpan timeout)
   at System.ServiceModel.Security.SecurityUtils.OpenTokenAuthenticatorIfRequired(SecurityTokenAuthenticator tokenAuthenticator, TimeSpan timeout)
   at System.ServiceModel.Security.SecurityProtocolFactory.Open(String propertyName, Boolean requiredForForwardDirection, SecurityTokenAuthenticator authenticator, TimeSpan timeout)
   at System.ServiceModel.Security.SymmetricSecurityProtocolFactory.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Security.SecurityProtocolFactory.Open(Boolean actAsInitiator, TimeSpan timeout)
   at System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.SecurityChannelListener`1.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Security.SecuritySessionSecurityTokenAuthenticator.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Security.CommunicationObjectSecurityTokenAuthenticator.Open(TimeSpan timeout)
   at System.ServiceModel.Security.SecurityUtils.OpenCommunicationObject(ICommunicationObject obj, TimeSpan timeout)
   at System.ServiceModel.Security.SecurityUtils.OpenTokenAuthenticatorIfRequired(SecurityTokenAuthenticator tokenAuthenticator, TimeSpan timeout)
   at System.ServiceModel.Security.SecuritySessionServerSettings.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Security.SecuritySessionServerSettings.Open(TimeSpan timeout)
   at System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.SecurityChannelListener`1.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open()
   at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)
System.Net.HttpListenerException (0x80004005): Access is denied
   at System.Net.HttpListener.AddAllPrefixes()
   at System.Net.HttpListener.Start()
   at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()

それで、私はそれが言ったことをやってみました:ポートを8732に変更しましたが、今度は例外がスローされますPlease try changing the HTTP port to 8732...HTTP could not register URL http://+:8732/EvalService/...。:P

新しいエンドポイントをコメントアウトしてみましたが、役に立ちませんでした。元のものでさえ、このエラーで失敗します。それらを元のポートに戻してもかまいません[そうではありません]1337。

これがApp.configであり、問​​題のあるものは何もありません。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="EvalServiceLibrary.EvalService">
        <clear />
        <endpoint address="ws" binding="wsHttpBinding" contract="EvalServiceLibrary.IEvalService"
          listenUriMode="Explicit">
          <identity>
            <dns value="localhost" />
            <certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"
          listenUriMode="Explicit">
          <identity>
              <dns value="localhost" />
              <certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" />
          </identity>
        </endpoint>
        <endpoint address="basic" binding="basicHttpBinding" contract="EvalServiceLibrary.IEvalService"
          listenUriMode="Explicit">
          <identity>
            <dns value="localhost" />
            <certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" />
          </identity>
        </endpoint>
        <endpoint address="net.tcp://localhost:8888/EvalService" binding="netTcpBinding"
          contract="EvalServiceLibrary.IEvalService" listenUriMode="Explicit">
          <identity>
            <dns value="localhost" />
            <certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" />
          </identity>
        </endpoint>
        <endpoint address="net.pipe://localhost/EvalService" binding="netNamedPipeBinding"
          bindingConfiguration="" contract="EvalServiceLibrary.IEvalService" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/EvalService" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

何が問題になっていますか/どうすれば修正できますか?

4

6 に答える 6

7

私も同じウェブキャストをフォローし、同じ問題を抱えていました。他の人が提案したように、それらのエントリをコメントアウトすることで、証明書の問題を回避しました。

「Design_Time_Addresses」をURLに追加して、「HTTPポートを8732に変更するか、管理者として実行してみてください」を修正しました。

動作しません

<add baseAddress="http://localhost:8732/AMessageService" />

動作します!

<add baseAddress="http://localhost:8732/Design_Time_Addresses/AMessageService" />
于 2012-02-27T06:05:25.693 に答える
3

上記の2つの問題の後者(HTTP could not register URL1つ)の解決策は、Gabobcatの回答(彼による)のコメントに投稿されたVS2010トレーニングキットにあります。

4番目の演習「Ex4-ServiceDiscovery」では、WCFサービスを使用して2つのクライアント間で通信するチャットアプリケーションのように見えるものが提供されます。検出機能を使用して、ネットワーク上のピアを検索します。簡単に言うと、完成したアプリケーションを最初に実行しようとしたときに同じ例外が発生します(演習で説明したように検出イベントを入力した後)。トレーニングキットには、「URL ACL」を設定または削除するための、いくつかのバッチスクリプト(AFAICTはMicrosoftの「オープンソース」ライセンスを使用しているため、これらのスクリプトを共有できるはずです)がバンドルされています。実際には、これらは単一の(有用な)コマンドにすぎないように見えます。

ファイル:AddURLACL.cmd

@Echo Off
@Echo Grant permissions for URL reservation
@Echo Parameter 1 "%1" == port
@Echo Parameter 2 "%2" == URL
pause
netsh http add urlacl url=http://+:%1/%2 user=%USERDOMAIN%\%USERNAME%

ファイル:DelURLACL.cmd

@Echo Off
@Echo Deletes permissions for URL reservation
@Echo Parameter 1 "%1" == port
@Echo Parameter 2 "%2" == URL
pause
netsh http delete urlacl url=http://+:%1/%2

明らかに、重要なのはnetshコマンドだけです。サンプルプロジェクトでは、次のコマンド([管理者として実行]コマンドプロンプトウィンドウから)を使用して、この例外を「修正」します。

C:\VS2010TrainingKit\Labs\WhatsNewInWCF4\Source\Setup\AddURLACL.cmd 8000

(私は、トレーニングキットのどこでこれらのスクリプトを見つけることができるかを示すためだけに絶対パスを使用しました。これを行ったとき、個人的にはWhatsNewInWCF4 \ Sourceディレクトリにいました)

文字列8000は、このプロジェクト全体で1回だけ発生します。

C:\VS2010TrainingKit\Labs\WhatsNewInWCF4\Source\Ex4-ServiceDiscovery\Begin\C#>findstr /n /s "8000" *
DiscoveryChat\SimpleChat.cs:376:            this.localAddress = new Uri("http://localhost:8000/" + Guid.NewGuid().ToString());

ポート8000​​は、チャットクライアントがサービスホストを起動しようとしているポートのようです(どのように共有するかは聞かないでください...使用するServiceHostクラスは、既存のサービスを再利用するのに十分インテリジェントであると思います。 ..)。

私はまだこれを徹底的に実験していませんが、EvalServiceプロジェクトを「修正」したようです(ポートを8000に変更したとき)。これは現在、ほとんどのエンドポイントが削除され(エンドポイントのみがbasicHttpBinding残っている)、にbaseAddress設定されていlocalhost:8000ます。

これがあなたにも役立つかどうか教えてください。

于 2011-10-27T15:15:19.640 に答える
1

問題は構成にあります。エンドポイントで証明書を参照しています。それらを削除するか:

<certificateReference storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectDistinguishedName" />

または、証明書ストアにいくつかの証明書を配置します。WCFについてもう少し学ぶまで、この時点で「ID」構成セクションを削除することをお勧めします。初心者向けの基本的なエンドポイント構成にとどまり、WCFの基本を理解したところから作業を進めてください。WCFは、特定のニーズに応じて、構成オプションの大規模な(非常に大規模な)セットを提供します。

たぶん、これらのリンクは、あなたが見ているビデオよりもWCFに入るのに役立つでしょう:

お役に立てれば。

于 2011-10-25T15:12:18.943 に答える
1

私は同じ問題に不満を持っていました。最後に、Visual Studio 2010を右クリックし、[管理者として実行]を選択して、管理者としてVisual Studioを実行することにより、自分で解決策を見つけました。

于 2012-04-08T04:59:48.380 に答える
0

私が読んでいたものから更新された統合された答えを追加すると思いました。

証明書のアクセス許可を許可するために私たち全員がかなりの努力をすることができますが、これを読んでいるほとんどの人は、実際にはWCFエンドポイントをできるだけ早く稼働させたいと思っています。

したがって、いくつかの選択肢があります。

1. sudipto-kumar-mukherjee above states "I was frustated with the same issue. 
Finally I found the solution by myself by running the Visual Studio as Administrator 
by right clicking Visual Studio 2010 and choosing 'Run As Administrator'."   
--> Yes,  this     will work.
OR
2. nasp.tech response with 
"Doesn't Work"
<add baseAddress="http://localhost:8732/AMessageService" />
"Works!"
<add baseAddress="http://localhost:8732/Design_Time_Addresses/AMessageService" />

これらのいずれかが、この問題を立ち上げて実行するための最速の方法のようです。

于 2013-02-25T00:57:33.033 に答える
-2

管理者として実行するには、Visual Studioを右クリックし、コンテキストメニューから[管理者として実行]を選択します。常に管理者として実行するには、Visual Studioを右クリックし、コンテキストメニューの[プロパティ]に移動します。[互換性]タブに移動し、[このプログラムを管理者として実行]を選択します。

于 2013-12-19T03:08:07.903 に答える