WCF - has more than one .svc service in an ASP.NET application

I created in Visual Studio 2010 a C # / ASP.NET application and in this file service.svc

and the corresponding

  • IService.cs

    //The contract
  • Service.cs

    // Implementation of the contract - interface

and this WCF service is returning my data in JSON. I hit it with jQuery ajax post. This service worked the way I wanted, but then I decided to add a second service i.e. ServiceNew.svc

with its respective

  • IServiceNew.cs

    //The contract
  • ServiceNew.cs

    // Implementation of the contract - interface

and adding the corresponding endpoint to web.config

.

After I added the second WCF service, none of the services returned an internal internal server error.

The strangest part is that if I delete the folder of my app all the new files ServiceNew.svc

, IServiceNew.cs

, ServiceNew.cs

, first service.svc

works, when I hit them jQuery messages as before, and then, if I just copy these files back to their folder and run visual studio host, then BOTH of my services (old and new) run for an arbitrary period of time, and then they suddenly return 500 errors again when I click on them with jQuery ajax.

My web.config

:

<system.serviceModel>       
   <behaviors>
     <serviceBehaviors>
       <behavior name="ServiceBehavior">
         <serviceMetadata httpGetEnabled="true"/>
         <serviceDebug includeExceptionDetailInFaults="true"/>
       </behavior>
     </serviceBehaviors>
     <endpointBehaviors>
       <behavior name="EndpBehavior">
         <webHttp/>
       </behavior>
     </endpointBehaviors>
   </behaviors>
   <services>
     <service behaviorConfiguration="ServiceBehavior" name="Service">
       <endpoint address="" binding="webHttpBinding"
           contract="IService" behaviorConfiguration="EndpBehavior"/>
     </service>
     <service behaviorConfiguration="ServiceBehavior" name="ServiceNew">
       <endpoint address="" binding="webHttpBinding"
           contract="IServiceNew" behaviorConfiguration="EndpBehavior"/>
     </service>
   </services>
 </system.serviceModel>

      

IService.cs

:

