WCF C# bekomme Projekt nicht übers Netzwerk zum laufen

  • C#

    WCF C# bekomme Projekt nicht übers Netzwerk zum laufen

    Ich bekomme mein einfaches kleines Projekt einfach nicht zum Laufen...

    Und ich weiß nicht woran es liegt...vllt kann jemand von euch mir helfen...

    Der Client soll auf nem anderen PC laufen und auf meinen zugreifen und sich dort vom Service ne Nachricht abholen...
    mit localhost funktioniert es...

    Service

    C#-Quellcode

    1. using System;
    2. using System.Collections.Generic;
    3. using System.Linq;
    4. using System.Text;
    5. using System.Threading.Tasks;
    6. namespace TCPBinding
    7. {
    8. class HelloService : IHelloService
    9. {
    10. #region IHelloService Member
    11. public string DoIt()
    12. {
    13. return "Hallo WCF-User";
    14. }
    15. #endregion
    16. }
    17. }


    C#-Quellcode

    1. using System;
    2. using System.Collections.Generic;
    3. using System.Linq;
    4. using System.ServiceModel;
    5. using System.Text;
    6. using System.Threading.Tasks;
    7. namespace TCPBinding
    8. {
    9. [ServiceContract]
    10. interface IHelloService
    11. {
    12. [OperationContract]
    13. string DoIt();
    14. }
    15. }


    C#-Quellcode

    1. using System;
    2. using System.Collections.Generic;
    3. using System.Linq;
    4. using System.ServiceModel;
    5. using System.Text;
    6. using System.Threading.Tasks;
    7. namespace TCPBinding
    8. {
    9. class Program
    10. {
    11. static void Main(string[] args)
    12. {
    13. using (ServiceHost sh = new ServiceHost(typeof(HelloService)))
    14. {
    15. sh.Open();
    16. Console.WriteLine("Service bereit...");
    17. Console.ReadLine();
    18. }
    19. }
    20. }
    21. }


    XML-Quellcode

    1. <?xml version="1.0" encoding="utf-8" ?>
    2. <configuration>
    3. <startup>
    4. <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    5. </startup>
    6. <system.serviceModel>
    7. <behaviors>
    8. <serviceBehaviors>
    9. <behavior name="ServiceBehaviorMeta">
    10. <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:2321/HelloService/meta" />
    11. </behavior>
    12. </serviceBehaviors>
    13. </behaviors>
    14. <services>
    15. <service behaviorConfiguration="ServiceBehaviorMeta" name="TCPBinding.HelloService">
    16. <endpoint address="net.tcp://[ip von meinem pc]:2121/HelloService" binding="netTcpBinding"
    17. bindingConfiguration="" name="HalloServiceTCPEndpoint" contract="TCPBinding.IHelloService" />
    18. </service>
    19. </services>
    20. </system.serviceModel>
    21. </configuration>


    jetzt zum Client...

    mit svcutil erzeugte Proxy-Klasse

    C#-Quellcode

    1. //------------------------------------------------------------------------------
    2. // <auto-generated>
    3. // Dieser Code wurde von einem Tool generiert.
    4. // Laufzeitversion:4.0.30319.18444
    5. //
    6. // Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
    7. // der Code erneut generiert wird.
    8. // </auto-generated>
    9. //------------------------------------------------------------------------------
    10. [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    11. [System.ServiceModel.ServiceContractAttribute(ConfigurationName="IHelloService")]
    12. public interface IHelloService
    13. {
    14. [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHelloService/DoIt", ReplyAction="http://tempuri.org/IHelloService/DoItResponse")]
    15. string DoIt();
    16. [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHelloService/DoIt", ReplyAction="http://tempuri.org/IHelloService/DoItResponse")]
    17. System.Threading.Tasks.Task<string> DoItAsync();
    18. }
    19. [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    20. public interface IHelloServiceChannel : IHelloService, System.ServiceModel.IClientChannel
    21. {
    22. }
    23. [System.Diagnostics.DebuggerStepThroughAttribute()]
    24. [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    25. public partial class HelloServiceClient : System.ServiceModel.ClientBase<IHelloService>, IHelloService
    26. {
    27. public HelloServiceClient()
    28. {
    29. }
    30. public HelloServiceClient(string endpointConfigurationName) :
    31. base(endpointConfigurationName)
    32. {
    33. }
    34. public HelloServiceClient(string endpointConfigurationName, string remoteAddress) :
    35. base(endpointConfigurationName, remoteAddress)
    36. {
    37. }
    38. public HelloServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
    39. base(endpointConfigurationName, remoteAddress)
    40. {
    41. }
    42. public HelloServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
    43. base(binding, remoteAddress)
    44. {
    45. }
    46. public string DoIt()
    47. {
    48. return base.Channel.DoIt();
    49. }
    50. public System.Threading.Tasks.Task<string> DoItAsync()
    51. {
    52. return base.Channel.DoItAsync();
    53. }
    54. }


    C#-Quellcode

    1. using System;
    2. using System.Collections.Generic;
    3. using System.Linq;
    4. using System.Text;
    5. using System.Threading.Tasks;
    6. using System.ServiceModel;
    7. namespace TCPBindingClient
    8. {
    9. class Program
    10. {
    11. static void Main(string[] args)
    12. {
    13. HelloServiceClient hsc = new HelloServiceClient();
    14. Console.WriteLine(hsc.DoIt());
    15. hsc.Close();
    16. Console.ReadLine();
    17. }
    18. }
    19. }


    ebenfalls mit svcutil erzeugte app.config

    XML-Quellcode

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <configuration>
    3. <system.serviceModel>
    4. <bindings>
    5. <netTcpBinding>
    6. <binding name="HalloServiceTCPEndpoint" />
    7. </netTcpBinding>
    8. </bindings>
    9. <client>
    10. <endpoint address="net.tcp://[ip von meinem pc]:2121/HelloService" binding="netTcpBinding"
    11. bindingConfiguration="HalloServiceTCPEndpoint" contract="IHelloService"
    12. name="HalloServiceTCPEndpoint">
    13. <identity>
    14. <userPrincipalName value="MM\Musterle" />
    15. </identity>
    16. </endpoint>
    17. </client>
    18. </system.serviceModel>
    19. </configuration>


    Ich hoffe ihr könnt damit alle was anfangen...
    das meiste das ich im Netz gefunden habe ist mit localhost (was ja bei mir problemlos funktioniert)
    oder nicht problemspezifisch...

    Mein Gedanke war, dass ich beim Client in der app.config die Ip austausche durch die des anderen PCs...brachte aber ebenfalls nichts...

    -Was überseh ich, dass es nicht wie gewünscht läuft?
    -fehlt mir noch was grundlegendes?
    -muss ich bei der Konfiguration noch was dazu schreiben, damit es funktioniert?

    ...die Firewall an meinem PC war während des Tests ausgeschaltet

    *Topic verschoben*

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Marcus Gräfe“ ()