1

WP7MangoプロジェクトにSQLCEを実装しようとしていますが、オブジェクトをDBに挿入/保存しようとすると、このエラーが発生します。

以下の私のコード:

public static void Save(MyObject myobject)
    {
        using (DBDataContext dc = new DBDataContext(DBDataContext.ConnectionString))
        {
            dc.MyObject.InsertOnSubmit(myobject);
            dc.SubmitChanges();
        }
    }

コードがinsertonsubmit行にヒットすると、次のように壊れます。

MissingMethodException was unhandled
MissingMethodException

そしてそれはそれが私に言うすべてです。

コールスタック:

mscorlib.dll!System.Activator.InternalCreateInstance(System.Type type, bool nonPublic, ref System.Threading.StackCrawlMark stackMark) + 0xe4 bytes  
mscorlib.dll!System.Activator.CreateInstance(System.Type type) + 0x2 bytes  
System.Data.Linq.dll!System.Data.Linq.WorkAround.ActivationHelper.CreateInstance(System.Type type)  
System.Data.Linq.dll!System.Data.Linq.ChangeTracker.StandardChangeTracker.StandardTrackedObject.CreateDataCopy(object instance) + 0x12 bytes    
System.Data.Linq.dll!System.Data.Linq.ChangeTracker.StandardChangeTracker.StandardTrackedObject.StartTracking() + 0x16 bytes    
System.Data.Linq.dll!System.Data.Linq.ChangeTracker.StandardChangeTracker.OnPropertyChanging(object sender, System.ComponentModel.PropertyChangingEventArgs args) + 0x16 bytes  
System.Data.Linq.dll!System.Data.Linq.ChangeTracker.StandardChangeTracker.Attach(object obj) + 0x1f bytes   
System.Data.Linq.dll!System.Data.Linq.ChangeTracker.StandardChangeTracker.Track(System.Data.Linq.Mapping.MetaType mt, object obj, System.Collections.Generic.Dictionary<object,object> visited, bool recurse, int level) + 0x4e bytes   
System.Data.Linq.dll!System.Data.Linq.ChangeTracker.StandardChangeTracker.Track(object obj, bool recurse) + 0x1d bytes  
System.Data.Linq.dll!System.Data.Linq.ChangeTracker.StandardChangeTracker.Track(object obj) + 0x3 bytes 
System.Data.Linq.dll!System.Data.Linq.Table<FotoDok.EkstraFeltMulighed>.InsertOnSubmit(FotoDok.EkstraFeltMulighed entity) + 0xac bytes  

FotoDok.dll!FotoDok.EkstraFeltMulighed.Gem(FotoDok.EkstraFeltMulighed ekstrafeltmulighed)70行目+ 0xcバイトC#FotoDok.dll!FotoDok.opdaterProjekter.behandlProjektJson(Newtonsoft.Json.Linq.JObject) FotoDok.opdaterProjekter.ReadCallbackValgteProjekter.AnonymousMethod__1(System.Windows.Controls.CheckBox delChk、Newtonsoft.Json.Linq.JObject delO)行141 + 0x7バイトC#mscorlib.dll!System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection 、object obj、System.Reflection.BindingFlags invokeAttr、System.Reflection.Binderバインダー、オブジェクトパラメーター、System.Globalization.CultureInfoカルチャー、bool isBinderDefault、System.Reflection.Assembly呼び出し元、bool verifyAccess、ref System.Threading.StackCrawlMark stackMark)
mscorlib.dll!System.Reflection.RuntimeMethodInfo.InternalInvoke(object obj、System.Reflection.BindingFlags invokeAttr、System.Reflection.Binderバインダー、object []パラメーター、System.Globalization.CultureInfoカルチャー、ref System.Threading.StackCrawlMark stackMark)+ 0x168バイトmscorlib.dll!System.Reflection.MethodBase.Invoke(object obj、object [] parameters)+ 0xaバイト
mscorlib.dll!System.Delegate.DynamicInvokeOne(object [] args)+ 0x98バイト
mscorlib.dll!System.MulticastDelegate .DynamicInvokeImpl(object [] args)+ 0x8バイト
mscorlib.dll!System.Delegate.DynamicInvoke(object [] args)+ 0x2バイト
System.Windows.dll!System.Windows.Threading.DispatcherOperation.Invoke()+0xcバイト
System.Windows.dll!System.Windows.Threading.Dispatcher.Dispatch(System.Windows.Threading.DispatcherPriority priority)+ 0x83バイト
System.Windows.dll!System.Windows.Threading.Dispatcher.OnInvoke(オブジェクトコンテキスト)+0x8バイトSystem.Windows.dll!System.Windows.Hosting.CallbackCookie.Invoke(object [] args)+ 0x19バイトSystem.Windows.dll!System.Windows.Hosting.DelegateWrapper.InternalInvoke(object [] args)+0x2バイトシステム。 Windows.RuntimeHost.dll!System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(System.IntPtr pHandle、int nParamCount、System.Windows.Hosting.NativeMethods.ScriptParam [] pParams、ref System.Windows.Hosting.NativeMethods.ScriptParampResult)+ 0x5eバイト[外部コード]

同じアプローチを使用して他のオブジェクトを挿入することができましたが、このオブジェクトの違いがわかりません。

4

2 に答える 2

1

私はそれを自分で解決し、それについてさらにグーグルで調べました(通常、何時間も検索し、ここに投稿した直後に答えに出くわしました。)

エラーが表示されない場合は、明らかに私のクラスには空のコンストラクターが必要です。したがって、空のコンストラクターをクラスに追加することで解決しました。

于 2012-01-19T07:41:01.440 に答える
0

コンストラクターはパブリックでなければならないことを付け加えたいと思います。同じ問題がありますが、モデルクラスに空の内部コンストラクターがありました。

于 2012-11-26T19:50:05.393 に答える