[ServiceContract]
public interface IService
{
    [OperationContract]
    [WebInvoke(Method = "POST",
 ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
    [return: MessageParameter(Name = "d")]
    MovieInfo GetMovieInfo(string title, string year);
}

      

Service.cs

:

[AspNetCompatibilityRequirements(RequirementsMode
    = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service: IService
{
    public MovieInfo GetMovieInfo(string title, string year)
    {
          ...
          return MovieInfo();
        }
}

      

Similarly

IServiceNew.cs

:

[ServiceContract]
public interface IServiceNew
{
    [OperationContract]
    [WebInvoke(Method = "POST",
 ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
    [return: MessageParameter(Name = "d")]
    string GetConf();
}

      

ServiceNew.cs

:

[AspNetCompatibilityRequirements(RequirementsMode
    = AspNetCompatibilityRequirementsMode.Allowed)]
public class ServiceNew: IServiceNew
{
    public string GetConf()
    {
          ...
          return conf;
        }
}

      

Can someone tell me what I am doing wrong? How can I add multiple WCF applications (.svc files) in an ASP.NET application to impress them with jQuery ajax calls?

Is there something wrong with mine web.config

?

Is this something else?

thank

UPDATE:

As an update, I can say that when I try to debug one of the .svc files, say ServiceNew.svc, the following exception is displayed in the browser:

Could not load file or assembly 'App_Web_oq2tdtg4, Version = 0.0.0.0, Culture = neutral, PublicKeyToken = null' or one of its dependencies. The system cannot find the file specified.

Stack trace:

[FileNotFoundException: Could not load file or assembly. App_Web_oq2tdtg4, Version = 0.0.0.0, Culture = neutral, PublicKeyToken = null, or one of its dependencies. The system cannot find the file specified.] System.Reflection.RuntimeAssembly._nLoad (AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark & ​​stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, SystemChecks suppressSeressSeress0 (AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark & ​​stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39 System.Reflection.RuntimeAssembly.InternalLoadorate assemblyStackCrawlMark & ​​stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132 System.Reflection.RuntimeAssembly.InternalLoad (String assemblyString, Evidence assemblySecurity, StackCrawlMark & ​​stackMark, StringStringStringo forIntrospection) +144 System.Reflection.Reflection ServiceModel.Activation.ServiceHostFactory.CreateServiceHost (String constructorString, Uri [] baseAddresses) +210 System.ServiceModel.HostingManager.CreateService (String normalizedVirtualPath) +1461 System.ServiceModel.Hosting normalManager.Ac EnsureServiceAvailable (String normalizedVirtualPath) +651Evidence assemblySecurity, StackCrawlMark & ​​stackMark, Boolean forIntrospection) +144 System.Reflection.Assembly.Load (String assemblyString) +28 System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost (String constructorString, Uri [] baseAddresses) .CreateService (String normalizedVirtualPath) +1461 System.ServiceModel.HostingManager.ActivateService (String normalizedVirtualPath) +44 System.ServiceModel.HostingManager.EnsureServiceAvailable (String normalizedVirtualPath) +651Evidence assemblySecurity, StackCrawlMark & ​​stackMark, Boolean forIntrospection) +144 System.Reflection.Assembly.Load (String assemblyString) +28 System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost (String constructorString, Uri [] baseAddresses) .CreateService (String normalizedVirtualPath) +1461 System.ServiceModel.HostingManager.ActivateService (String normalizedVirtualPath) +44 System.ServiceModel.HostingManager.EnsureServiceAvailable (String normalizedVirtualPath) +651CreateService (String normalizedVirtualPath) +1461 System.ServiceModel.HostingManager.ActivateService (String normalizedVirtualPath) +44 System.ServiceModel.HostingManager.EnsureServiceAvailable (String normalizedVirtualPath) +651CreateService (String normalizedVirtualPath) +1461 System.ServiceModel.HostingManager.ActivateService (String normalizedVirtualPath) +44 System.ServiceModel.HostingManager.EnsureServiceAvailable (String normalizedVirtualPath) +651

[ServiceActivationException: Service /ServiceNew.svc could not be activated due to a compile-time exception. Exception message: Could not load file or assembly 'App_Web_oq2tdtg4, Version = 0.0.0.0, Culture = neutral, PublicKeyToken = null' or one of its dependencies. The system cannot find the file specified ..] System.Runtime.AsyncResult.End (result of IAsyncResult) +687598 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End (result of IAsyncResult) +190 System.ServiceModel.ActtpRetivation.HostedAppult String routeServiceVirtualPath, Boolean flowContext, Boolean provide WFService) +234 System.ServiceModel.Activation.HttpHandler.ProcessRequest (HttpContext context) +24 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IE.Execute () +100 System.Web.HttpApplication.ExecuteStep (step IExecutionStep, Boolean & completed synchronously) +75

Assembly loading schedule:

The following information may be helpful in determining why the assembly 'App_Web_oq2tdtg4, Version = 0.0.0.0, Culture = neutral, PublicKeyToken = null' could not be loaded.

=== Pre-binding state information === LOG: User = ZULUTRADE \ stassis LOG: DisplayName = App_Web_oq2tdtg4, Version = 0.0.0.0, Culture = neutral, PublicKeyToken = null (Fully specified) LOG: Appbase = file: /// C: / Users / stassis / Documents / Development / theDreamBox / LOG: Initial PrivatePath = C: \ Users \ stassis \ Documents \ Development \ theDreamBox \ bin

Assembly call: (Unknown).

LOG: This binding starts in the default load context. LOG: Using the application configuration file: C: \ Users \ stassis \ Documents \ Development \ theDreamBox \ web.config LOG: Using the host configuration file: LOG: Using the machine configuration file from C: \ Windows \ Microsoft.NET \ Framework \ v4. 0.30319 \ config \ machine.config. LOG: Policy is not applied to link at this time (private, custom, partial, or location based assembly binding). LOG: Attempting to download a new file URL: /// C: / Users / stassis / AppData / Local / Temp / Temporary ASP.NET Files / root / 87ef3319 / ec80b2f5 / App_Web_oq2tdtg4.DLL. LOG: Attempting to download a new file URL: /// C: / Users / stassis / AppData / Local / Temp / Temporary ASP.NET Files / root / 87ef3319 / ec80b2f5 / App_Web_oq2tdtg4 / App_Web_oq2tdtg4.DLL. LOG: Attempting to download a new file URL: /// C:/Users/stassis/Documents/Development/theDreamBox/bin/App_Web_oq2tdtg4.DLL. LOG: Attempting to download a new file URL: /// C: /Users/stassis/Documents/Development/theDreamBox/bin/App_Web_oq2tdtg4/App_Web_oq2tdtg4.DLL. LOG: Attempting to download a new file URL: /// C: / Users / stassis / AppData / Local / Temp / Temporary ASP.NET Files / root / 87ef3319 / ec80b2f5 / App_Web_oq2tdtg4.EXE. LOG: Attempting to download a new file URL: /// C: / Users / stassis / AppData / Local / Temp / Temporary ASP.NET Files / root / 87ef3319 / ec80b2f5 / App_Web_oq2tdtg4 / App_Web_oq2tdtg4.EXE. LOG: Attempting to download a new file URL: /// C: /Users/stassis/Documents/Development/theDreamBox/bin/App_Web_oq2tdtg4.EXE. LOG: Attempting to download a new file URL: /// C: /Users/stassis/Documents/Development/theDreamBox/bin/App_Web_oq2tdtg4/App_Web_oq2tdtg4.EXE.///C:/Users/stassis/Documents/Development/theDreamBox/bin/App_Web_oq2tdtg4/App_Web_oq2tdtg4.DLL. LOG: Attempting to download a new file URL: /// C: / Users / stassis / AppData / Local / Temp / Temporary ASP.NET Files / root / 87ef3319 / ec80b2f5 / App_Web_oq2tdtg4.EXE. LOG: Attempting to download a new file URL: /// C: / Users / stassis / AppData / Local / Temp / Temporary ASP.NET Files / root / 87ef3319 / ec80b2f5 / App_Web_oq2tdtg4 / App_Web_oq2tdtg4.EXE. LOG: Attempting to download a new file URL: /// C: /Users/stassis/Documents/Development/theDreamBox/bin/App_Web_oq2tdtg4.EXE. LOG: Attempting to download a new file URL: /// C: /Users/stassis/Documents/Development/theDreamBox/bin/App_Web_oq2tdtg4/App_Web_oq2tdtg4.EXE.///C:/Users/stassis/Documents/Development/theDreamBox/bin/App_Web_oq2tdtg4/App_Web_oq2tdtg4.DLL. LOG: Attempting to download a new file URL: /// C: / Users / stassis / AppData / Local / Temp / Temporary ASP.NET Files / root / 87ef3319 / ec80b2f5 / App_Web_oq2tdtg4.EXE. LOG: Attempting to download a new file URL: /// C: / Users / stassis / AppData / Local / Temp / Temporary ASP.NET Files / root / 87ef3319 / ec80b2f5 / App_Web_oq2tdtg4 / App_Web_oq2tdtg4.EXE. LOG: Attempting to download a new file URL: /// C: /Users/stassis/Documents/Development/theDreamBox/bin/App_Web_oq2tdtg4.EXE. LOG: Attempting to download a new file URL: /// C: /Users/stassis/Documents/Development/theDreamBox/bin/App_Web_oq2tdtg4/App_Web_oq2tdtg4.EXE.NET Files / root / 87ef3319 / ec80b2f5 / App_Web_oq2tdtg4.EXE. LOG: Attempting to download a new file URL: /// C: / Users / stassis / AppData / Local / Temp / Temporary ASP.NET Files / root / 87ef3319 / ec80b2f5 / App_Web_oq2tdtg4 / App_Web_oq2tdtg4.EXE. LOG: Attempting to download a new file URL: /// C: /Users/stassis/Documents/Development/theDreamBox/bin/App_Web_oq2tdtg4.EXE. LOG: Attempting to download a new file URL: /// C: /Users/stassis/Documents/Development/theDreamBox/bin/App_Web_oq2tdtg4/App_Web_oq2tdtg4.EXE.NET Files / root / 87ef3319 / ec80b2f5 / App_Web_oq2tdtg4.EXE. LOG: Attempting to download a new file URL: /// C: / Users / stassis / AppData / Local / Temp / Temporary ASP.NET Files / root / 87ef3319 / ec80b2f5 / App_Web_oq2tdtg4 / App_Web_oq2tdtg4.EXE. LOG: Attempting to download a new file URL: /// C: /Users/stassis/Documents/Development/theDreamBox/bin/App_Web_oq2tdtg4.EXE. LOG: Attempting to download a new file URL: /// C: /Users/stassis/Documents/Development/theDreamBox/bin/App_Web_oq2tdtg4/App_Web_oq2tdtg4.EXE./Users/stassis/Documents/Development/theDreamBox/bin/App_Web_oq2tdtg4/App_Web_oq2tdtg4.EXE./Users/stassis/Documents/Development/theDreamBox/bin/App_Web_oq2tdtg4/App_Web_oq2tdtg4.EXE.

+3


source to share


3 answers


I'm not really sure, but you are linking both services to the same address, perhaps you changed the endpoint address for each service-implementation



<services>
 <service behaviorConfiguration="ServiceBehavior" name="Service">
   <endpoint address="a" binding="webHttpBinding"
       contract="IService" behaviorConfiguration="EndpBehavior"/>
 </service>
 <service behaviorConfiguration="ServiceBehavior" name="ServiceNew">
   <endpoint address="b" binding="webHttpBinding"
       contract="IServiceNew" behaviorConfiguration="EndpBehavior"/>
 </service>

      

+2


source


There is a bug that leads to similar behavior that you are observing. I don't know if this is the exact problem, but you can check this support page .



+1


source


I had the same problem with my service a few days ago See here

The problem was that I couldn't have an int services implementation in a single .config file.

When I posted this service, I had to specify ServiceHost

the implementation type, but since the tug was defined in the config file, it still throws an error.

My solution was to add one service from config and add another (to the other ServiceHost

) in C #

+1


source







All Articles