Search code examples
c#dynamics-crm

i have error while create CRM app


[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MyPage : ContentPage
{
    AuthenticationResult authResult;
    private OrganizationDataWebServiceProxy proxy;
    public MyPage()
    {
        InitializeComponent();
        myButton.Clicked += MyButton_Clicked;

        proxy = new OrganizationDataWebServiceProxy();
    }
    async void MyButton_Clicked(object sender, EventArgs args)
    {
        try
        {
            var auth = DependencyService.Get<IAuthenticator>();
           authResult = await auth.Authenticate(Constants.Authority,

            Constants.ServiceURL,

            Constants.ClientId,

            Constants.RedirectURL,

            Constants.Username,

            Constants.Password);
        }
        catch(Exception ex)
        {

            await DisplayAlert("Error", "This: " + ex, "got it");
        }

        proxy.ServiceUrl = Constants.ServiceURL;

        proxy.AccessToken = authResult.AccessToken;

        await GetLoggedInUserName();

    }
    public async Task GetLoggedInUserName()
    {
        try
        {
            WhoAmIResponse result = (WhoAmIResponse)await proxy.Execute(new WhoAmIRequest());

            await DisplayAlert("Result \n", "User Id : " + result.UserId.ToString() + "\n OrganizationId: " + result.OrganizationId.ToString() + "\n BusinessUnitId: " + result.BusinessUnitId.ToString(), "Ok", "Cancel");

        }
        catch (Exception ex)
        {

            await DisplayAlert("Error", "This: " + ex, "got it");
        }
    }

}

}

And i get this error message
1.The name lt doesnt exist in the current text
2.The name amp doesnt exist in the current text
3.The name gt doesnt exist in the current text
4.IAuthenticator is a type which isnt valid in the given context
somebody please help me, i was about to make crm app with xamarin.forms from this tutorial http://scaleablesolutions.com/connecting-xamarin-form-application-with-dynamics-crm/


Solution

  • Author of that tutorial has some errors in code due to HTML encoding, and you copied that error.

    Change line

    var auth = DependencyService.Get<IAuthenticator>();
    

    Into

    var auth = DependencyService.Get<IAuthenticator>();