我目前正在爲WP7製作遊戲,主要是在Silverlight中製作的。但是現在我需要一個可以使用XNA的頁面。 XNA頁面將接收一場戰鬥的數據,然後爲用戶進行可視化。將XNA添加到Silverlight WP7項目
我試過在我的解決方案中製作一個「Windows Phone Silverlight和XNA」項目(BattleSimulator)並導航到GamePage.xaml。但是我得到一個NullReferenceException(Application.Current as App)和一個警告。警告在BattleSimulator項目中。
警告
Warning 1 The project 'BattleSimulatorLib' cannot be referenced. The referenced project is targeted to a different framework family (.NETFramework)
代碼
堆棧跟蹤
at BattleSimulator.GamePage..ctor()
at System.Reflection.RuntimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo rtci, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Activator.InternalCreateInstance(Type type, Boolean nonPublic, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type)
at System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread(AsyncCallback userCallback, PageResourceContentLoaderAsyncResult result)
at System.Windows.Navigation.PageResourceContentLoader.<>c__DisplayClass4.<BeginLoad>b__0(Object args)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Delegate.DynamicInvokeOne(Object[] args)
at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)
at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)
一個解決,將B的方式e將我所有的silverlight類和標記複製到一個新的SL和XNA項目中,但這是我的if-all-else-failures計劃。
有誰知道如何解決這個NullReferenceException或警告?或者我應該嘗試以其他方式做到這一點?
編輯:發現這裏的警告信息:http://forums.create.msdn.com/forums/p/93769/561676.aspx 它是無害的。
謝謝你的回答。開始尋找它,但它看起來有點麻煩,我認爲風險是我最終會遇到不穩定的事情。我只需拿到我的鼠標並開始導入。 – softarn 2012-02-27 14:58:57