gpt4 book ai didi

c# - Xamarin.Forms/iOS,出现异常, "You_Should_Not_Call_Base_In_This_Method"?

转载 作者:行者123 更新时间:2023-11-29 00:27:34 26 4
gpt4 key购买 nike

我有一个Xamarin.Forms项目并实现了第三方服务,Android部分几乎完美,但iOS部署不断抛出异常。我完全不知道这个异常,因为在代码中我在方法调用中获得了所有返回值。那么,我想知道什么是“基地”,我应该检查哪个地方?

这是一个异常(exception):

下面是抛出异常的代码部分:

void Join_Clicked(object sender, System.EventArgs e)
{
String channelName = this.Room_Name_Entry.Text;
if (channelName != null)
{
if (myEngine.AgoraJoinChannel(channelName) == 0)
{
this.VoiceStatus.Text = "You are in the channel!";
this.VoiceStatus.IsVisible = true;
this.Room_Join_Button.IsEnabled = false;
}
else
{
this.VoiceStatus.Text = "You are not in the channel!";
this.VoiceStatus.IsVisible = true;
}
}
else
{
this.VoiceStatus.Text = "Please set the room's name!";
this.VoiceStatus.IsVisible = true;
}
}

这是特定于平台的实现:

using System;
using DT.Xamarin.Agora;
using TabbedPageTest.iOS;

[assembly: Xamarin.Forms.Dependency(typeof(AgoraVoiceImplement_iOS))]
namespace TabbedPageTest.iOS
{
public class AgoraVoiceImplement_iOS : IAgora
{
AgoraRtcEngineKit myEngine;
AgoraRtcEngineDelegate myDelegate;

public AgoraVoiceImplement_iOS()
{
myDelegate = new AgoraRtcEngineDelegate();
myEngine = AgoraRtcEngineKit.SharedEngineWithAppIdAndDelegate("6de68f576fda42ca92a791b38383fee8", myDelegate);
}

public int AgoraJoinChannel(string Channel_Name)
{
myEngine.SetChannelProfile(AgoraRtcChannelProfile.Communication);
return myEngine.JoinChannelByKey(null, Channel_Name, "", 0, (Foundation.NSString arg1, nuint arg2, nint arg3) =>
{
myDelegate.DidJoinChannel(myEngine, arg1, arg2, arg3);
});
}

public int AgoraLeaveChannel()
{
return myEngine.LeaveChannel((AgoraRtcStats obj) =>
{
myDelegate.DidLeaveChannelWithStats(myEngine, obj);
});
}
}
}

非常感谢!

最佳答案

您的代码中某处有一个委托(delegate),它为该委托(delegate)基实现接口(interface)/类,并调用基类实现。

Xamarin SDK 具有委托(delegate)基类的概念(由于 C# 的性质),但在带有协议(protocol)的实际 IOS SDK ObjC 上并非如此。因此,Xamarin 添加了此异常以在执行时对其进行标记,以找到将实现留空或添加自定义代码以处理委托(delegate)回调的位置。

在代码中搜索它或在调试器中添加 Break On Exception,它会在调用后停止。

关于c# - Xamarin.Forms/iOS,出现异常, "You_Should_Not_Call_Base_In_This_Method"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42664677/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com