지난 몇 주 동안 저는 32 비트 DLL과 통신해야하는 64 비트 WinForms 응용 프로그램을 개발했습니다 (작업 사양 요구 사항).응용 프로그램 실행 파일을 실행할 때 WinForm 응용 프로그램 내에서 WCF 서비스 호스팅이 작동하지 않습니다.
인터넷을 통해 약간의 독서를하고 재미있는 방법이 없다는 것을 알게 된 후 32 비트 DLL과 통신하기 위해 WinForms 응용 프로그램 내에서 WCF 서비스 응용 프로그램을 호스팅하기로 결정했습니다. ... 또는 나는 내가하고 있다고 생각했다.
개발하는 동안 (Visual Studio에서 실행되는 동안) 정말 잘 작동했지만, 이제는 배포해야하므로 문제가 발생합니다. WCF Services에 대한 충분한 이해를 얻는 데 어려움을 겪고 있습니다. WCF Services가 끔찍한 방식으로 진행될 것인지 또는 몇 분 세부 사항을 놓치고 있는지 알기가 어렵습니다.
관리자로 프로젝트를 생성했습니다. 개발 후 이 완료되었습니다. WinForm 실행 파일 (디버그 및 릴리스 모두), WindowsFormsApplication1.exe를 실행하려고했습니다. 이 응용 프로그램은 최대 시작했지만, 나는 WCF 서비스의 사용을 포함하는 작업을 완료하는 데 노력 후, 예외가 발생 :이 비주얼 스튜디오가의 호스팅을하는 것을 믿고 저를 주도하고있다
서비스를 WinForm 응용 프로그램 대신 개발하는 동안 또는 내 configs 및/또는 디렉토리 구조가 올바르지 않습니다.
[업데이트]] WCF 서비스의 Web.config :
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" maxRequestLength="2147483647"/>
</system.web>
<system.net>
<defaultProxy>
<proxy usesystemdefault="False"/>
</defaultProxy>
</system.net>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true" >
<listeners>
<add name="xml"/>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="xml"/>
</listeners>
</source>
<source name="myUserTraceSource"
switchValue="Information, ActivityTracing">
<listeners>
<add name="xml"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="C:\logs\Traces.svclog" />
</sharedListeners>
</system.diagnostics>
<system.serviceModel>
<diagnostics wmiProviderEnabled="true">
<messageLogging
logEntireMessage="true"
logMalformedMessages="true"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
maxMessagesToLog="3000"
/>
</diagnostics>
<behaviors>
<serviceBehaviors>
<behavior name="metadadiscovery>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="ServiceReference1.Service1" behaviorConfiguration="metadadiscovery">
<endpoint address="" binding="basicHttpBinding" contract="ServiceReference1.IService1"></endpoint>
</service>
</services>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="false"/>
</system.webServer>
</configuration>
의 WinForm의 App.config는 :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService2" />
<binding name="BasicHttpBinding_IService3" />
<binding name="BasicHttpBinding_IService1" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:45053/Service2.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService2" contract="ServiceReference2.IService2"
name="BasicHttpBinding_IService2" />
<endpoint address="http://localhost:46351/Service3.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService3" contract="ServiceReference3.IService3"
name="BasicHttpBinding_IService3" />
<endpoint address="http://localhost:44848/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
<appSettings>
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
</configuration>
디렉토리 EXE가있는 경우 :
디렉토리가를 포함 WCF 서비스는 imag에서 WcfService1 디렉터리 내에 있습니다. 위의 e. 나는 서비스 호스트 (아래)를 사용하여 전환을 시도하면
ServiceReference1.Service1Client = new ServiceReference1.SErvice1Client();
,하지만 난 그 방법을 사용하는 경우, 서비스는 때마다 타임 아웃 것이다 :
나는 대부분의 서비스를 인스턴스화 다음과 같은 방법을 사용하고있다 DLL과 통신하려고했습니다.
Uri address = new Uri("http://localhost:44848/Service1.svc");
ServiceHost host = new ServiceHost(typeof(ServiceReference1.Service1Client), address);
host.Open();
그리고 호스트를 나중에 닫았습니다. 이 시점에서 나는이 일을하기 위해 무엇이든 시도하려고합니다.
[편집] 내 WindowsFormsApplication1.exe.config 파일의 코드는 다음과 같습니다. 세 가지 계약 모두 "clientContractType '데이터 유형에 따라 유효하지 않다고 경고합니다. 나는 이것이 내 문제의 원인이 될 수 있다고 생각하지만, 나는이 경고를 보여주는 이유를 알고하지 않습니다
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService2" />
<binding name="BasicHttpBinding_IService3" />
<binding name="BasicHttpBinding_IService1" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:45053/Service2.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService2" contract="ServiceReference2.IService2" name="BasicHttpBinding_IService2" />
<endpoint address="http://localhost:46351/Service3.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService3" contract="ServiceReference3.IService3" name="BasicHttpBinding_IService3" />
<endpoint address="http://localhost:44848/Service1.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
당신이 제공 할 수있는 도움과지도에 감사드립니다.
불행히도,이 문제가 해결되지 않았습니다. – bhaan
업데이트 된 구현이 내가 의도 한대로 구현되었는지 확인해 주시겠습니까? 나는 벽에 머리를 부딪쳐서 이것을 알아 내려고 노력했다. – bhaan
서비스 계약을 게시 할 수 있습니까? –