I'm trying to implement SQL CE in a WP7 Mango project, but now I'm encountering this error when I try to insert/save an object to my DB.
My code below:
public static void Save(MyObject myobject)
{
using (DBDataContext dc = new DBDataContext(DBDataContext.ConnectionString))
{
dc.MyObject.InsertOnSubmit(myobject);
dc.SubmitChanges();
}
}
When code hits the insertonsubmit line, it breaks with
MissingMethodException was unhandled
MissingMethodException
And that's all it tells me.
Call stack:
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) Line 70 + 0xc bytes C#
FotoDok.dll!FotoDok.opdaterProjekter.behandlProjektJson(Newtonsoft.Json.Linq.JObject o) Line 202 + 0x7 bytes C#
FotoDok.dll!FotoDok.opdaterProjekter.ReadCallbackValgteProjekter.AnonymousMethod__1(System.Windows.Controls.CheckBox delChk, Newtonsoft.Json.Linq.JObject delO) Line 141 + 0x7 bytes C#
mscorlib.dll!System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo rtmi, object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object parameters, System.Globalization.CultureInfo culture, bool isBinderDefault, System.Reflection.Assembly caller, bool verifyAccess, ref System.Threading.StackCrawlMark stackMark)
mscorlib.dll!System.Reflection.RuntimeMethodInfo.InternalInvoke(object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object[] parameters, System.Globalization.CultureInfo culture, ref System.Threading.StackCrawlMark stackMark) + 0x168 bytes
mscorlib.dll!System.Reflection.MethodBase.Invoke(object obj, object[] parameters) + 0xa bytes
mscorlib.dll!System.Delegate.DynamicInvokeOne(object[] args) + 0x98 bytes
mscorlib.dll!System.MulticastDelegate.DynamicInvokeImpl(object[] args) + 0x8 bytes
mscorlib.dll!System.Delegate.DynamicInvoke(object[] args) + 0x2 bytes
System.Windows.dll!System.Windows.Threading.DispatcherOperation.Invoke() + 0xc bytes
System.Windows.dll!System.Windows.Threading.Dispatcher.Dispatch(System.Windows.Threading.DispatcherPriority priority) + 0x83 bytes
System.Windows.dll!System.Windows.Threading.Dispatcher.OnInvoke(object context) + 0x8 bytes
System.Windows.dll!System.Windows.Hosting.CallbackCookie.Invoke(object[] args) + 0x19 bytes
System.Windows.dll!System.Windows.Hosting.DelegateWrapper.InternalInvoke(object[] args) + 0x2 bytes
System.Windows.RuntimeHost.dll!System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(System.IntPtr pHandle, int nParamCount, System.Windows.Hosting.NativeMethods.ScriptParam[] pParams, ref System.Windows.Hosting.NativeMethods.ScriptParam pResult) + 0x5e bytes
[External Code]
I've managed to insert other objects, using the same approach just fine, but I can't figure out what makes this object any different.
I solved it myself, googling even more about it (Typical, searching for hours, then right after making a post here I stumble on an answer..)
Aparrently my classes must have an empty contructor, if they don't the error appears.
So adding empty constructors to my classes solved it.
I would like to add that the constructor must be public. I have the same problem, but in my model class I had empty internal constructor.
Related
Since upgrading to Apache.Ignite 2.12.0, Ignite fails to start up with the following error:
Unhandled exception. Apache.Ignite.Core.Common.IgniteException: Failed to start Ignite.NET, check inner exception for details
System.ArgumentException: Seek before origin: -1953261975
at Apache.Ignite.Core.Impl.Memory.PlatformMemoryStream.Seek(Int32 offset, SeekOrigin origin)
at Apache.Ignite.Core.Impl.Binary.BinaryReader.ReadHandleObject[T](Int32 pos, Type typeOverride)
at Apache.Ignite.Core.Impl.Binary.BinaryReader.Read[T](Func`1 readFunc, Byte expHdr)
at Apache.Ignite.Core.Impl.Binary.BinaryReader.Read[T](Func`2 readFunc, Byte expHdr)
at Apache.Ignite.Core.Impl.Binary.BinaryReader.ReadString()
at Apache.Ignite.Core.Configuration.DataRegionConfiguration..ctor(IBinaryRawReader reader)
at Apache.Ignite.Core.Configuration.DataStorageConfiguration.<>c__DisplayClass27_0.<.ctor>b__0(Int32 x)
at System.Linq.Enumerable.SelectRangeIterator`1.ToArray()
at Apache.Ignite.Core.Configuration.DataStorageConfiguration..ctor(IBinaryRawReader reader)
at Apache.Ignite.Core.IgniteConfiguration.ReadCore(BinaryReader r)
at Apache.Ignite.Core.IgniteConfiguration.Read(BinaryReader binaryReader)
at Apache.Ignite.Core.IgniteConfiguration..ctor(BinaryReader binaryReader, IgniteConfiguration baseConfig)
at Apache.Ignite.Core.Impl.Ignite.<GetConfiguration>b__87_0(IBinaryStream s)
at Apache.Ignite.Core.Impl.PlatformJniTarget.OutStream[T](Int32 type, Func`2 readAction)
at Apache.Ignite.Core.Impl.PlatformTargetAdapter.DoInOp[T](Int32 type, Func`2 action)
at Apache.Ignite.Core.Impl.Ignite.GetConfiguration()
at Apache.Ignite.Core.Impl.Ignite.SetCompactFooter()
at Apache.Ignite.Core.Impl.Ignite..ctor(IgniteConfiguration cfg, String name, IPlatformTargetInternal proc, Marshaller marsh, IList`1 lifecycleHandlers, UnmanagedCallbacks cbs)
at Apache.Ignite.Core.Ignition.OnStart(GlobalRef interopProc, IBinaryStream stream)
at Apache.Ignite.Core.Impl.Unmanaged.UnmanagedCallbacks.OnStart(Int64 memPtr, Int64 unused, Int64 unused1, Void* proc)
at Apache.Ignite.Core.Impl.Unmanaged.UnmanagedCallbacks.InLongLongLongObjectOutLong(Int32 type, Int64 val1, Int64 val2, Int64 val3, IntPtr arg)
at Apache.Ignite.Core.Impl.Unmanaged.Jni.Callbacks.InLongLongLongObjectOutLong(IntPtr env, IntPtr clazz, Int64 igniteId, Int32 op, Int64 arg1, Int64 arg2, Int64 arg3, IntPtr arg)
Any assistance would be appreciated
I seem to be doing something wrong in this attempt to expose the localtime functionality in Perl 6:
use NativeCall;
my class TimeStruct is repr<CStruct> {
has int32 $!tm_sec;
has int32 $!tm_min;
has int32 $!tm_hour;
has int32 $!tm_mday;
has int32 $!tm_mon;
has int32 $!tm_year;
has int32 $!tm_wday;
has int32 $!tm_yday;
has int32 $!tm_isdst;
has Str $!tm_zone;
has long $!tm_gmtoff;
}
sub localtime(uint32 $epoch --> TimeStruct) is native {*}
dd localtime(time); # segfault
Running under perl6-lldb-m, I get:
Process 82758 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x5ae5dda1)
frame #0: 0x00007fffe852efb4 libsystem_c.dylib`_st_localsub + 13
libsystem_c.dylib`_st_localsub:
-> 0x7fffe852efb4 <+13>: movq (%rdi), %rax
0x7fffe852efb7 <+16>: movq %rax, -0x20(%rbp)
0x7fffe852efbb <+20>: movq 0x8e71d3e(%rip), %rbx ; lclptr
0x7fffe852efc2 <+27>: testq %rbx, %rbx
Target 0: (moar) stopped.
Any obvious things I'm doing wrong here?
UPDATE: the final working solution:
class TimeStruct is repr<CStruct> {
has int32 $.tm_sec; # *must* be public attributes
has int32 $.tm_min;
has int32 $.tm_hour;
has int32 $.tm_mday;
has int32 $.tm_mon;
has int32 $.tm_year;
has int32 $.tm_wday;
has int32 $.tm_yday;
has int32 $.tm_isdst;
has long $.tm_gmtoff; # these two were
has Str $.time_zone; # in the wrong order
}
sub localtime(int64 $epoch is rw --> TimeStruct) is native {*}
my int64 $epoch = time; # needs a separate definition somehow
dd localtime($epoch);
localtime() expects a pointer of type time_t* as argument. Assuming time_t and uint32_t are compatible types on your particular platform,
sub localtime(uint32 $epoch is rw --> TimeStruct) is native {*}
my uint32 $t = time;
dd localtime($t);
should do it (though you won't get to see anything unless you make your attributes public).
I'm a bit surprised that your time_t isn't a 64-bit type, and having just googled apple time.h, I also suspect the last two attributes in your struct declaration are in the wrong order...
When using Rebus with Nhibernate, while storing the subscriber details in table getting error like
NHibernate.Event.Default.AbstractFlushingEventListener
NHibernate.AdoNet.TooManyRowsAffectedException: Unexpected row count: 5; expected: 1
at NHibernate.AdoNet.Expectations.BasicExpectation.VerifyOutcomeNonBatched(Int32 rowCount, IDbCommand statement)
at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.UpdateOrInsert(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object obj, Object rowId, ISessionImplementor session)
at NHibernate.Action.EntityUpdateAction.Execute()
at NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
at NHibernate.Engine.ActionQueue.ExecuteActions()
at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session)
This may happen due to all subscriber concurrency, because If I use debugger, then it work unexpectedly as enough time passes.
Getting exception in this code
public void Insert(ISagaData sagaData, string[] sagaDataPropertyPathsToIndex)
{
try
{
var nSagaData = new NDbSagaData
{
Id = sagaData.Id,
Revision = sagaData.Revision++,
Data = JsonConvert.SerializeObject(sagaData, Formatting.Indented, Settings)
};
PersistenceManager.Save(nSagaData);
}
catch (Exception ex)
{
_log.Error("Insert Exception " + ex.Message);
System.IO.File.AppendAllText("C:\\TestFolder\\WriteText.txt", "Insert fromSource - " + ex.Message);
throw new OptimisticLockingException(sagaData, ex);
}
}
and it says, 'Unexpected row count: 3; expected: 1'
What will be the reason?
It looks like you have implemented a saga persister based on NHibernate, and it seems like it has detected a race condition, which I am guessing results in a rolled-back transaction.
I guess the question is why a race condition occurred. The "unexpected row count" exception occurs when NHibernate's optimistic concurrency check fails, but in that case I would have expected a message saying "unexpected row count 0; expected 1".
If I were you, I would use Rebus' built-in SQL Server saga persister, as it seems you are serializing the saga data into a single column anyway.
I'm struggling with the below exception using WaveFileWriter. This exception occurs intermittently -- most times this works fine. Code snippet below:
MemoryStream s = new MemoryStream();
MemoryStream newStream = new MemoryStream();
int length = 0;
byte[] buffer = null;
int read = 0;
MixingSampleProvider mixer2 = new MixingSampleProvider(_samples);
SampleToWaveProvider16 mixer3 = new SampleToWaveProvider16(mixer2);
length = mixer3.WaveFormat.AverageBytesPerSecond*Convert.ToInt32(position.TotalSeconds); //position is a Timespan calculated to be the total duration of the WAV files
buffer = new byte[length];
WaveFileWriter waveFileWriter = new WaveFileWriter(new IgnoreDisposeStream(s), mixer3.WaveFormat);
while ((read = mixer3.Read(buffer, 0, buffer.Length)) > 0)
{
waveFileWriter.Write(buffer, 0, read);
}
waveFileWriter.Flush();
waveFileWriter.Close();
waveFileWriter.Dispose();
s.WriteTo(newStream);
Here are the details of the Exception:
System.IndexOutOfRangeException was caught
HResult=-2146233080
Message=Index was outside the bounds of the array.
Source=NAudio
StackTrace:
at NAudio.Wave.SampleProviders.Pcm16BitToSampleProvider.Read(Single[] buffer, Int32 offset, Int32 count)
at NAudio.Wave.SampleProviders.OffsetSampleProvider.Read(Single[] buffer, Int32 offset, Int32 count)
at NAudio.Wave.SampleProviders.MixingSampleProvider.Read(Single[] buffer, Int32 offset, Int32 count)
at NAudio.Wave.SampleProviders.OffsetSampleProvider.Read(Single[] buffer, Int32 offset, Int32 count)
at NAudio.Wave.SampleProviders.MixingSampleProvider.Read(Single[] buffer, Int32 offset, Int32 count)
at NAudio.Wave.SampleProviders.SampleToWaveProvider16.Read(Byte[] destBuffer, Int32 offset, Int32 numBytes)
at GamedayRadio.HalfInning.Process() in xxxxxx
InnerException:
Not sure if this is causing your error, but do make sure that the read length is an exact multiple of the BlockAlign for your WaveFormat. So for example when reading stereo 16 bit audio, always read multiples of 4 bytes (2 channels x 2 bytes per sample). Your buffer looks like it might be an odd number of bytes in some circumstances
I've a problem with following Hql Query:
FROM PhysikalischesObjekt physikalischesObjekt LEFT OUTER JOIN FETCH physikalischesobjekt.AktuelleInstallation installation
As you see - i'm using aliases that named like the entity (just with lower letter at the first position).
If im execute this query to Nhibernate, i get a InvalidPathException:
NHibernate.Hql.Ast.ANTLR.InvalidPathException : Invalid path: 'physikalischesobjekt.AktuelleInstallation' [FROM PhysikalischesObjekt physikalischesObjekt LEFT OUTER JOIN FETCH physikalischesobjekt.AktuelleInstallation installation ]
Stacktrace:
> NHibernate.dll!NHibernate.Hql.Ast.ANTLR.Util.LiteralProcessor.LookupConstant(NHibernate.Hql.Ast.ANTLR.Tree.DotNode node) Zeile 81 C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.Tree.DotNode.Resolve(bool generateJoin, bool implicitJoin, string classAlias, NHibernate.Hql.Ast.ANTLR.Tree.IASTNode parent) Zeile 208 C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.Tree.FromReferenceNode.Resolve(bool generateJoin, bool implicitJoin, string classAlias) Zeile 58 C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.CreateFromJoinElement(NHibernate.Hql.Ast.ANTLR.Tree.IASTNode path, NHibernate.Hql.Ast.ANTLR.Tree.IASTNode alias, int joinType, NHibernate.Hql.Ast.ANTLR.Tree.IASTNode fetchNode, NHibernate.Hql.Ast.ANTLR.Tree.IASTNode propertyFetch, NHibernate.Hql.Ast.ANTLR.Tree.IASTNode with) Zeile 681 C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.joinElement() Zeile 3955 + 0x3c Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.fromElement() Zeile 3617 + 0xc Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.fromElementList() Zeile 3391 + 0xc Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.fromClause() Zeile 3308 + 0xc Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.unionedQuery() Zeile 1645 + 0xc Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.query() Zeile 1510 + 0xc Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectStatement() Zeile 536 + 0xc Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.statement() Zeile 435 + 0xc Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate() Zeile 590 + 0x1b Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Analyze(string collectionRole) Zeile 449 + 0x12 Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(System.Collections.Generic.IDictionary<string,string> replacements, bool shallow, string collectionRole) Zeile 354 + 0x13 Bytes C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Compile(System.Collections.Generic.IDictionary<string,string> replacements, bool shallow) Zeile 72 C#
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(NHibernate.Hql.Ast.ANTLR.Tree.IASTNode ast, string queryIdentifier, string collectionRole, bool shallow, System.Collections.Generic.IDictionary<string,NHibernate.IFilter> filters, NHibernate.Engine.ISessionFactoryImplementor factory) Zeile 43 + 0xa3 Bytes Unknown
NHibernate.dll!NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(string queryString, string collectionRole, bool shallow, System.Collections.Generic.IDictionary<string,NHibernate.IFilter> filters, NHibernate.Engine.ISessionFactoryImplementor factory) Zeile 21 + 0x3a Bytes C#
NHibernate.dll!NHibernate.Engine.Query.HQLStringQueryPlan.CreateTranslators(string hql, string collectionRole, bool shallow, System.Collections.Generic.IDictionary<string,NHibernate.IFilter> enabledFilters, NHibernate.Engine.ISessionFactoryImplementor factory) Zeile 24 + 0x99 Bytes C#
NHibernate.dll!NHibernate.Engine.Query.HQLStringQueryPlan.HQLStringQueryPlan(string hql, string collectionRole, bool shallow, System.Collections.Generic.IDictionary<string,NHibernate.IFilter> enabledFilters, NHibernate.Engine.ISessionFactoryImplementor factory) Zeile 16 + 0x3e Bytes C#
NHibernate.dll!NHibernate.Engine.Query.HQLStringQueryPlan.HQLStringQueryPlan(string hql, bool shallow, System.Collections.Generic.IDictionary<string,NHibernate.IFilter> enabledFilters, NHibernate.Engine.ISessionFactoryImplementor factory) Zeile 14 C#
NHibernate.dll!NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(string queryString, bool shallow, System.Collections.Generic.IDictionary<string,NHibernate.IFilter> enabledFilters) Zeile 61 + 0x5b Bytes C#
NHibernate.dll!NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(string query, bool shallow) Zeile 304 + 0x87 Bytes C#
NHibernate.dll!NHibernate.Impl.AbstractSessionImpl.CreateQuery(string queryString) Zeile 283 + 0x3b Bytes C#
Is there a problem using alias like this in Hql? Is there a Syntax that disallows to use the same alias name as the entity name? It seems that Nhibernate tries find a persister for the alias name which doesn't work, obviously.
The alias you used are not the same: "physikalischesObjekt" and "physikalisachesobjekt".