Esri / arcgis-maps-sdk-dotnet-samples

Sample code for ArcGIS Maps SDK for .NET – WPF, WinUI, .NET MAUI
Apache License 2.0
415 stars 518 forks source link

Method Name Expected: authorizeOnUIAction = new Action((() ... O_o #224

Closed SierraMultimedia closed 7 years ago

SierraMultimedia commented 7 years ago

On Win 7 x64 in VS13, I opened, restored NuGet packs, and cleaned the solution. However, build yielded the following error.

Error 4 Method name expected ~\arcgis-runtime-samples-dotnet-master\src\WPF\ArcGISRuntime.WPF.Samples\Samples\Map\AuthorMap\AuthorMap.xaml.cs 435 54 ArcGISRuntime.WPF.Samples.CSharp

AuthorMap.xaml.cs lines 429-437:

            var dispatcher = Application.Current.Dispatcher;
            if (dispatcher == null || dispatcher.CheckAccess())
                AuthorizeOnUIThread(_authorizeUrl);
            else
            {
                var authorizeOnUIAction = new Action((() => AuthorizeOnUIThread(_authorizeUrl)));
                dispatcher.BeginInvoke(authorizeOnUIAction);
            }

Suggestions?

Thanks for considering,

Matthew

SierraMultimedia commented 7 years ago

Is this the else content and Action(lambda) syntax the original developer intended?

            else
            {
                var authorizeOnUIAction = new Action(() => AuthorizeOnUIThread(_authorizeUrl));
                dispatcher.BeginInvoke(authorizeOnUIAction);
            }

I'm going to try it and let you know, though I am not certain how I am going to invoke this OAuth condition. Maybe it happens the first time I make a map action O_o Oh, well: it's worth a shot. :+1:

Persistently,

Matthew

ThadT commented 7 years ago

@SierraMultimedia Thanks Matthew! Strange, I don't get that error on my end, but I can see that the lambda has a superfluous set of parentheses. I'm running on Win10 with VS 15, perhaps a newer version of the .NET framework doesn't raise the exception? Did removing the parentheses solve the problem (I've made that update in the code regardless)?

SierraMultimedia commented 7 years ago

@ThadT

Thad, it worked like a charm - immediately! So far, no other issues have revealed themselves. BTW: my VS13 Pro is a trusty leftover from my C++ college days. I found the following page's .NET-environment exclusivity disclaimer under Lambda especially informative.

http://msdn.microsoft.com/en-us/library/bb397687.aspx

I think something in the CLR was trying to find parenthetic pairs to arrange priorities for completing nested commands. It appears to have misinterpreted the lambda as an empty pair of parenthesis (<-- that's only kind of a joke, sort of...). Don't you follow all your integers with a decimal point?!? After 40 years of coding, this is the first time I have seen an extra pair of parenthesis generate an error.

All's well that ends well. :+1: :grinning: