Xamarin.forms Xamarin Android和自定义控件:无法激活实例
我正在为标记编辑创建自定义控件。我正在使用Xamarin.forms Xamarin Android和自定义控件:无法激活实例,xamarin.forms,xamarin.android,visual-studio-2019,Xamarin.forms,Xamarin.android,Visual Studio 2019,我正在为标记编辑创建自定义控件。我正在使用VisualStudio2019和Xamarin表单。它适用于UWP和iOS,但在Android中,我的本机渲染器有一个错误 System.NotSupportedException:无法从本机句柄0x7feca76624(密钥句柄0x95e8e41)激活Xamarin.Forms.Platform.Android.EntryRenderer类型的实例 输出为: 04-24 10:10:11.382 W/InputMethodManager(17644
VisualStudio2019
和Xamarin表单
。它适用于UWP
和iOS
,但在Android
中,我的本机渲染器有一个错误
System.NotSupportedException:无法从本机句柄0x7feca76624(密钥句柄0x95e8e41)激活Xamarin.Forms.Platform.Android.EntryRenderer类型的实例
输出为:
04-24 10:10:11.382 W/InputMethodManager(17644):startInputReason=4
04-24 10:10:11.415 I/HwSecImmHelper(17644):
MSSecurityInputMethodService为null 04-24 10:10:11.446
W/ResourceType(17644):获取的名称时没有包标识符
资源编号0x00000000 04-24 10:10:11.448 W/视图(17644):
DispatchProviderAutoFillStructure():未布局,忽略04-24
10:10:11.453输入/辅助结构(17644):扁平化最终辅助数据:
2444字节,包含1个窗口,10个视图04-24 10:10:12.379
I/zygote64(17644):执行部分代码缓存收集,代码=61KB,
data=54kb04-2410:10:12.379i/zygote64(17644):在代码缓存之后
收集,代码=61KB,数据=54KB 04-2410:10:12.379I/zygote64(17644):
将代码缓存容量增加到256KB 04-24 10:10:14.160
W/zygote64(17644):JNI注册活动方法:尝试注册0
md58432a647068b097f9637064b8985a5e0.FrameRenderer的本机方法
04-24 10:10:14.220 W/InputMethodManager(17644):startInputReason=4
04-24 10:10:14.259 W/InputMethodManager(17644):startInputReason=4
04-24 10:10:14.260 I/zygote64(17644):编译器为
编译void android.view.view.(android.content.Context,
android.util.AttributeSet,int,int)04-2410:10:14.263
W/InputMethodManager(17644):startInputReason=304-2410:10:14.284
I/HwSecImmHelper(17644):mSecurityInputMethodService为null 04-24
10:10:14.379 I/zygote64(17644):执行完整代码缓存收集,
代码=108KB,数据=98KB 04-24 10:10:14.380 I/zygote64(17644):在代码之后
缓存收集,代码=101KB,数据=74KB 04-2410:10:14.568d/Mono(17644):加载Mono.Android.dll asmctx DEFAULT的参考6, 正在查找System.Runtime.Serialization,版本=2.0.5.0, 文化=中性,公钥令牌=7cec85d7bea7798e 04-24 10:10:14.570 D/Mono(17644):图像添加参考 System.Runtime.Serialization[0x7e53d21780](asmctx默认)-> System.Runtime.Serialization.dll[0x7e51894800]:2mono\u pe\u文件\u映射: 打开文件System.Runtime.Serialization.dll(3)时出错:没有此类文件 或目录 04-24 10:10:14.570 D/Mono(17644):准备安装组件 “System.Runtime.Serialization”(System.Runtime.Serialization.dll) 04-24 10:10:14.570 D/Mono(17644):装配 System.Runtime.Serialization[0x7e53d21780]已添加到域根域, 参考计数=104-2410:10:14.572 D/单声道(17644):AOT:图像 找不到“System.Runtime.Serialization.dll.so”:dlopen失败: 找不到库“System.Runtime.Serialization.dll.so”04-24 10:10:14.572 D/单声道(17644):AOT:图像 “/Users/builder/jenkins/workspace/xamarin-android-d16-0/xamarin-android/external/mono/sdks/out/android-arm64-v8a-release/lib/mono/aot cache/arm64/System.Runtime.Serialization.dll.so”未找到:dlopen失败:库 “/Users/builder/jenkins/workspace/xamarin-android-d16-0/xamarin-android/external/mono/sdks/out/android-arm64-v8a-release/lib/mono/aot cache/arm64/System.Runtime.Serialization.dll.so”未找到04-24 10:10:14.572 D/mono(17644):配置尝试 解析:“System.Runtime.Serialization.dll.config”。04-24 10:10:14.572 D/Mono(17644):试图解析的配置: “/Users/builder/jenkins/workspace/xamarin-android-d16-0/xamarin-android/external/mono/sdks/out/android-arm64-v8a-release/etc/mono/assemblems/System.Runtime.Serialization/System.Runtime.Serialization.config”。 04-24 10:10:14.572 D/Mono(17644):装配参考添加参考 Mono.Android[0x7e56659a80]-> 系统运行时序列化[0x7e53d21780]:204-24 10:10:14.573 D/Mono(17644):加载参考0 System.Runtime.Serialization.dll asmctx DEFAULT,查找mscorlib, 版本=2.0.5.0,区域性=中性,PublicKeyToken=7cec85d7bea7798e 04-24 10:10:14.573 D/Mono(17644):装配参考添加参考 System.Runtime.Serialization[0x7e53d21780]>mscorlib[0x7e77dc3c80]: 40加载的程序集:System.Runtime.Serialization.dll[外部] 未处理的异常: System.NotSupportedException:无法激活类型的实例 来自本机句柄的Xamarin.Forms.Platform.Android.EntryRenderer 0x7feca76624(钥匙手柄0x95e8e41) 组件将运行时添加到
布局中的新条目中。
这也是我对Android的期望
我的组件的完整源代码已打开。重要的部分在这里:
public class TagEntryView : Layout<View>, IDisposable
{
TagEntry TagEntry;
public TagEntryView()
{
PropertyChanged += TagEntryViewPropertyChanged;
PropertyChanging += TagEntryViewPropertyChanging;
TagEntry = new TagEntry();
TagEntry.TextChanged += TagEntryTextChanged;
Children.Add(TagEntry);
}
void TagEntryTextChanged(object sender, TextChangedEventArgs e)
{
if (TagSeparators != null)
{
if (TagSeparators.Any(e.NewTextValue.Contains))
{
string tag = e.NewTextValue;
foreach (var item in TagSeparators)
{
tag = tag.Replace(item, string.Empty);
}
if (TagValidatorFactory != null)
{
var tagBindingContext = TagValidatorFactory(tag);
var tagEntry = sender as Entry;
if (tagBindingContext != null)
{
TagItems.Add(tagBindingContext);
tagEntry.Text = string.Empty;
}
else
{
tagEntry.Text = tag;
}
tagEntry.Focus();
}
}
}
}
}
public类TagEntryView:Layout,IDisposable
{
标记语;
公共TagEntryView()
{
PropertyChanged+=TagEntryViewPropertyChanged;
PropertyChange+=TagentryViewPropertyChange;
TagEntry=新的TagEntry();
TagEntry.TextChanged+=TagEntryTextChanged;
添加(标记项);
}
void TagEntryTextChanged(对象发送方,textchangedventargs e)
{
if(标记分隔符!=null)
{
if(TagSeparators.Any(例如NewTextValue.Contains))
{
字符串标记=e.NewTextValue;
foreach(标记分隔符中的变量项)
{
tag=tag.Replace(item,string.Empty);
}
如果(TagValidatorFactory!=null)
{
var tagBindingContext=TagValidatorFactory(标记);
var tagEntry=发送方作为条目;
if(tagBindingContext!=null)
{
添加(tagBindingContext);
tagEntry.Text=string.Empty;
}