Bug 19411 - WCF NullReferenceException in Release Build. Works in Debug.
Summary: WCF NullReferenceException in Release Build. Works in Debug.
Status: RESOLVED DUPLICATE of bug 18259
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 4.12.2
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Alex Rønne Petersen
URL:
Depends on:
Blocks:
 
Reported: 2014-04-30 07:45 UTC by jimm@tbsmobility.com
Modified: 2014-05-01 04:35 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test Project Showing WCF Crash (16.92 KB, application/octet-stream)
2014-04-30 07:45 UTC, jimm@tbsmobility.com
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 18259

Description jimm@tbsmobility.com 2014-04-30 07:45:54 UTC
Created attachment 6681 [details]
Test Project Showing WCF Crash

Hi Chaps.

We've discovered an error that doesn't show up in a Debug build but throws a NullReferenceException in release builds when  calling a WCF proxy class. The error only seems to show when the linking option is set to "Sdk and User Assemblies" or "Sdk Assemblies Only". When set to "None" it works ok like it does in a Debug build.

The service call function takes 2 parameters and has a return type of a structure containing info from the server. I'm not sure if that is an important detail that trigger this error.

The text of the exception in a release build is as follows:

----------------------------------------------
Exception: System.NullReferenceException
Error calling service: Object reference not set to an instance of an object
System.NullReferenceException: Object reference not set to an instance of an object
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel..ctor (System.ServiceModel.Dispatcher.ClientRuntime runtime, System.ServiceModel.Description.ContractDescription contract, TimeSpan openTimeout, TimeSpan closeTimeout, IChannel contextChannel, IChannelFactory factory, System.ServiceModel.Channels.MessageVersion messageVersion, System.ServiceModel.EndpointAddress remoteAddress, System.Uri via) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel..ctor (System.ServiceModel.Description.ServiceEndpoint endpoint, System.ServiceModel.ChannelFactory channelFactory, System.ServiceModel.EndpointAddress remoteAddress, System.Uri via) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.ClientBase`1+ChannelBase`1[XamarinWcfCrash.TestService.ITMSession,XamarinWcfCrash.TestService.ITMSession].get_Inner () [0x
  at System.ServiceModel.ClientBase`1+ChannelBase`1[XamarinWcfCrash.TestService.ITMSession,XamarinWcfCrash.TestService.ITMSession].BeginInvoke (System.String methodName, System.Object[] args, System.AsyncCallback callback, System.Object state) [0x00000] in <filename unknown>:0 
  at XamarinWcfCrash.TestService.TMSessionClient+TMSessionClientChannel.BeginLogin (System.String userName, System.String password, System.AsyncCallback callback, System.Object asyncState) [0x00000] in <filename unknown>:0 
  at XamarinWcfCrash.TestService.TMSessionClient.XamarinWcfCrash.TestService.ITMSession.BeginLogin (System.String userName, System.String password, System.AsyncCallback callback, System.Object asyncState) [0x00000] in <filename unknown>:0 
  at XamarinWcfCrash.TestService.TMSessionClient.OnBeginLogin (System.Object[] inValues, System.AsyncCallback callback, System.Object asyncState) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.ClientBase`1[XamarinWcfCrash.TestService.ITMSession].InvokeAsync (System.ServiceModel.BeginOperationDelegate beginOperationDelegate, System.Object[] inValues, System.ServiceModel.EndOperationDelegate endOperationDelegate, System.Threading.SendOrPostCallback operationCompletedCallback, System.Object userState) [0x00000] in <filename unknown>:0 
  at XamarinWcfCrash.TestService.TMSessionClient.LoginAsync (System.String userName, System.String password, System.Object userState) [0x00000] in <filename unknown>:0 
  at XamarinWcfCrash.TestService.TMSessionClient.LoginAsync (System.String userName, System.String password) [0x00000] in <filename unknown>:0 
  at XamarinWcfCrash.Activity1.ConnectToService_Click (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0 
----------------------------------------------

I've also included a test project built in VisualStudio 2010 that shows the error. This is just client code. If you need any definitions of classes from the server-code, just give me a shout.

The bug as detailed by the test app, exceptions in the main code that calls the service function and doesn't even get to the callback.

Hope this is enough info.

JimM

P.S. I've read the bug report here: https://bugzilla.xamarin.com/show_bug.cgi?id=18259 
and will try the work-around. At the bottom of the thread, there's a call to post a report if this bug still exists, so here it is.

P.P.S. I upgraded to the latest Xamarin.Android this morning using the XamarinInstaller.exe and the version in VS2010 reads 4.12.02001
Comment 1 Udham Singh 2014-04-30 14:10:50 UTC
I have checked this issue with sample attached in bug description and noticed the same behavior mentioned in bug description. To reproduce this issue I have followed the steps below :

1. Open the project attached in bug description.
2. Set linking option is set to "Sdk and User Assemblies" or "Sdk Assemblies Only".
3. Run the project in "Release" mode and click on the "Call WCF Service" button and see the exception text below the "Call WCF Service" button.
 
Screencast : http://www.screencast.com/t/ZPWW0CfXcy1

Environment Info:
Windows 8.1
VS 2013
Xamarin.Android 4.12.02001

Note : When we set linking option to "None" in release mode and run the project, then on click of "Call WCF Service" button observed that the same behavior like it does in a Debug build.
Comment 2 Alex Rønne Petersen 2014-04-30 21:41:57 UTC
This was fixed on XA master but unfortunately didn't make it into the 4.12 series. It'll be in 4.14.
Comment 3 Jonathan Pryor 2014-04-30 21:43:31 UTC
@JimM: This is bug #18259. The fix for Bug #18259 has not been released yet, as can be seen in the release notes:

http://docs.xamarin.com/releases/android/xamarin.android_4/xamarin.android_4.12/

This fix will be included in the 4.14 series.

*** This bug has been marked as a duplicate of bug 18259 ***
Comment 4 jimm@tbsmobility.com 2014-05-01 04:35:12 UTC
Thanks for the replies and knowing that it's already fixed.  The workaround in the other thread works a beaut.