Note that there are some explanatory texts on larger screens.

plurals
  1. POasmx WebService insisting on methods it calls in other classes having nullable parameters
    primarykey
    data
    text
    <p>I was trying to simplify some code in a library shared between a winform and a webapp (written by someone else) by taking several methods/properties that were nullable, but for which nullable values were never passed in/nulls were never consumed into non-nullable ones. </p> <p>This worked fine in the winform app, and the webapp doesn't have any compile time problems but when I first ran it, it failed reporting an error that it couldn't find the old version of the method that took <code>DateTime?</code> parameters, despite the fact that the values being passed were non-nullable <code>DateTime</code>s. When I added back an overload with <code>DateTime?</code> parameters it worked only to generate an error elsewhere in the code due to a property that had been changed from <code>int?</code> to <code>int</code>. </p> <p>After confirming that an overload with <code>DateTime?</code> parameters would work as a fix, I commented the overload back out to try and figure out why it was insisting on calling that version. At some point while I was fiddling with it (doing forced rebuilds, etc), it suddenly stopped generating the errors even though I'd reverted the two .cs files to the version where they were initially failing. At this point it's working, but I have no idea what went wrong initially or how it was fixed, and I'm very leery of continuing on until I know what happened.</p> <p>Approximate error message (from memory): <code>Method not found: 'null NameSpace.StaticClass.StaticMethod( IFoo foo, IBar[] bar, DateTime? padStart, DateTime? padEnd )'.</code></p> <p>Actual error message: <code>Method not found: 'System.Nullable</code>1 NameSpace.OtherClass.get_Number()'.`</p> <p>Method in MyWebService.asmx:</p> <pre><code> [WebMethod( EnableSession = true )] public string DoStuff( string jsonFoo, string startDate, string endDate ) { try { IFoo foo = Deserialize&lt;IFoo&gt;( jsonFoo ); IBar[] bar = null; DateTime padStart = DateTime.Parse(startDate); DateTime padEnd = DateTime.Parse(endDate); StaticClass.StaticMethod( foo, bar, padStart, padEnd ); } } </code></pre> <p>Method in StaticClass:</p> <pre><code> public static void StaticMethod( IFoo foo, IBar[] bar, DateTime padStart, DateTime padEnd ) { } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload