本文介绍了在window phone sdk 8.0中创建窗口手机应用程序时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 不显示设计窗口电话 错误:=发生未处理的异常 System.NullReferenceException 对象引用未设置为对象的实例。 at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.WaitForCompletion(NestedCallContext nestedCallContext,BlockingCall call,WaitHandle timeoutSignal) at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.MarshalOutSynchronous(Action action, Int32 targetApartmentId,WaitHandle aborted,WaitHandle timeoutSignal) at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.MarshalOut(Action action,Int32 targetApartmentId,WaitHandle aborted,CallSynchronizationMode syncMode,WaitHandle timeoutSignal) at Microsoft。 Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalOut [TValue](RemoteHandle`1 targetObject,Action action,CallSynchronizationMode syncMode) at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalOut [TResult,TValue]( RemoteHandle`1 targetObject,Func`2 func,CallSynchronizationMode syncMode) at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerServi ce.CreateDesignerImpl(IHostSourceItem item,IHostTextEditor editor,RemoteCancellationToken remoteCancelToken) at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService。< > c__DisplayClass12。< Microsoft.Expression.DesignHost.IDesignerService.CreateDesigner > b__11(RemoteCancellationToken remoteToken) at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService.CallWithCancellation [TResult](CancellationToken cancelToken,Func 2 func at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService.Microsoft.Expression.DesignHost.IDesignerService.CreateDesigner(IHostSourceItem item,IHostTextEditor editor,CancellationToken cancelToken) at Microsoft.Expression.DesignHost .IsolatedDesignerService.IsolatedDesignerView.CreateDesignerV iewInfo(CancellationToken cancelToken) System.NullReferenceException 对象引用未设置为对象的实例。 服务器堆栈跟踪: at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.WaitForCompletion(NestedCallContext nestedCallContext,BlockingCall call,WaitHandle timeoutSignal) at Microsoft.Expression.DesignHost .Isolation.Remoting.STAMarshaler.MarshalIn(Action action,Int32 targetApartmentId) at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalIn(IRemoteObject targetObject,Action action) at Microsoft.Expression.DesignHost .Isolation.Remoting.ThreadMarshaler.MarshalIn [TResult](IRemoteObject targetObject,Func`1 func) at Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteDesignerService.Microsoft.Expression.DesignHost.Isolation.Remoting.IRemoteDesignerService.CreateDesigner (IRemoteHostSourceItem remoteItem,IRemoteHostTextEditor remoteEditor,IRemoteCancellationToken remoteToken) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md,Object [] args,Object s erver,Object []& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg) 异常重新抛出[0]:在System.Runtime.Remoting.Proxies。 RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 type) at Microsoft.Expression.DesignHost.Isolation.Remoting.IRemoteDesignerService .CreateDesigner(IRemoteHostSourceItem remoteItem,IRemoteHostTextEditor remoteEditor,IRemoteCancellationToken cancelToken) at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService。< > c__DisplayClass8。< CreateDesignerImpl > b__6(IRemoteDesignerService d) at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler。< > c__DisplayClass4`2。< MarshalOut > b__3() at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.Call。 InvokeWorker() System.NullReferenceException 对象引用未设置为对象的实例。 at Microsoft.Expression.Platform.PlatformService.PlatformEntry.get_PlatformCreator() at Microsoft.Expression.Platform.PlatformService.GetPlatformCreator(String frameworkSpec) at Microsoft.Expression.Platform.PlatformService.IsCompatibleFramework (FrameworkName hostFramework,FrameworkName guestFramework) at Microsoft.Expression.DesignSurface.Project.ProjectContextManager.GetProjectContext(IHostProject project,IPlatform platform,Boolean create) at Microsoft.Expression.DesignSurface.Project.ProjectContextManager.GetSourceItemContext( IHostSourceItem sourceItem) at Microsoft.Expression.DesignSurface.DesignerService.CreateDesigner(IHostSourceItem item,IHostTextEditor editor,CancellationToken cancelToken) at Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteDesignerService。< > c__DisplayClass10。< > c__DisplayClass12。< Microsoft.Expression.DesignHost.Isolation.Remoting.IRemoteDesignerService.CreateDesigner > b__f(CancellationToken cancelToken) at Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteDesignerService.CallWithCancellation [TResult](IRemoteCancellationToken remoteToken, Func`2 func) at Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteDesignerService。< > c__DisplayClass10。< Microsoft.Expression.DesignHost.Isolation.Remoting.IRemoteDesignerService.CreateDesigner > b__e() at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler。< > c__DisplayClass16`1。< MarshalIn > b__15() at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.Call.InvokeWorker() 解决方案 答案很简单! 引发此错误的对象或代码部分为空值。但是代码的一部分需要一个值来处理,而你的应用程序传递一个空值,导致.NET跳入并导致异常并终止进程。 尝试将该代码块包装在 try catch 中,或者使用 if else block。 我会使用if else block if (someVariable!= null ){ // 在此处执行该代码块.. } else { // 报告用户,关于错误,告诉他值为空 } 这很方便,您可以在应用程序中控制此空引用异常。它只是意味着该变量具有无值来处理。 NOT DISPLAY DESIGN WINDOW PHONEError:="an unhandled exception has occured"System.NullReferenceExceptionObject reference not set to an instance of an object. at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.WaitForCompletion(NestedCallContext nestedCallContext, BlockingCall call, WaitHandle timeoutSignal) at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.MarshalOutSynchronous(Action action, Int32 targetApartmentId, WaitHandle aborted, WaitHandle timeoutSignal) at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.MarshalOut(Action action, Int32 targetApartmentId, WaitHandle aborted, CallSynchronizationMode syncMode, WaitHandle timeoutSignal) at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalOut[TValue](RemoteHandle`1 targetObject, Action action, CallSynchronizationMode syncMode) at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalOut[TResult,TValue](RemoteHandle`1 targetObject, Func`2 func, CallSynchronizationMode syncMode) at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService.CreateDesignerImpl(IHostSourceItem item, IHostTextEditor editor, RemoteCancellationToken remoteCancelToken) at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService.<>c__DisplayClass12.<Microsoft.Expression.DesignHost.IDesignerService.CreateDesigner>b__11(RemoteCancellationToken remoteToken) at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService.CallWithCancellation[TResult](CancellationToken cancelToken, Func`2 func) at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService.Microsoft.Expression.DesignHost.IDesignerService.CreateDesigner(IHostSourceItem item, IHostTextEditor editor, CancellationToken cancelToken) at Microsoft.Expression.DesignHost.IsolatedDesignerService.IsolatedDesignerView.CreateDesignerViewInfo(CancellationToken cancelToken)System.NullReferenceExceptionObject reference not set to an instance of an object.Server stack trace: at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.WaitForCompletion(NestedCallContext nestedCallContext, BlockingCall call, WaitHandle timeoutSignal) at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.MarshalIn(Action action, Int32 targetApartmentId) at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalIn(IRemoteObject targetObject, Action action) at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.MarshalIn[TResult](IRemoteObject targetObject, Func`1 func) at Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteDesignerService.Microsoft.Expression.DesignHost.Isolation.Remoting.IRemoteDesignerService.CreateDesigner(IRemoteHostSourceItem remoteItem, IRemoteHostTextEditor remoteEditor, IRemoteCancellationToken remoteToken) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.Expression.DesignHost.Isolation.Remoting.IRemoteDesignerService.CreateDesigner(IRemoteHostSourceItem remoteItem, IRemoteHostTextEditor remoteEditor, IRemoteCancellationToken cancelToken) at Microsoft.Expression.DesignHost.Isolation.Remoting.LocalDesignerService.<>c__DisplayClass8.<CreateDesignerImpl>b__6(IRemoteDesignerService d) at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.<>c__DisplayClass4`2.<MarshalOut>b__3() at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.Call.InvokeWorker()System.NullReferenceExceptionObject reference not set to an instance of an object. at Microsoft.Expression.Platform.PlatformService.PlatformEntry.get_PlatformCreator() at Microsoft.Expression.Platform.PlatformService.GetPlatformCreator(String frameworkSpec) at Microsoft.Expression.Platform.PlatformService.IsCompatibleFramework(FrameworkName hostFramework, FrameworkName guestFramework) at Microsoft.Expression.DesignSurface.Project.ProjectContextManager.GetProjectContext(IHostProject project, IPlatform platform, Boolean create) at Microsoft.Expression.DesignSurface.Project.ProjectContextManager.GetSourceItemContext(IHostSourceItem sourceItem) at Microsoft.Expression.DesignSurface.DesignerService.CreateDesigner(IHostSourceItem item, IHostTextEditor editor, CancellationToken cancelToken) at Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteDesignerService.<>c__DisplayClass10.<>c__DisplayClass12.<Microsoft.Expression.DesignHost.Isolation.Remoting.IRemoteDesignerService.CreateDesigner>b__f(CancellationToken cancelToken) at Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteDesignerService.CallWithCancellation[TResult](IRemoteCancellationToken remoteToken, Func`2 func) at Microsoft.Expression.DesignHost.Isolation.Remoting.RemoteDesignerService.<>c__DisplayClass10.<Microsoft.Expression.DesignHost.Isolation.Remoting.IRemoteDesignerService.CreateDesigner>b__e() at Microsoft.Expression.DesignHost.Isolation.Remoting.ThreadMarshaler.<>c__DisplayClass16`1.<MarshalIn>b__15() at Microsoft.Expression.DesignHost.Isolation.Remoting.STAMarshaler.Call.InvokeWorker() 解决方案 The answer is simple!The object or the part of code that is raising this error is of null value. But the part of code, requires a value to work on whereas your application is passing a null value so causing the .NET to jump in and cause an exception and terminate the process.Try wrapping that code block inside a try catch, or use if else block.I would use if else block asif(someVariable != null) { // execute that code block here..} else { // report the user, about the error, tell him value is null}This comes handy and you can control this null reference exception in your application. It just means that the variable has no value to work on. 这篇关于在window phone sdk 8.0中创建窗口手机应用程序时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-20 14:54