创建CRM应用程序时出错

时间:2017-06-05 08:51:00

标签: c# dynamics-crm

[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");
        }
    }

}

}

我收到此错误消息
1.名称lt在当前文本中不存在
2.当前文本中不存在名称放大器
3.名称gt不存在于当前文本中
4.IAuthenticator是一种在给定的上下文中无效的类型 有人请帮助我,我正准备用本教程中的xamarin.forms创建crm应用程序http://scaleablesolutions.com/connecting-xamarin-form-application-with-dynamics-crm/

1 个答案:

答案 0 :(得分:2)

由于HTML编码,该教程的作者在代码中有一些错误,并且您复制了该错误。

更改行

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

var auth = DependencyService.Get<IAuthenticator>();
相关问题