2017-09-04 36 views
0

後遷移我XamarinForm項目使用共享.NET starddard項目,而不是PCL(如下因素此鏈接https://blog.xamarin.com/building-xamarin-forms-apps-net-standard/棱鏡模板包 - 錯誤在.NET標準碎片項目中添加Xamarin.Forms ContentPage模板項目時

當我右鍵單擊共享項目(.net stardard proj)創建Xamarin.Forms ContentPage與棱鏡ViewModel使用棱鏡模板包我得到此錯誤:

項目系統遇到錯誤。 未將對象引用設置爲對象的實例。 已將診斷日誌寫入以下位置:「C:\ Users \ toumir \ AppData \ Local \ Temp \ VsProjectFault_7c3ce3c8-085f-4531-99cf-85d9a8b8ceee.failure.txt」。

日誌文件內容

04-09-2017 09:05:10 
Recoverable 
System.NullReferenceException: Object reference not set to an instance of an object. 
    at Prism.VisualStudio.Wizards.CreateViewModelForViewWizard.RunFinished() 
    at Microsoft.VisualStudio.TemplateWizard.Wizard.Execute(Object application, Int32 hwndOwner, Object[]& ContextParams, Object[]& CustomParams, wizardResult& retval) 
    at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) 
    at Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(Int32 hr, Int32[] expectedHRFailure) 
    at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.RunWizard(SimpleHierarchyNode parentNode, String itemName, String wizardToRun, IntPtr dlgOwner) 
    at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.<AddItemWithSpecificAsync>d__602.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.<>c__DisplayClass468_0.<<AddItem>b__0>d.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread() 
    at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread() 
    at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod, JoinableTaskCreationOptions creationOptions) 
    at Microsoft.VisualStudio.ProjectSystem.ProjectMultiThreadedService.ExecuteSynchronously[T](Func`1 asyncAction) 
    at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.<>c__DisplayClass559_0.<HrInvoke>b__0() 
    at Microsoft.VisualStudio.ProjectSystem.VS.HResult.Invoke(Func`1 action, IServiceProvider vsShellServiceProvider, IProjectFaultHandlerService projectFaultHandlerService, UnconfiguredProject project) 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.Rethrow(Exception ex) 
    at Microsoft.VisualStudio.ProjectSystem.ProjectErrorReporting.<>c__DisplayClass6_0.<SubmitErrorReport>b__0() 
    at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2_0.<Guard>b__0() 
    at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2) 

,但示出該消息的另一個消息框:

「未設置爲一個對象的實例對象引用」。

FYI:

  • 沒有使用PCL項目
  • 我的應用程序類是從PrismApplication
  • 導出時沒有問題

任何人都可以指導我們? 在此先感謝

+0

可能重複[什麼是NullReferenceException,以及如何解決它?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-doi-i-fix -it) – Enigmativity

回答

2

棱鏡模板包目前尚未正式支持.NET標準項目格式。 Xamarin不附帶任何與.NET標準兼容的項目模板,而Xamarin本身不是.NET標準。當Xamarin更新爲.NET標準版時,Prism模板包將隨之發佈。

+0

明白了,謝謝布萊恩先生 – toumir