0

I have a .NET project that I have inherited, in which I'm having issues getting a service to return properly when running on Windows Server IIS.

The ExceptionType is System.NullReferenceException

The Stacktrace is at Integra.HLX.SB.Web.WS_Reps..ctor() at CreateIntegra.HLX.SB.Web.WS_Reps() at System.ServiceModel.InstanceContext.GetServiceInstance(Message message) at System.ServiceModel.Dispatcher.InstanceBehavior.EnsureServiceInstance(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

This error gets thrown when I attempt to POST to the service's endpoint. I'm assuming I'm missing something within the web.config to allow this to work on IIS from a Windows Server, or maybe missing a feature setting within IIS on Windows Server.

Here is the relevant web.config settings...

<system.serviceModel> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> <bindings> <webHttpBinding> <binding name="binding1"> <security mode="Transport" /> </binding> </webHttpBinding> </bindings> <behaviors> <endpointBehaviors> <behavior name="Integra.HLX.SB.Web.WS_RepsAspNetAjaxBehavior"> <enableWebScript /> </behavior> <behavior name="Integra.HLX.SB.Web.WS_ClientContactsAspNetAjaxBehavior"> <enableWebScript /> </behavior> <behavior name="Integra.HLX.SB.Web.WS_ContactUniverseNameAddressesAspNetAjaxBehavior"> <enableWebScript /> </behavior> <behavior name="Integra.HLX.SB.Web.WS_UsersAspNetAjaxBehavior"> <enableWebScript /> </behavior> <behavior name="jsonBehavior"> <webHttp /> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior name="RESTbehavior"> <serviceMetadata httpGetEnabled="true" /> </behavior> <behavior> <serviceDebug includeExceptionDetailInFaults="true"/> </behavior> </serviceBehaviors> </behaviors> <services> <service name="Integra.HLX.SB.Web.WS_Reps"> <endpoint address="" behaviorConfiguration="Integra.HLX.SB.Web.WS_RepsAspNetAjaxBehavior" bindingConfiguration="binding1" binding="webHttpBinding" contract="Integra.HLX.SB.Web.WS_Reps" /> </service> <service name="Integra.HLX.SB.Web.WS_ClientContacts"> <endpoint address="" behaviorConfiguration="Integra.HLX.SB.Web.WS_ClientContactsAspNetAjaxBehavior" bindingConfiguration="binding1" binding="webHttpBinding" contract="Integra.HLX.SB.Web.WS_ClientContacts" /> </service> <service name="Integra.HLX.SB.Web.WS_ContactUniverseNameAddresses"> <endpoint address="" behaviorConfiguration="Integra.HLX.SB.Web.WS_ContactUniverseNameAddressesAspNetAjaxBehavior" bindingConfiguration="binding1" binding="webHttpBinding" contract="Integra.HLX.SB.Web.WS_ContactUniverseNameAddresses" /> </service> <service name="Integra.HLX.SB.Web.WS_Users"> <endpoint address="" behaviorConfiguration="Integra.HLX.SB.Web.WS_UsersAspNetAjaxBehavior" bindingConfiguration="binding1" binding="webHttpBinding" contract="Integra.HLX.SB.Web.WS_Users" /> </service> <service name="Integra.HLX.SB.Web.WS_SpeakerDataFeed" behaviorConfiguration="RESTbehavior"> <endpoint address="" bindingConfiguration="binding1" binding="webHttpBinding" behaviorConfiguration="jsonBehavior" contract="Integra.HLX.SB.Web.IWS_SpeakerDataFeed" /> </service> <service name="Integra.HLX.SB.Web.WS_DashboardDataFeed" behaviorConfiguration="RESTbehavior"> <endpoint address="" bindingConfiguration="binding1" binding="webHttpBinding" behaviorConfiguration="jsonBehavior" contract="Integra.HLX.SB.Web.IWS_DashboardDataFeed" /> </service> </services> </system.serviceModel>

Any help would be appreciated. Thanks!

Kevin Cherepski
  • 1,473
  • 8
  • 8
  • When the exception clearly gave you the call stack, I wonder what prevents you from debugging from there. You have to be more specific and share more details. There are far too many differences, https://blog.lextudio.com/web-application-differences-in-visual-studio-and-iis-60fec7e311b3 so you cannot ask others to guess for you. – Lex Li Feb 13 '20 at 02:33
  • I’ve attempted to use remote debugging, but I’m unable to add breakpoints to the service code (I believe it complains about symbols not being defined). I’m able to insert breakpoints in my web application source code and those breakpoints do get hit when using remote debugging. – Kevin Cherepski Feb 13 '20 at 13:50
  • https://stackoverflow.com/questions/151966/why-are-no-symbols-loaded-when-remote-debugging – Lex Li Feb 13 '20 at 15:10
  • @LexLi: Thanks for taking your time to look into this, but as I pointed out above, I am able to remote debug. If I build my application in debug mode, which builds all the .PDB files, and deploy that to my windows server, I'm able to successfully debug my web application source but I can't debug the service code which lives inside the App_Code directory of the project. – Kevin Cherepski Feb 13 '20 at 16:54
  • I fixed it. Apparently, the web.config was missing this line, `` I found out more information by checking the Windows Event Viewer logs and found this key bit of information `The service cannot be activated because it requires ASP.NET compatibility. ` which pointed me in the right direction. Just wish the original exception had more relevant information. – Kevin Cherepski Feb 13 '20 at 19:10
  • Then post your answer and accept it. – Lex Li Feb 13 '20 at 19:19

1 Answers1

0

I was able to answer my own question. The fix for me in this instance was the web.config on the production server was missing the line <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

I found out more information by checking the Windows Event Viewer logs and found this key bit of information The service cannot be activated because it requires ASP.NET compatibility.

After inserting the aforementioned line into the web.config and restarting the AppPool and server, the service started working properly. I hope this helps anybody in the future.

Kevin Cherepski
  • 1,473
  • 8
  • 8