【发布时间】:2017-01-27 12:23:00
【问题描述】:
在我的应用程序中,在 LG G3 D855 上运行,我在启动时收到此错误,这通常发生在我的应用程序有一段时间没有启动时,总是在崩溃后重新启动它可以正常工作:
E/linker ( 2105): readlink('/proc/self/fd/28') failed: Permission denied [fd=28]
E/linker ( 2105): warning: unable to get realpath for the library "/vendor/lib/egl/eglsubAndroid.so". Will use given name.
E/mono ( 2105):
E/mono ( 2105): Unhandled Exception:
E/mono ( 2105): System.NullReferenceException: Object reference not set to an instance of an object
E/mono ( 2105): at Dictionary.Fragments.SearchFragment+<>c__DisplayClass13_0.<PerformSearch>b__0 (System.Object x) [0x00050] in <88db5ed5788f4131a4894bb5620511e9>:0
E/mono ( 2105): at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) [0x0000e] in <8552b98493c447d5a7a1f07bdaff39bb>:0
E/mono ( 2105): at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x0008d] in <8552b98493c447d5a7a1f07bdaff39bb>:0
E/mono ( 2105): at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <8552b98493c447d5a7a1f07bdaff39bb>:0
E/mono ( 2105): at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x0002a] in <8552b98493c447d5a7a1f07bdaff39bb>:0
E/mono ( 2105): at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00096] in <8552b98493c447d5a7a1f07bdaff39bb>:0
E/mono ( 2105): at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <8552b98493c447d5a7a1f07bdaff39bb>:0
这是失败的代码:
private void PerformSearch(string input) {
ThreadPool.QueueUserWorkItem( x => {
if ( _tranService == null )
_tranService = new TranslationService();
var translations = _tranService.Translate( input );
_transAdapter.Update( translations );
Activity.RunOnUiThread( () => _transAdapter.NotifyDataSetChanged() );
} );
}
请告诉我这是什么,这让我非常恼火。它也发生在我正在制作的另一个应用程序中,它使用相同类型的 ThreadPool.QueueUserWorkItem() 块。
我的安装:
Microsoft Visual Studio Professional 2015 版本 14.0.25431.01 更新 3 Microsoft .NET 框架版本 4.6.01586
安装版本:专业版
Microsoft Visual Studio 应用程序工具 2015
00322-40000-00000-AA309 适用于应用程序的 Microsoft Visual Studio 工具 2015Visual Basic 2015 00322-40000-00000-AA309 Microsoft Visual Basic 2015
Visual C# 2015 00322-40000-00000-AA309 Microsoft Visual C# 2015
Visual C++ 2015 00322-40000-00000-AA309 微软 Visual C++ 2015
适用于 Visual Studio 包 7.17.00119.9 的 Application Insights 工具 适用于 Visual Studio 的 Application Insights 工具
ASP.NET 和 Web 工具 2015.1 14.1.21111.0 ASP.NET 和 Web 工具 2015.1
ASP.NET Web 框架和工具 2012.2 4.1.41102.0 更多 信息,请访问http://go.microsoft.com/fwlink/?LinkID=309563
ASP.NET Web 框架和工具 2013 5.2.40314.0 更多 信息,请访问http://www.asp.net/
Azure 应用服务工具 v2.8.1 14.0.11123.0 Azure 应用服务工具 v2.8.1
命令总线、事件流和异步管理器 Merq 提供 ICommandBus、IEventStream 和 IAsyncManager MEF 服务用于松散 耦合 Visual Studio 扩展组件的通信和 整合。
Common Azure Tools 1.8 提供常用服务供 Azure 使用 移动服务和 Microsoft Azure 工具。
缩进指南 15 个缩进指南
在每个缩进级别添加视觉指南。
JavaScript 语言服务 2.0 JavaScript 语言服务
JavaScript 项目系统 2.0 JavaScript 项目系统
JetBrains ReSharper Ultimate 2016.2.2 Build 106.0.20160913.91321 适用于 Microsoft Visual Studio 的 JetBrains ReSharper Ultimate 包。为了 有关 ReSharper Ultimate 的更多信息,请访问 http://www.jetbrains.com/resharper。版权所有 © 2017 JetBrains, Inc.
Microsoft .NET Core 工具(预览版 2)14.1.21111.0 Microsoft .NET 核心工具(预览版 2)
Microsoft Azure 移动服务工具 1.4 Microsoft Azure 移动 服务工具
NuGet 包管理器 3.5.0 Visual Studio 中的 NuGet 包管理器。 有关 NuGet 的更多信息,请访问http://docs.nuget.org/。
PreEmptive Analytics Visualizer 1.2 Microsoft Visual Studio 扩展以可视化来自 PreEmptive 的聚合摘要 分析产品。
SQL Server 分析服务 13.0.1605.88 Microsoft SQL Server 分析服务设计器版本 13.0.1605.88
SQL Server 数据工具 14.0.60629.0 Microsoft SQL Server 数据工具
SQL Server 集成服务 Microsoft SQL Server 集成 服务设计器版本 13.0.1601.5
SQL Server 报告服务 13.0.1605.88 Microsoft SQL Server Reporting Services 设计器版本 13.0.1605.88
TypeScript 1.8.36.0 用于 Visual Studio 的 TypeScript 工具
Visual Studio Tools for Unity 2.8.0.0 Visual Studio Tools for Unity
Windows 安装程序 XML 工具集 3.10.2.2516 Windows 安装程序 XML 工具集版本 3.10.2.2516 版权所有 (c) Outercurve Foundation。全部 保留权利。
Xamarin 4.2.2.11 (00fa5cc) Visual Studio 扩展启用 Xamarin.iOS 和 Xamarin.Android 的开发。
Xamarin.Android 7.0.2.42 (501e63c) 启用 Visual Studio 扩展 为 Xamarin.Android 开发。
Xamarin.iOS 10.3.1.8 (7beaef4) Visual Studio 扩展启用 为 Xamarin.iOS 开发。
【问题讨论】:
-
你能单步执行该方法中的代码来尝试查看哪个对象为空吗?我的第一个想法是 _transAdapter,因为您没有对其进行空检查。也许不知何故 _transAdapter 正在被处理并且在恢复应用程序时没有重新创建?
-
@jgoldberger 的问题是,它发生在实际设备上启动时,间歇性地,我无法调试它。
-
也许可以尝试对 _transAdapter 进行空检查,看看是否有问题:
_transAdapter?.Update( translations );或if (_transAdapter != null) _transAdapter.Update( translations );
标签: multithreading xamarin xamarin.android threadpool