NServiceBus is throwing ArgumentNullException in UnicastBus.IsInitializationMessage - nservicebus

I'm a bit perplexed by an issue I'm getting on a particular deployment, but not
on my build machine. This is a web application that is receiving NServiceBus events to keep
a persistent view model updated. There are events waiting in the services incoming MSMQ, so the
subscription seems to be working correctly, but the application isn't processing
them. The output I'm getting is shown below. Sorry for the mass of text; the
summary is that the logs point to UnicastBus.Address being Nothing at runtime.
Perhaps something is missing in my configuration.
Here are the logs:
[Worker.11] INFO NServiceBus.Unicast.UnicastBus [(null)] -
Common.Users.WebApp.DevTest initialized.
[10] INFO NServiceBus.Unicast.UnicastBus [(null)] - Subscribing to
Common.Users.Messages.Events.IAllUsersPublished, Common.Users.Messages,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null at publisher queue
Common.Users.MessageHandlers.DevTest
[10] INFO NServiceBus.Unicast.UnicastBus [(null)] - Subscribing to
Common.Users.Messages.Events.IAllUsersPublished, Common.Users.Messages,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null at publisher queue
Common.Users.MessageHandlers.DevTest
INFO NServiceBus.Unicast.UnicastBus [(null)] - Common.Users.WebApp.DevTest
initialized.
WARN NServiceBus.Unicast.Transport.Msmq.MsmqTransport [(null)] - Failed raising
'transport message received' event for message with
ID=537591b0-20e2-4ab9-aabc-b635c3d0e23c\3997
System.ArgumentNullException: Value cannot be null.
Parameter name: value
at System.String.IndexOf(String value, Int32 startIndex, Int32 count,
StringComparison comparisonType)
at NServiceBus.Unicast.UnicastBus.IsInitializationMessage(TransportMessage
msg) in
d:\code\nservicebus-src\src\unicast\NServiceBus.Unicast\UnicastBus.cs:line 1211
at NServiceBus.Unicast.UnicastBus.TransportMessageReceived(Object sender,
TransportMessageReceivedEventArgs e) in
d:\code\nservicebus-src\src\unicast\NServiceBus.Unicast\UnicastBus.cs:line 1056
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at
NServiceBus.Unicast.Transport.Msmq.MsmqTransport.OnTransportMessageReceived(Tran\
sportMessage msg) in
d:\code\nservicebus-src\src\impl\unicast\NServiceBus.Unicast.Msmq\MsmqTransport.\
cs:line 400
This last entry repeats for every message in the queue; the queue messages
remain in the queue.
So I checked out the source code IsInitializationMessage; here is the throwing
code:
private bool IsInitializationMessage(TransportMessage msg)
{
if (msg.ReturnAddress == null)
return false;
if (!msg.ReturnAddress.Contains(Address)) <<< THROWS
return false;
So it appears that UnicastBus.Address is Nothing. Not sure why this would be;
here are the NServiceBus configurations:
<MsmqTransportConfig
InputQueue="Common.Users.WebApp.DevTest"
NumberOfWorkerThreads="1"
MaxRetries="5"
ErrorQueue="Common.Users.WebApp.DevTest.Errors" />
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="Common.Users.Messages"
Endpoint="Common.Users.MessageHandlers.DevTest" />
</MessageEndpointMappings>
</UnicastBusConfig>
On Application_Start I'm using the following code to get NServiceBus started:
Dim bus = NServiceBus.Configure.WithWeb() _
.Log4Net() _
.StructureMapBuilder() _
.XmlSerializer() _
.MsmqTransport() _
.UnicastBus().LoadMessageHandlers() _
.CreateBus()
bus.Start()

I changed the identity that the web application's app pool was using from defaultapppool to NETWORK SERVICE. On next startup the web app reported the same error. It restarted again an hour later and the problem went away and the messages were all successfully processed. I don't know if the identity change fixed it, or if there was some other change that I'm not aware of. If it happens again or I learn more I'll try to post it here.

Related

Ektron: synchronization between two servers stopped

We have problem with Ektron synchronization between two servers.
It stopped couple days ago. We tried the “Pause/Resume” button, but that didn’t work.
Do you know where to look for errors and how to troubleshoot this problem?
Please advise.
Updates :
version Ektron 8.6.1
synchronization schedule : daily at 11PM
Restarted services on both machines.
Found error in C:\Program Files (x86)\Ektron\EktronWindowsService40\log\errors
Type : System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : The security identifier is not allowed to be the owner of this object.
Source : mscorlib
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Void Persist(System.String, System.Runtime.InteropServices.SafeHandle, System.Security.AccessControl.AccessControlSections, System.Object)
HResult : -2146233079
Stack Trace : at System.Security.AccessControl.NativeObjectSecurity.Persist(String name, SafeHandle handle, AccessControlSections includeSections, Object exceptionContext)
at System.Security.AccessControl.FileSystemSecurity.Persist(String fullPath)
at Ektron.FileSync.Common.FileSyncUtils.ChangePermissions(String filePath, String dirPath)
Stack Trace : at System.Security.AccessControl.NativeObjectSecurity.Persist(String name, SafeHandle handle, AccessControlSections includeSections, Object exceptionContext)
at System.Security.AccessControl.FileSystemSecurity.Persist(String fullPath)
at Ektron.FileSync.Common.FileSyncUtils.ChangePermissions(String filePath, String dirPath)
Severity: Error
Title:EktronWindowsServices Exception
Application Domain: Ektron.ASM.EktronServices40.exe
Process Id: 1568
Process Name: E:\Program Files (x86)\Ektron\EktronWindowsService40\Ektron.ASM.EktronServices40.exe

NserviceBus Hosted in IIS issue

I've been working on a project where I need Nservicebus to be hosted in IIS.
I need the MVC3 webapplication to send a message, a nservicebus host should handle this message
and then send back some sort of message to the webapplication.
the Async Pages example http://docs.particular.net/samples/web/asp-mvc-application/
shows one way of doing it. I can get this to work, however this does not fully furfill my requirements. I need an object to be returned from the handler, not just an int.
To get this to work i've tried setting up a host under IIS, in my Global.asax I've got this code:
Bus = Configure.WithWeb()
.DefineEndpointName("CQRS")
.Log4Net()
.DefaultBuilder()
.DisableTimeoutManager()
.XmlSerializer()
.MsmqTransport()
.IsTransactional(true)
.PurgeOnStartup(false)
.InMemorySubscriptionStorage()
.UnicastBus()
.AllowSubscribeToSelf()
.ImpersonateSender(false)
.LoadMessageHandlers()
.CreateBus().Start();
my web.config:
<MessageForwardingInCaseOfFaultConfig ErrorQueue="CQRS.error" />
<MsmqTransportConfig NumberOfWorkerThreads="1" MaxRetries="5" />
<UnicastBusConfig DistributorControlAddress="" DistributorDataAddress="" TimeoutManagerAddress="CQRS.timeouts">
<MessageEndpointMappings>
<add Messages="Nokavision.InvoiceProcessing.CQRS.Messages" Endpoint="CQRS" />
<add Messages="NServiceBus.Scheduling.Messages.ScheduledTask" Endpoint="CQRS" />
</MessageEndpointMappings>
</UnicastBusConfig>
Sending messages with the Bus object works perfectly, a message appears in the "cqrs" queue.
The handler within the webapplication however does not trigger. This is the code:
public class UpdateInkoopFactuurAlgemeenHandler : IHandleMessages<UpdateInkoopFactuurAlgemeenCommand>
{
public IBus Bus { get; set; }
public void Handle(UpdateInkoopFactuurAlgemeenCommand message)
{
P2PEntities entities = new P2PEntities();
var factuur = (from f in entities.Documenten.OfType<InkoopFactuur>()
where f.DocumentId == message.DTO.DocumentId
select f).FirstOrDefault();
if (factuur != null)
{
factuur.FactuurNummer = message.DTO.FactuurNummer;
entities.SaveChanges();
}
//Bus.Return(new UpdateInkoopFactuurAlgemeenResponse(message.DTO.ClientConnectionId));
}
}
I'm sure I'm missing something small here but what am I doing wrong, why doesn't the handler get triggered while I can clearly see a message in the queue.
Also on the Bus object I can see the handler being loaded.
If you configure installer correctly in your fluent configuration then NSB sets the rights on the queue properly.
http://andreasohlund.net/2012/01/26/installers-in-nservicebus-3-0/
Ok, I think I figured it out, it seems that the queue's created by NSB dont have full access permissions for the IIS USER. I've set "full control" for everyone on each of the queue's and restarted IIS. Somehow it seems to work now

wcf linq to sql error

I am getting an error returning a linq query over http to an ASP.Net application
I have the following wcf service running in IIS
public class ProductService : IProductService
{
NorthwindEntities context = new NorthwindEntities();
public List<Customer> GetCustomers()
{
return context.Customers.Select(c => c).ToList();
}
}
Web Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
</system.web>
<system.serviceModel>
<services>
<service name="WCF_Entity.ProductService">
<endpoint address="" binding="wsHttpBinding" contract="WCF_Entity.IProductService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<connectionStrings>
<add name="NorthwindEntities" connectionString="metadata=res://*/Northwind.csdl|res://*/Northwind.ssdl|res://*/Northwind.msl;provider=System.Data.SqlClient;provider connection string="Data Source=SHLOMOKATZ-PC;Initial Catalog=Northwind;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
I created a ASP.Net application to use the service
myService.ProductServiceClient objService = new ProductServiceClient();
var customers = objService.GetCustomers();
on debuging, I get the following error
An existing connection was forcibly closed by the remote host
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
Source Error:
Line 2454:
Line 2455: public ASPWFC.myService.Customer[] GetCustomers() {
Line 2456: return base.Channel.GetCustomers();
Line 2457: }
Line 2458: }
Source File: D:\My Documents\Visual Studio 2010\Projects\wcf\WCF_Entity\ASPWFC\Service References\myService\Reference.cs Line: 2456
Stack Trace:
[SocketException (0x2746): An existing connection was forcibly closed by the remote host]
System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) +6132200
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +134
[IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.]
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +300
System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) +26
System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) +265
[WebException: The underlying connection was closed: An unexpected error occurred on a receive.]
System.Net.HttpWebRequest.GetResponse() +6038435
System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +103
[CommunicationException: An error occurred while receiving the HTTP response to http://localhost/WCF_Entity_SVC/ProductService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +9464367
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +345
ASPWFC.myService.IProductService.GetCustomers() +0
ASPWFC.myService.ProductServiceClient.GetCustomers() in D:\My Documents\Visual Studio 2010\Projects\wcf\WCF_Entity\ASPWFC\Service References\myService\Reference.cs:2456
ASPWFC._Default.Page_Load(Object sender, EventArgs e) in D:\My Documents\Visual Studio 2010\Projects\wcf\WCF_Entity\ASPWFC\Default.aspx.cs:36
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +37
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +95
System.Web.UI.Control.OnLoad(EventArgs e) +145
System.Web.UI.Control.LoadRecursive() +134
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3412
changing the buffer length, etc... Didn't solve the issue. The database is the sample NorthWind database
I am able to browse to the service
It seems that Aliostad is correct as I recreated the service without using IIs and used ASP to consume the service, and get the below error. So it is a problem invoking the svc from the app, I can still run the service directly via http
The underlying connection was closed: The connection was closed unexpectedly.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly.
Source Error:
Line 2337:
Line 2338: public NorthwindApp.myService.Customer[] getCustomers() {
Line 2339: return base.Channel.getCustomers();
Line 2340: }
Line 2341: }
Source File: d:\my documents\visual studio 2010\Projects\wcf\NorthwindServices\NorthwindApp\Service References\myService\Reference.cs Line: 2339
Stack Trace:
[WebException: The underlying connection was closed: The connection was closed unexpectedly.]
System.Net.HttpWebRequest.GetResponse() +6038435
System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +51
[CommunicationException: The underlying connection was closed: The connection was closed unexpectedly.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +9464367
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +345
NorthwindApp.myService.INorthwindService.getCustomers() +0
NorthwindApp.myService.NorthwindServiceClient.getCustomers() in d:\my documents\visual studio 2010\Projects\wcf\NorthwindServices\NorthwindApp\Service References\myService\Reference.cs:2339
NorthwindApp._Default.Page_Load(Object sender, EventArgs e) in d:\my documents\visual studio 2010\Projects\wcf\NorthwindServices\NorthwindApp\Default.aspx.cs:18
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +46
System.Web.UI.Control.OnLoad(EventArgs e) +83
System.Web.UI.Control.LoadRecursive() +120
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3954
I found an article that says that with entity framework 4 there is a problem to serialize entities in wcf with lazy loading enabled
I added the following code to the service and everything works
context.ContextOptions.LazyLoadingEnabled = false;
link to article http://geekswithblogs.net/danemorgridge/archive/2010/05/04/entity-framework-4-wcf-amp-lazy-loading-tip.aspx
How many records are being returned? There are a couple of things in play here:
From a WCF Perspective:
MaxBufferSize: Gets or sets the maximum size of the buffer to use. For buffered messages this value is the same as MaxReceivedMessageSize. For streamed messages, this value is the maximum size of the SOAP headers, which must be read in buffered mode. For a non-streamed message, if the message size is greater than this property, then the message is dropped.
If not specified, this defaults to 65536.
This is only 0.0625 megabytes!
MaxReceivedMessageSize: Gets and sets the maximum allowable message size that can be received.
Default here is also 65536 bytes.
MaxStringContentLength: Gets and sets the maximum string length returned by the reader.
Your service is probably returning a value greater in size than the defaults.
So, you could try modifying your service behavior to include these attributes with higher limits, say 6 MB or so to see if it resolves your issue.
Also - remember there is maxRequestLength limit which is enforced by IIS which trumps any WCF setting, the default is 4096 KB, so you may have to tweak that if you alter the above properties.

404 Error when TFS 2010 Sends SOAP Alert to a WCF 4.0 Service

I'm trying to write a WCF 4.0 service that will receive SOAP alerts from TFS 2010. Here is my service contract:
[ServiceContract(Namespace = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03")]
public interface IService1
{
[OperationContract(Action = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03/Notify")]
[XmlSerializerFormat(Style = OperationFormatStyle.Document)]
void Notify(string eventXml, string tfsIdentityXml);
}
I am using this binding configuration for my service endpoint:
<bindings>
<wsHttpBinding>
<binding name="noSecurity">
<security mode="None"/>
</binding>
</wsHttpBinding >
</bindings>
Having registered a TFS alert using BISSUBSCRIBE.EXE and pointed it to my service, every time it is triggered my service is not invoked and instead I see the following in the TfsJobAgent log:
Notification not delivered.
Notification: WorkItemChangedEvent (DeliveryType: Soap; Address: http://192.168.10.10/TrafficLight/Service1.svc)
Exception: Microsoft.TeamFoundation.TeamFoundationServiceUnavailableException: Team Foundation services are not available from server http://192.168.10.10/TrafficLight/Service1.svc. Technical information (for administrator):
HTTP code 404: Not Found ---> System.Net.WebException: The remote server returned an error: (404) Not Found.
at System.Net.HttpWebRequest.GetResponse()
at Microsoft.TeamFoundation.Client.TeamFoundationClientProxyBase.AsyncWebRequest.ExecRequest(Object obj)
--- End of inner exception stack trace ---
at Microsoft.TeamFoundation.Client.TeamFoundationClientProxyBase.ProcessHttpResponse(HttpWebResponse response, Stream responseStream, WebException webException, XmlReader& xmlResponseReader)
at Microsoft.TeamFoundation.Client.TeamFoundationClientProxyBase.ExecWebServiceRequest(HttpWebRequest request, XmlWriter requestXml, String methodName, HttpWebResponse& response)
at Microsoft.TeamFoundation.JobService.Extensions.Core.TeamFoundationNotificationClient.Notify(String eventXml, String tfsIdentityXml, Subscription subscription)
at Microsoft.TeamFoundation.JobService.Extensions.Core.NotificationJobExtension.SendSoapNotification(TeamFoundationRequestContext requestContext, TeamFoundationNotification notification, TeamFoundationIdentityService identityService)
(This is taken from the [Tfs_Configuration].[dbo].[tbl_JobHistory] table of my TFS 2010 installation)
Oddly enough, when I try my service's URL in internet explorer on the same machine where the TfsJobAgent is running, I receive the standard "You have created a service." web page auto-generated by WCF and not a 404 error.
At last, my question: Why is the TFS Job Agent receiving a 404 error from my service which seems to be properly configured? How can I resolve this issue?
Update: I've tried rewriting my service as an ASMX web service and it's working well. Below is the implementation. I still want to learn how to achieve the same using WCF 4.0 so any help would be greatly appreciated.
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class WebService1 : System.Web.Services.WebService
{
[SoapDocumentMethod("http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03/Notify", RequestNamespace = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03")]
[WebMethod]
public void Notify(string eventXml, string tfsIdentityXml)
{
// log incoming event...
}
I have created this succesfully - http://www.ewaldhofman.nl/post/2010/08/02/How-to-use-WCF-to-subscribe-to-the-TFS-2010-Event-Service-rolling-up-hours.aspx - and it seems that you are using the same steps.
Did you also specify the wsHttpBinding for the endpoint?

Catches communication exception instead of custom fault exception - WCF

On Server I'm throwing the exception like this.
catch(SqlException exception)
{
if (exception.Message.Contains("Custom error from stored proc"))
{
//Exception to be thrown when authentication fails.
throw new FaultException<MyServiceFault>(new MyServiceFault { MessageText = exception.Message });
}
}
And on client end I'm catching the exception
catch(FaultException<MyServiceFault> faultException)
{
}
Here is my MyServiceFault
[DataContract]
public class MyServiceFault
{
[DataMember]
public string MessageText { get; set; }
[DataMember]
public Guid Id { get; set; }
}
The problem is that on client, it doesn't go to MyServiceFault catch block instead it goes to communication exception catch block and throws this error
System.ServiceModel.CommunicationException: The underlying connection was closed: The connection was closed unexpectedly. ---> System.Net.WebException
I've also decorated my service method [FaultContract(typeof(MyServiceFault))] in the interface which is implemented by my service.
In my web.config servicebehaviour tag consist
<serviceDebug includeExceptionDetailInFaults="true" />
Any idea where I'm going wrong.
This problem is occurring on windows 7. Can there be a reason related to it?
IMPORTANT UPDATE
According to answerers, any unhandled exception on the server can cause throwing of the Communication exception on the client side and it may not have anything to do with the custom fault exception you have thrown on the server. So the solution is log the errors on the server and find what error is causing this behavior. Here is a very useful open source logging functionality I found and implemented which can even be more useful after your project goes into production environment. Many thanks to the answerers.
A better way of logging exceptions in WCF
Add logging to your WCF calls by including this in your app.config.
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing">
<listeners>
<add name="sdt" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\LogPath\LogFile.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
(You can do this for both server and client, obviously specifying different log files)
Once you've generated some logs, look through for exceptions or warnings. I often find this produces some very useful information that helps me solve WCF problems.
To read the log file, you'll need to use SvcTraceViewer.exe. Unfortunately the only way to get this is with the windows SDK which is a bit of a big download for one tiny little tool.
It's also worth bearing in mind that WCF can through the CommunctionException when it is being closed, and this is expected behaviour. You shouldn't just do using with client WCF comm channels. Instead, you should follow a pattern like this:
try{
x.Close()
}
catch(Comms ex){
x.Abort()
}
One thing i learned from working with wcf is that the error CommunicationException is thrown alot of times. It is even possible that the error you get has nothing to do with the Exception you throw, but with something else causing it. At the moment something is being sent between a client and server, it's hard to track down what is causing the exception.
I could solve some of my issues by adjusting some settings in the app.config. Setting timeout, etc...
Maybe that can help?
As a follow-up, one reason for getting CommunicationException is that the FaultException could not be serialized correctly. In the log (see Simon's answer on how to set up logging), this would show up as "Handling exception" followed by "Replying to an operation threw an exception".
In my case, this was caused by not initializing an enumeration value:
[DataContract]
public class MyCustomWebServiceFault
{
public MyCustomWebServiceFault()
{
}
[DataMember]
public EMyCustomWebServiceFaultReason Reason { get; set; }
[...]
The log then revealed it:
Enum value '0' is invalid for type 'EMyCustomWebServiceFaultReason' and cannot be serialized. Ensure that the necessary enum values are present and are marked with EnumMemberAttribute attribute if the type has DataContractAttribute attribute.
Long story short, use logging or unit test exception serialization.