Linked Questions

Popular Questions

I have a WCF application and some clients in my solution. What is the problem - when i try to access any method implemented in service from client, i get this error. I correctly added service references to every client and my Web.config file is shown below. I already included detailed exceptions in my web config file and after that, i keep getting this error.

I already tried to debug my code and see which part throws exception, but it happens when i'm running client, and error is on server side. Could problem be in my static constructors in my server class?

<?xml version="1.0"?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.6.1" />
    <httpRuntime targetFramework="4.6.1"/>
       </system.web>
  <system.serviceModel>
    <services>
      <service name="Service.Service" behaviorConfiguration="debug">

        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>

        <endpoint address="AlarmDisplay" binding="wsDualHttpBinding" contract="Service.IAlarm"></endpoint>
        <endpoint address="AlarmDisplay/Mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>

        <endpoint address="DatabaseManager" binding="basicHttpBinding" contract="Service.IDatabaseManager"></endpoint>
        <endpoint address="DatabaseManager/Mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>

        <endpoint address="RealTimeUnit" binding="basicHttpBinding" contract="Service.IRealTimeUnit"></endpoint>
        <endpoint address="RealTimeUnit/Mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>

        <endpoint address="Trending" binding="wsDualHttpBinding" contract="Service.ITrending"></endpoint>
        <endpoint address="Trending/Mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>    
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="debug">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata/>
        </behavior>
        <behavior>
          <!-- 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>
    <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="true"/>
  </system.webServer>

</configuration>

And this is service file:

public class Service : IAlarm, IDatabaseManager, IRealTimeUnit, ITrending
   {
    static Dictionary<string, Tag> tags = new Dictionary<string, Tag>();
    static Dictionary<string, Thread> threads = new Dictionary<string, Thread>();

    static SimulationDriver simulationDriver = new SimulationDriver();
    static RealTimeDriver realTimeDriver = new RealTimeDriver();

    static IAlarmCallback alarmCallback = null;
    delegate void AlarmDelegate(string message);
    static event AlarmDelegate AlarmActivated = null;

    static ITrendingCallback trendingCallback = null;
    delegate void TrendingDelegate(int option, string type, string ID, double value);
    static event TrendingDelegate ValueChanged = null;

    static string scadaDirectory = @"C:\Users\Sevic\Desktop\SCADA\dir\";
    static string configFile = @"scadaConfig.txt";
    static string alarmFile = @"alarmLog.txt";

    static string database = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Sevic\Desktop\SCADA\SCADA\Service\App_Data\DATABASE.mdf;Integrated Security=True";
    static SqlConnection connection = new SqlConnection(database);

    static bool serviceRunning = LoadConfigFile();

 ... implementation of methods
    }

Related Questions