서비스에 애플리케이션 (비 인프라) 엔드 포인트가 없습니다.
최근에 WCF 서비스 (dll)와 서비스 호스트 (exe)를 만들었습니다. WcfTestClient에 서비스를 성공적으로 추가 할 수 있으므로 내 WCF 서비스가 올바르게 작동하고 있음을 알고 있습니다.
그러나 서비스 호스트 (exe)에서 내 WCF를 사용할 때 문제가 발생하는 것 같습니다. 내 서비스 호스트 (exe)에 WCF (dll)에 대한 참조를 추가하고 exe에 필요한 구성 요소를 만들 수 있습니다. 서비스 설치 프로그램, 서비스 호스트 및 app.config와 같은, 컴파일 한 다음 마지막으로 InstallUtil을 사용하여 exe를 설치합니다. 그러나 Microsoft Management Console에서 서비스를 시작하려고하면 서비스가 시작된 후 즉시 중지됩니다.
그래서 이벤트 뷰어의 응용 프로그램 로그에서이 오류가 발생한 원인이 정확히 무엇인지 조사하기 시작했습니다.
기술:
서비스를 시작할 수 없습니다. System.InvalidOperationException : 서비스 '서비스'에 응용 프로그램 (비 인프라) 끝 점이 없습니다. 이는 애플리케이션에 대한 구성 파일이 없거나 구성 파일에서 서비스 이름과 일치하는 서비스 요소를 찾을 수 없거나 서비스 요소에 정의 된 엔드 포인트가 없기 때문일 수 있습니다.
이 오류는 실제로 생성됩니다 OnStart. 이 호출을 수행 할 때 내 exe의 ServiceHost.Open(). 나는 다른 사람들이이 문제를 겪은 수많은 게시물을 보았지만, 전부는 아니더라도 대부분은 서비스 이름이나 계약을 주장합니다. 네임 스페이스 및 클래스 이름이 지정되지 않았습니다. 내 구성 파일에서이 두 항목을 모두 확인했습니다. exe뿐만 아니라 dll에서도 완벽하게 일치합니다. 나는 사무실에있는 다른 사람들에게 내가 한 번에 눈이 멀지 않았는지 다시 확인하도록했지만, 물론 그들은 모든 것이 올바르게 지정된 것처럼 보인다는 동일한 결론에 도달했습니다. 나는이 시점에서 무슨 일이 일어나고 있는지 정말로 잃어 버렸다. 누구든지이 문제로 나를 도울 수 있습니까?
이 문제가 발생할 수있는 또 다른 이유는 app.config가 읽히지 않는다는 것입니다. 적어도 내가 읽어야한다고 생각하는 것은 아닙니다. 이것이 문제일까요? 그렇다면이 문제를 어떻게 해결할 수 있습니까? 다시 한 번 모든 도움을 주시면 감사하겠습니다.
방금이 문제가 발생하여 서비스 이름에 네임 스페이스를 추가하여 해결했습니다. 예 :
<service name="TechResponse">
되었다
<service name="SvcClient.TechResponse">
또한 App.config 대신 Web.config로 해결되는 것을 보았습니다.
엔드 포인트에는 네임 스페이스도 있어야합니다.
<endpoint address="uri" binding="wsHttpBinding" contract="Namespace.Interface" />
서비스 프로젝트에서 콘솔 호스트 애플리케이션으로 App.config 파일을 복사하고 여기에 붙여 넣은 다음 서비스 프로젝트에서 삭제하면됩니다.
고려해야 할 한 가지는 : WCF가 WS (WindowsService)에서 완전히 분리되어 있습니까? WS는 통제력이나 가시성이 많지 않기 때문에 고통 스럽습니다. 비 WS 항목을 모두 자체 클래스에 포함하여 호스트 WS와 독립적으로 테스트 할 수 있도록하여이를 완화하려고합니다. 이 접근 방식을 사용하면 특히 서비스와 비교하여 WS 런타임에서 발생하는 모든 일을 제거 할 수 있습니다.
John은 .config 파일 문제라는 것이 맞을 수 있습니다. WCF는 항상 실행 컨텍스트 .config를 찾습니다 . 따라서 다른 실행 컨텍스트에서 WCF를 호스팅하는 경우 (즉, 콘솔 응용 프로그램으로 테스트하고 WS로 배포) WCF 구성 데이터를 적절한 .config 파일로 이동했는지 확인해야합니다. 그러나 저에게 근본적인 문제는 WS goo가 방해가되기 때문에 문제가 무엇인지 모른다는 것입니다. 어떤 컨텍스트 (즉, 단위 테스트 또는 콘솔)에서든 서비스를 실행할 수 있도록 아직 리팩토링하지 않았다면 그렇게 할 것입니다. 단위 테스트에서 서비스를 가동하면, 엉뚱한 WS 배관으로 시도하는 것보다 디버그하기 훨씬 쉬운 WS에서 보는 것과 동일한 방식으로 실패 할 수 있습니다.
프로그래밍 방식으로 추가했을 때 더 자세한 예외가 발생했습니다 AddServiceEndpoint.
string baseAddress = "http://" + Environment.MachineName + ":8000/Service";
ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress));
host.AddServiceEndpoint(typeof(MyNamespace.IService),
new BasicHttpBinding(), baseAddress);
host.Open();
WCF에 대한 구성을 준비하는 것은 어렵고 때로는 서비스 유형 정의가 눈에 띄지 않게됩니다.
서비스 태그에 네임 스페이스 만 작성 했으므로 동일한 오류가 발생했습니다.
<service name="ServiceNameSpace">
잊지 마십시오. 서비스 태그에는 완전한 서비스 클래스 이름이 필요합니다.
<service name="ServiceNameSpace.ServiceClass">
나와 같은 다른 사람들을 위해.
오늘 나는 같은 문제에 직면하여 여기에 내 실수를 게시하고 누군가를 도울 수 있도록 수정했습니다.
코드를 재구성하는 동안 실제로 Service 클래스 및 IService 이름을 변경하고 ServiceHost를이 새 서비스 클래스 이름 (코드 조각에 표시됨)을 가리 키도록 변경했지만 호스트 응용 프로그램 App.Config 파일에서는 여전히 이전 서비스 클래스 이름을 사용하고있었습니다. . (아래 스 니펫의 구성 섹션 이름 필드 참조)
다음은 코드 스 니펫입니다.
ServiceHost myServiceHost = new ServiceHost(typeof(NewServiceClassName));
섹션 서비스의 App.config 파일에서 이전 서비스 클래스 이름을 참조하여 New ServiceClassName 수정 된 문제로 변경했습니다.
<service name="ProjectName.OldServiceClassName">
<endpoint address="" binding="basicHttpBinding" contract="ProjectName.IService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress=""/>
</baseAddresses>
</host>
</service>
나는 같은 문제가 있었다. 모든 것이 VS2010에서 작동하지만 VS2008에서 동일한 프로젝트를 실행하면 언급 된 예외가 발생합니다.
VS2008 프로젝트에서 내가 한 일은 AddServiceEndpointServiceHost 개체 의 구성원에 대한 호출을 추가하는 것입니다.
내 코드 스 니펫은 다음과 같습니다.
Uri baseAddress = new Uri("http://localhost:8195/v2/SystemCallbackListener");
ServiceHost host = new ServiceHost(typeof(SystemCallbackListenerImpl), baseAddress);
host.AddServiceEndpoint(typeof(CsfServiceReference.SystemCallbackListener),
new BasicHttpBinding(),
baseAddress);
host.Open();
app.config 파일을 수정하지 않았습니다. 하지만 서비스 엔드 포인트가 .config 파일에 추가되었을 수도 있습니다.
내 서비스에서이 문제를 해결했습니다. 내가받은 오류는 다음과 같습니다.
Service 'EmailSender.Wcf.EmailService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.
Here are the two steps I used to fix it:
Use the correct fully-qualified class name:
<service behaviorConfiguration="DefaultBehavior" name="EmailSender.Wcf.EmailService">Enable an endpoint with mexHttpBinding, and most importantly, use the IMetadataExchange contract:
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
This error will occur if the configuration file of the hosting application of your WCF service does not have the proper configuration.
Remember this comment from configuration:
When deploying the service library project, the content of the config file must be added to the host's app.config file. System.Configuration does not support config files for libraries.
If you have a WCF Service hosted in IIS, during runtime via VS.NET it will read the app.config of the service library project, but read the host's web.config once deployed. If web.config does not have the identical <system.serviceModel> configuration you will receive this error. Make sure to copy over the configuration from app.config once it has been perfected.
I ran Visual Studio in Administrator mode and it worked for me :) Also, ensure that the app.config file which you are using for writing WCF configuration must be in the project where "ServiceHost" class is used, and not in actual WCF service project.
My problem was when I renamed my default Service1 class for .svc file to a more meaningful name, which caused web.config behaviorConfiguration and endpoint to correspond to old naming convention. Try to fix your web.config.
I just ran into this issue and checked all of the above answers to make sure I wasn't missing anything obvious. Well, I had a semi-obvious issue. My casing of my classname in code and the classname I used in the configuration file didn't match.
For example: if the class name is CalculatorService and the configuration file refers to Calculatorservice ... you will get this error.
One crucial thing to remember for those working with a Console application to host the WCF service is that the Web.config file in the WCF project is completely ignored. If your system.serviceModel configuration is there, then you need to move that section of config to the App.config of your Console project.
This is in addition to the answers concerning ensuring the namespace is specified in the right places.
As another clue, that indeed fixed this issue in my case.
I'm migrating some WCF services from a console application (that configures in code few WCF services) to an Azure WebRole to publish them in Azure. Every time I add a new service VS edits my web.config and adds this line:
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
Well, with all the advices and answers above I couldn't make it work until I removed all the attributes in the serviceHostingEnvironment element. As you can see I'm not a WCF rockstar but I made it to work with the first Service just by configuring it as:
<service name="FirstService" behaviorConfiguration="metadataBehavior">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_WcfServicesBinding"
contract="IFirstService" />
</service>
but when I added the second Service it stoped working and I realized that those attributes where there again.
I hope it saves you time.
I had this error in a Windows Service when my WCF Service Library that I created was not connected for hosting, but was connected for connection. I was missing an endpoint. (I wanted both connection and hosting in my Windows Service so that I could serve up the WCF Service to other connections, as well as have the main process of my Windows Service use it as well to do various tasks on a timer/schedule.)
The fix was that I rightlcicked my App.config file and chose Edit WCF Configuration. Then, I did the steps for Create Service so that I could connect to my WCF Service. Now I had two endpoints in my App.config, not just one. One endpoint was for the connection to the WCF Service Library, and another was for the hosting of it.
'Programing' 카테고리의 다른 글
| 콘솔 종료 C # 캡처 (0) | 2020.09.10 |
|---|---|
| Rails Console과 동등한 Phoenix가 있습니까? (0) | 2020.09.10 |
| 배치 파일에는 변수에 대한 외부 파일이 포함됩니다. (0) | 2020.09.10 |
| 로더 잠금 오류 (0) | 2020.09.10 |
| 열거 형 및 상수. (0) | 2020.09.10 |