2011-10-25 10 views
6

Staram się śledzić wraz z filmami demonstracyjnymi na stronie dla początkujących do strony WCF na MSDN."Konfigurowanie usług z punktami końcowymi" Demo nie powiedzie się dla mnie (Microsoft/endpoint.tv/Pluralsight)

Pierwszy film pracował mniej więcej dobrze. Zbliżam się do końca drugiego filmu. Używam VS2010/.NET 4.0, podczas gdy wideo wydaje się używać VS2008 (Zakładam .NET 3.5, ale nie pamiętam).

I'm using the following demo

Właśnie dodaliśmy kolejne 3 punkty końcowe: zwykły http, Net.TCP i net.pipe. Kiedy próbuję uruchomić projekt, usługa sieci Web nie uruchamia się.

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) 

podstawie mojego fu Google natknąłem tym wątku: "Cannot load the X.509 certificate identity specified in the configuration"

ja naprawdę nie chce się angażować w certyfikatach jeszcze ponieważ jestem nadal tylko eksperymentowanie z podstawami więc następuje poradę w tym poście i właśnie dodałem tag <dns value="localhost" />. Zmiany wyjątek:

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() 

Tak, próbowałem robić to, co powiedział: zmiana portu będzie 8732, ale wyjątek jest jeszcze rzucone, tym razem mówiąc Please try changing the HTTP port to 8732...HTTP could not register URL http://+:8732/EvalService/.... : P

Próbowałem komentować nowe punkty końcowe bez skutku. Nawet pierwotne zawodzą z tym błędem. Nie ma znaczenia, albo jeśli umieścić je z powrotem do pierwotnego portu [nie tak] 1337.

Oto app.config i nic wyróżnia się jako problematyczne:

<?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> 

Co jest nie tak/jak zrobić Naprawię to?

Odpowiedz

3

Pozornie działające rozwiązanie dla drugiego z dwóch powyższych problemów (HTTP could not register URL) można znaleźć w VS2010 Training Kit zamieszczonym w komentarzach odpowiedzi Gabobcat (przez niego).

W czwartym ćwiczeniu "Ex4-ServiceDiscovery" otrzymujesz coś, co wygląda na aplikację do czatu, która używa usług WCF do komunikacji między dwoma klientami. Używa funkcji wykrywania, aby znaleźć rówieśników w sieci. Krótko mówiąc, ten sam wyjątek występuje wtedy, gdy początkowo próbujesz uruchomić ukończoną aplikację (po wypełnieniu zdarzeń odkrywania, jak określono w ćwiczeniu). W pakiecie z zestawem szkoleniowym znajduje się kilka skryptów wsadowych (które AFAICT używa licencji "open source" Microsoftu, więc powinienem móc udostępniać te skrypty), aby ustawić lub usunąć "listy ACL adresów URL". W praktyce pojawiają się pojedyncze (przydatne) komenda tylko:

Plik: 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% 

Plik: 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 

Oczywiście, polecenia są netsh tylko te, które mają znaczenie. Przykładowy projekt musi użyć następującego polecenia (z „Uruchom jako administrator” okno wiersza polecenia), aby „naprawić” ten wyjątek:

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

(użyłem bezwzględną ścieżkę tylko pokazać, gdzie w Training Kit można znaleźć te skrypty; osobiście byłem w katalogu WhatsNewInWCF4 \ Source kiedy to zrobił)

ciąg 8000 występuje tylko 1 raz w całym tym projekcie:

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()); 

wydaje się, że port 8000 jest portem że klienci czatu próbują uruchomić ch usługodawca na (nie pytaj mnie, jak wszyscy się nim dzielą ... Zakładam, że klasa ServiceHost, której używają, jest na tyle inteligentna, aby ponownie wykorzystać istniejącą usługę ...).

Nie eksperymentowałem jeszcze z tym dokładnie, ale wydaje się, że "naprawiłem" mój projekt EvalService (kiedy zmieniłem port na 8000). Jest to obecnie z usuniętą większością punktów końcowych (tylko końcowy punkt końcowy basicHttpBinding) i baseAddress ustawiony na localhost:8000.

Daj mi znać, jeśli to działa również dla Ciebie.

1

Problem występuje w konfiguracji. Wymieniasz certyfikaty w swoich punktach końcowych. Możesz je usunąć:

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

Lub możesz umieścić niektóre certyfikaty w swoim magazynie certyfikatów. Polecam usunięcie sekcji konfiguracji "tożsamości" w tym momencie, dopóki nie nauczysz się nieco więcej o WCF. Spróbuj pozostać przy podstawowej konfiguracji punktu końcowego dla początkujących i pracuj od punktu, w którym rozumiesz podstawy WCF. WCF daje duży (naprawdę duży) zestaw opcji konfiguracyjnych w zależności od Twoich konkretnych potrzeb.

Może te linki pomogą Ci przejść do WCF lepiej, że filmy, które zostały oglądania:

nadzieję, że to pomaga.

+0

dzięki. Komentowanie znaczników '' powoduje usunięcie błędów certyfikatu X.509, ale nadal pozostają błędy związane z oprawianiem. Myślę, że sekcje "" również zostały automatycznie dodane przez Visual Studio (bez żadnej specjalnej akcji przeze mnie), więc wydaje się nieintuicyjne, aby pozbyć się ich w tym demo. – bambams

+0

Ile masz węzłów/wiązań? Zacznij od jednego punktu końcowego za pomocą podstawowegoHttpBinding. Usuń inne punkty końcowe i powiązania, do których się odwołują. Czy używasz serwera programisty VS lub innego serwera WWW? Jeśli tak, pozwól VS kontrolować numery portów. Jeśli korzystasz z innego serwera WWW, trzymaj się portu 80 ze względu na swoje dema. Jeśli musisz, opublikuj nowe wyjątki, które otrzymujesz. –

+0

Pierwszy link zamieszczony powyżej to pierwszy link w OP. ;) Właśnie tam znalazłem film. : P – bambams

7

Ja też podążałem za tym samym webcast i miałem te same problemy. Obejrzałem kwestię certyfikatu, komentując te wpisy zgodnie z sugestiami innych osób.

I poprawione "Proszę spróbować zmienić port HTTP do 8732 lub z systemem jako administrator" dodając "Design_Time_Addresses" z powrotem do mojego url

nie działa

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

działa!

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

Działa również dla mnie w VS 2012. –

1

Byłem ścięty z tym samym problemem. W końcu znalazłem rozwiązanie samodzielnie, uruchamiając Visual Studio jako Administrator, klikając prawym przyciskiem myszy Visual Studio 2010 i wybierając "Uruchom jako administrator".

0

Myślałem, że dodam zaktualizowaną, skonsolidowaną odpowiedź z tego, co czytałem.

Podczas gdy wszyscy możemy bardzo się starać, aby zezwolić na uprawnienia z certyfikatem, większość osób czytających to naprawdę chce uzyskać punkty końcowe WCF działające jak najszybciej.

Tak więc kilka możliwości.

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" /> 

Każdy z nich wydaje się być najszybszym sposobem na rozpoczęcie pracy z tym problemem.

-2

Aby uruchomić jako administrator, kliknij prawym przyciskiem i wybierz Visual Studio Uruchom jako administrator z menu kontekstowego. Aby uruchomić jako administrator cały czas, kliknij prawym przyciskiem Visual Studio, a następnie przejdź do właściwości w menu kontekstowym Got do zakładki zgodności, a następnie wybierz opcję Uruchom ten program jako administrator.

Powiązane problemy