Get More Support

Here for you 24/7

learn more
VOD Free SDK

Start Building your Engine Now

Download Now
VOD Extranet

Access to patches, license management,
tech docs and more for existing VOD customers.

Learn More
db40 in WP7
Last Post 04 May 2011 05:47 PM by Adriano Verona. 20 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Page 1 of 212 > >>
Author Messages
callmelee
New Member
New Member
Posts: 6


--
07 Aug 2010 05:25 AM

    Ok, I admit I'm new to db4o and to WP7, so I'm probably missing something basic here.  I'm getting an error when calling the OpenFile method of the DB4oEmbedded object.  My understanding is that if the file doesn't exist, calling OpenFile will create it.  I understand that in WP7 we're essentially working with Silverlight 3.0's isolated storage so my guess is its something to do with that.

    The code that causes the error is:

     IObjectContainer db = Db4oEmbedded.OpenFile(Db4oEmbedded.NewConfiguration(), "MyDB.db4");
     

    The error is:

    System.MethodAccessException was unhandled
      Message=Attempt to access the method failed: System.IO.Path.GetFullPath(System.String)
      StackTrace:
           at Sharpen.IO.File.GetCanonicalPath()
           at Db4objects.Db4o.IO.FileStorage.FileBin..ctor(BinConfiguration config)
           at Db4objects.Db4o.IO.FileStorage.Open(BinConfiguration config)
           at Db4objects.Db4o.IO.StorageDecorator.Open(BinConfiguration config)
           at Db4objects.Db4o.IO.CachingStorage.Open(BinConfiguration config)
           at Db4objects.Db4o.Internal.IoAdaptedObjectContainer.OpenImpl()
           at Db4objects.Db4o.Internal.ObjectContainerBase._IRunnable_128.Run()
           at Db4objects.Db4o.Foundation.DynamicVariable.With(Object value, IRunnable block)
           at Db4objects.Db4o.Foundation.Environments.RunWith(IEnvironment environment, IRunnable runnable)
           at Db4objects.Db4o.Internal.ObjectContainerBase.WithEnvironment(IRunnable runnable)
           at Db4objects.Db4o.Internal.ObjectContainerBase.Open()
           at Db4objects.Db4o.Internal.IoAdaptedObjectContainer..ctor(IConfiguration config, String fileName)
           at Db4objects.Db4o.Internal.ObjectContainerFactory.OpenObjectContainer(IEmbeddedConfiguration config, String databaseFileName)
           at Db4objects.Db4o.Db4oEmbedded.OpenFile(IEmbeddedConfiguration config, String databaseFileName)
           at JournalIt.AddJournal.btnCreate_Click(Object sender, RoutedEventArgs e)
           at System.Windows.Controls.Primitives.ButtonBase.OnClick()
           at System.Windows.Controls.Button.OnClick()
           at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
           at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
           at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

     

    What did I miss?  Are there any examples out there of using db4o with WP7 or Silverlight?

    Any help appreciated!

    -Lee

    Adriano Verona
    Basic Member
    Basic Member
    Posts: 464


    --
    07 Aug 2010 06:34 AM

    Hi


    You need to configure the right storage:

    IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration();
    config.File.Storage = new IsolatedStorageStorage();
    

    Also I've created an issue to make configuring this in an easier way: http://tracker.db4o.com/browse/COR-2032

    Best

    Adriano

    callmelee
    New Member
    New Member
    Posts: 6


    --
    07 Aug 2010 03:40 PM

    Thanks Adriano!  That got me past that part and I was able to call the store method after I figured out I couldn't use automatic properties.  But now when I try to retrieve the same object I just stored, from another page, I get a null reference exception when I call OpenFile using the exact same code I used when I stored the object. 

     	//Code to retrieve object   
    	IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration();  
             config.File.Storage = new IsolatedStorageStorage(); 
             IObjectContainer db = Db4oEmbedded.OpenFile(config, "SomeFile.db4"); Was I suppossed do something special when I call the store method? I just called db.Store(myobject);

    Here's the actual error:

    Db4objects.Db4o.Ext.Db4oRecoverableException was unhandled
      Message=Db4oRecoverableException
      StackTrace:
           at Db4objects.Db4o.Internal.ObjectContainerBase.GetByID(Transaction ta, Int64 id)
           at Db4objects.Db4o.Internal.Fileheader.FileHeaderVariablePart.ReadIdentity(LocalTransaction trans)
           at Db4objects.Db4o.Internal.Fileheader.NewFileHeaderBase.ReadIdentity(LocalObjectContainer container)
           at Db4objects.Db4o.Internal.LocalObjectContainer.ReadThis()
           at Db4objects.Db4o.Internal.IoAdaptedObjectContainer.OpenImpl()
           at Db4objects.Db4o.Internal.ObjectContainerBase._IRunnable_128.Run()
           at Db4objects.Db4o.Foundation.DynamicVariable.With(Object value, IRunnable block)
           at Db4objects.Db4o.Foundation.Environments.RunWith(IEnvironment environment, IRunnable runnable)
           at Db4objects.Db4o.Internal.ObjectContainerBase.WithEnvironment(IRunnable runnable)
           at Db4objects.Db4o.Internal.ObjectContainerBase.Open()
           at Db4objects.Db4o.Internal.IoAdaptedObjectContainer..ctor(IConfiguration config, String fileName)
           at Db4objects.Db4o.Internal.ObjectContainerFactory.OpenObjectContainer(IEmbeddedConfiguration config, String databaseFileName)
           at Db4objects.Db4o.Db4oEmbedded.OpenFile(IEmbeddedConfiguration config, String databaseFileName)
           at JournalIt.AddJournal.btnCreate_Click(Object sender, RoutedEventArgs e)
           at System.Windows.Controls.Primitives.ButtonBase.OnClick()
           at System.Windows.Controls.Button.OnClick()
           at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
           at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
           at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
      InnerException: System.NullReferenceException
           Message=NullReferenceException
           StackTrace:
                at Db4objects.Db4o.Ext.Db4oDatabase.GetHashCode()
                at System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(Object o)
                at Sharpen.Lang.IdentityHashCodeProvider.IdentityHashCode(Object obj)
                at Sharpen.Runtime.IdentityHashCode(Object obj)
                at Db4objects.Db4o.Internal.ObjectReference.Hc_getCode(Object obj)
                at Db4objects.Db4o.Internal.ObjectReference.Hc_init()
                at Db4objects.Db4o.Internal.ObjectReference.Ref_init()
                at Db4objects.Db4o.Internal.References.HashcodeReferenceSystem.AddReference(ObjectReference ref)
                at Db4objects.Db4o.Internal.References.HashcodeReferenceSystem.AddExistingReference(ObjectReference ref)
                at Db4objects.Db4o.Internal.References.TransactionalReferenceSystem.AddExistingReference(ObjectReference ref)
                at Db4objects.Db4o.Internal.ClassMetadata.OnInstantiate(UnmarshallingContext context, Object obj)
                at Db4objects.Db4o.Internal.ClassMetadata.Instantiate(UnmarshallingContext context)
                at Db4objects.Db4o.Internal.Marshall.UnmarshallingContext.Read()
                at Db4objects.Db4o.Internal.ObjectReference.Read(Transaction trans, ByteArrayBuffer buffer, Object obj, IActivationDepth instantiationDepth, Int32 addToIDTree, Boolean checkIDTree)
                at Db4objects.Db4o.Internal.ObjectReference.Read(Transaction trans, IActivationDepth instantiationDepth, Int32 addToIDTree, Boolean checkIDTree)
                at Db4objects.Db4o.Internal.ObjectContainerBase.GetByID2(Transaction ta, Int32 id)
                at Db4objects.Db4o.Internal.ObjectContainerBase.GetByID(Transaction ta, Int64 id)
                at Db4objects.Db4o.Internal.Fileheader.FileHeaderVariablePart.ReadIdentity(LocalTransaction trans)
                at Db4objects.Db4o.Internal.Fileheader.NewFileHeaderBase.ReadIdentity(LocalObjectContainer container)
                at Db4objects.Db4o.Internal.LocalObjectContainer.ReadThis()
                at Db4objects.Db4o.Internal.IoAdaptedObjectContainer.OpenImpl()
                at Db4objects.Db4o.Internal.ObjectContainerBase._IRunnable_128.Run()
                at Db4objects.Db4o.Foundation.DynamicVariable.With(Object value, IRunnable block)
                at Db4objects.Db4o.Foundation.Environments.RunWith(IEnvironment environment, IRunnable runnable)
                at Db4objects.Db4o.Internal.ObjectContainerBase.WithEnvironment(IRunnable runnable)
                at Db4objects.Db4o.Internal.ObjectContainerBase.Open()
                at Db4objects.Db4o.Internal.IoAdaptedObjectContainer..ctor(IConfiguration config, String fileName)
                at Db4objects.Db4o.Internal.ObjectContainerFactory.OpenObjectContainer(IEmbeddedConfiguration config, String databaseFileName)
                at Db4objects.Db4o.Db4oEmbedded.OpenFile(IEmbeddedConfiguration config, String databaseFileName)
                at JournalIt.AddJournal.btnCreate_Click(Object sender, RoutedEventArgs e)
                at System.Windows.Controls.Primitives.ButtonBase.OnClick()
                at System.Windows.Controls.Button.OnClick()
                at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
                at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
                at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

     Thanks again for your help!

    -Lee

     

    Adriano Verona
    Basic Member
    Basic Member
    Posts: 464


    --
    07 Aug 2010 04:14 PM

    Glad to known you moved forward.

    Actually this is an strange error. It is failing to find db4o "internal"  (book keeping) objects.

     

    Can you try to run the sample application I've written for the following blog post:

    http://developer.db4o.com/Blogs/Pro...fault.aspx

     


    Please, read this blog post also http://developer.db4o.com/Blogs/Pro...fault.aspx

    since it contains update information.

    Best

    callmelee
    New Member
    New Member
    Posts: 6


    --
    10 Aug 2010 03:19 AM

     Ok, I got past this error.  The problem seemed to be opening the db after on a separate page after it had been created.  To get around this, I declared the DB as a global member in App.xaml.cs.  This way it is accessible to all pages within the app.  The only issue I've run into using this method is that if I don't restart the WP7 emulator each time I debug the app I get this exception:

     

    Db4objects.Db4o.Ext.Db4oRecoverableException was unhandled

      Message=Db4oRecoverableException

      StackTrace:

           at Db4objects.Db4o.Internal.ObjectContainerBase.GetByID(Transaction ta, Int64 id)

           at Db4objects.Db4o.Internal.Fileheader.FileHeaderVariablePart.ReadIdentity(LocalTransaction trans)

           at Db4objects.Db4o.Internal.Fileheader.NewFileHeaderBase.ReadIdentity(LocalObjectContainer container)

           at Db4objects.Db4o.Internal.LocalObjectContainer.ReadThis()

           at Db4objects.Db4o.Internal.IoAdaptedObjectContainer.OpenImpl()

           at Db4objects.Db4o.Internal.ObjectContainerBase._IRunnable_128.Run()

           at Db4objects.Db4o.Foundation.DynamicVariable.With(Object value, IRunnable block)

           at Db4objects.Db4o.Foundation.Environments.RunWith(IEnvironment environment, IRunnable runnable)

           at Db4objects.Db4o.Internal.ObjectContainerBase.WithEnvironment(IRunnable runnable)

           at Db4objects.Db4o.Internal.ObjectContainerBase.Open()

           at Db4objects.Db4o.Internal.IoAdaptedObjectContainer..ctor(IConfiguration config, String fileName)

           at Db4objects.Db4o.Internal.ObjectContainerFactory.OpenObjectContainer(IEmbeddedConfiguration config, String databaseFileName)

           at Db4objects.Db4o.Db4oEmbedded.OpenFile(IEmbeddedConfiguration config, String databaseFileName)

           at JournalIt.App.Application_Launching(Object sender, LaunchingEventArgs e)

           at Microsoft.Phone.Shell.PhoneApplicationService.FireLaunching()

           at Microsoft.Phone.Execution.NativeEmInterop.FireOnLaunching()

      InnerException: System.NullReferenceException

           Message=NullReferenceException

           StackTrace:

                at Db4objects.Db4o.Ext.Db4oDatabase.GetHashCode()

                at System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(Object o)

                at Sharpen.Lang.IdentityHashCodeProvider.IdentityHashCode(Object obj)

                at Sharpen.Runtime.IdentityHashCode(Object obj)

                at Db4objects.Db4o.Internal.ObjectReference.Hc_getCode(Object obj)

                at Db4objects.Db4o.Internal.ObjectReference.Hc_init()

                at Db4objects.Db4o.Internal.ObjectReference.Ref_init()

                at Db4objects.Db4o.Internal.References.HashcodeReferenceSystem.AddReference(ObjectReference ref)

                at Db4objects.Db4o.Internal.References.HashcodeReferenceSystem.AddExistingReference(ObjectReference ref)

                at Db4objects.Db4o.Internal.References.TransactionalReferenceSystem.AddExistingReference(ObjectReference ref)

                at Db4objects.Db4o.Internal.ClassMetadata.OnInstantiate(UnmarshallingContext context, Object obj)

                at Db4objects.Db4o.Internal.ClassMetadata.Instantiate(UnmarshallingContext context)

                at Db4objects.Db4o.Internal.Marshall.UnmarshallingContext.Read()

                at Db4objects.Db4o.Internal.ObjectReference.Read(Transaction trans, ByteArrayBuffer buffer, Object obj, IActivationDepth instantiationDepth, Int32 addToIDTree, Boolean checkIDTree)

                at Db4objects.Db4o.Internal.ObjectReference.Read(Transaction trans, IActivationDepth instantiationDepth, Int32 addToIDTree, Boolean checkIDTree)

                at Db4objects.Db4o.Internal.ObjectContainerBase.GetByID2(Transaction ta, Int32 id)

                at Db4objects.Db4o.Internal.ObjectContainerBase.GetByID(Transaction ta, Int64 id)

                at Db4objects.Db4o.Internal.Fileheader.FileHeaderVariablePart.ReadIdentity(LocalTransaction trans)

                at Db4objects.Db4o.Internal.Fileheader.NewFileHeaderBase.ReadIdentity(LocalObjectContainer container)

                at Db4objects.Db4o.Internal.LocalObjectContainer.ReadThis()

                at Db4objects.Db4o.Internal.IoAdaptedObjectContainer.OpenImpl()

                at Db4objects.Db4o.Internal.ObjectContainerBase._IRunnable_128.Run()

                at Db4objects.Db4o.Foundation.DynamicVariable.With(Object value, IRunnable block)

                at Db4objects.Db4o.Foundation.Environments.RunWith(IEnvironment environment, IRunnable runnable)

                at Db4objects.Db4o.Internal.ObjectContainerBase.WithEnvironment(IRunnable runnable)

                at Db4objects.Db4o.Internal.ObjectContainerBase.Open()

                at Db4objects.Db4o.Internal.IoAdaptedObjectContainer..ctor(IConfiguration config, String fileName)

                at Db4objects.Db4o.Internal.ObjectContainerFactory.OpenObjectContainer(IEmbeddedConfiguration config, String databaseFileName)

                at Db4objects.Db4o.Db4oEmbedded.OpenFile(IEmbeddedConfiguration config, String databaseFileName)

                at JournalIt.App.Application_Launching(Object sender, LaunchingEventArgs e)

                at Microsoft.Phone.Shell.PhoneApplicationService.FireLaunching()

                at Microsoft.Phone.Execution.NativeEmInterop.FireOnLaunching()

     

     

    I can live with this, but are there any other issues I might run into having the db as a global variable?

    Also, I haven't been able to get LINQ to work.

    This SODA query works:

     

     IQuery query = app.db.Query();
                query.Constrain(typeof(Journal));
                query.Descend("_ObjectID").Constrain(oid);
                IObjectSet result = query.Execute();

    But this LINQ query does not, even though I have referenced the db4oObjects.db4o.linq assembly and have added the using statement:

     

    var q = from MyOjbect o in app.db
                        where o.ObjectID== oid
                        select o;

    In both cases oid is a public member of the PhoneApplicationBage.  The error that the LINQ query receives is:

     

     

     

    System.MissingMethodException was unhandled

      Message=Method not found: quality rlib, Version=3.7.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC.System.Type.

      StackTrace:

           at JournalIt.JournalEntryListPage.PhoneApplicationPage_Loaded(Object sender, RoutedEventArgs e)

           at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)

           at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

    Thanks for all your help!
    Lee

     

     

    Adriano Verona
    Basic Member
    Basic Member
    Posts: 464


    --
    10 Aug 2010 12:13 PM

    Hi

    Ok, I got past this error.  The problem seemed to be opening the db after on a separate page after it had been created.  To get around this, I declared the DB as a global member in App.xaml.cs.  This way it is accessible to all pages within the app.  The only issue I've run into using this method is that if I don't restart the WP7 emulator each time I debug the app I get this exception:

    Strange. Are you trying to reopen the database (without closing it ) in each page?

    Can you post the configurations you are using? Is it possible to share a basic working VS solution so I can take a look (in my free time ?

    Also, I haven't been able to get LINQ to work.

    ...

    But this LINQ query does not, even though I have referenced the db4oObjects.db4o.linq assembly and have added the using statement:

    We'll support LINQ on Silverlight soon (actually the code is already checked in in our SVN but we didn't get a successful build from our continuous build yet).

    Best

     

    callmelee
    New Member
    New Member
    Posts: 6


    --
    10 Aug 2010 03:06 PM
    Hi,
    Prior to moving the DB to a global variable, I was opening it each page, but was explicitly closing and disposing of it prior to calling a new page. I'll see if I can put together a simple solution that illustrates the problem.

    I look forward to trying out your build that supports LINQ. I've grown accustomed to its syntax so that would make my life a bit easier.

    Thanks!
    Lee
    Adriano Verona
    Basic Member
    Basic Member
    Posts: 464


    --
    10 Aug 2010 07:19 PM

    Hi

    I'll see if I can put together a simple solution that illustrates the problem.

    Cool

    I look forward to trying out your build that supports LINQ. I've grown accustomed to its syntax so that would make my life a bit easier

    Indeed, LINQ is really nice.

    Best

     

    callmelee
    New Member
    New Member
    Posts: 6


    --
    11 Aug 2010 01:25 AM

     Ok, I've created a solution that illustrates the issue.

    It's located at www.phillipsitsolutions.com/misc/db4oMultiPageDemo.zip.

    So the main page just collects some info, open/creates the db4o database, stores object calls commit, then closes and disposes the db.  It then navigates to Page1 where the db is opened again, which causes the error.

    Cheers!

    Lee

     

    callmelee
    New Member
    New Member
    Posts: 6


    --
    26 Aug 2010 07:59 PM

     Hey Adriano, did you ever get a chance to look at this?  Having the DB in a global variable is turning out to be a pain.

    Thanks,

    Lee

    Adriano Verona
    Basic Member
    Basic Member
    Posts: 464


    --
    25 Oct 2010 08:56 PM

    Hi

    unfortunately I didn't get the time to look into WP7 support until last week.

    During this week we started to investigate what would be required to support WP7 and I have some news (you can track progress here):

    1. db4o silverlight assemblies will not work (we need to build specifically for WP7)
       
    2. We found what we believe to be a bug in one of WP7 BLC classes that will make it hard to run db4o on it (you can get more details in the issue I linked before)
       
    3. We managed to store simple objects on db4o running on WP7 (but keep in mind the problem discussed in topic 2)
       

    I'll keep you posted about what'll be our next steps;

    best

    Adriano

    Buju
    New Member
    New Member
    Posts: 1


    --
    13 Dec 2010 05:32 PM
    Hi,

    is there an update for Windows Phone 7 support? Because I can't get it to work. I installed db4o using "db4o for .NET 4.0, version 8.0.160.14822 MSI" and I'm using silverlight-3.0 binaries, because .NET 4.0 binaries could not be added to WP7 project.

    Thanks,
    Buju
    jrd6dk
    New Member
    New Member
    Posts: 8


    --
    30 Jan 2011 10:17 PM

     I kinda replicated this thread, in a new thread. It seems I didn't read it close enough the first time.

    However, Buju, you need to use the silverlight 3 dlls from the version 8 beta .net 3.5 package - NOT THE 4.0 package.

    jrd6dk
    New Member
    New Member
    Posts: 8


    --
    30 Jan 2011 10:25 PM
    It seems we are unable to reopen the database as it is right now.
    I do not have permission to see the issue Adriano Verona is talking about:
    http://tracker.db4o.com/browse/INT-196

    So I guesswe are out of luck for the moment.
    Adriano Verona
    Basic Member
    Basic Member
    Posts: 464


    --
    02 Feb 2011 01:14 AM

    Hi

    I do not have permission to see the issue Adriano Verona is talking about: 
    http://tracker.db4o.com/browse/INT-196 

    Sorry, the issue was created as an internal issue.

    Basically the issue says that WP7 platform has a bug that make porting db4o to this platform a tough task. 


    We opened a bug on Microsoft : https://connect.microsoft.com/VisualStudio/feedback/details/618090/runtimehelpers-gethashcode-is-calling-the-inherited-gethashcode-version-instead-of-object-gethashcode

    Since we do want to support this platform we are going to try to contact MS support to get an official answer about the issue.

    Best

    Adriano

    jrd6dk
    New Member
    New Member
    Posts: 8


    --
    02 Feb 2011 09:23 AM
    Ah I see,
    Lets just hope MS gets this fixed soon.
    Anyway, thanks for your answer, and i better get that serilization code back in the app:)

    Heh now i understand why there seem to be a lack of WP7 info on the site :)

    Cheers
    Jesper
    Adriano Verona
    Basic Member
    Basic Member
    Posts: 464


    --
    07 Feb 2011 04:41 PM
    Please, if you'd like to get db4o to support Windows Phone 7, go to Microsoft Connect and mark it as important for you. Best
    jersiovic
    New Member
    New Member
    Posts: 6


    --
    19 Apr 2011 06:50 PM

     I've voted, eventhough two monts without an answer is too many time.

    Any news from Microsoft regarding this issue?

    Regards

    james.arendt
    New Member
    New Member
    Posts: 24


    --
    28 Apr 2011 11:12 PM
    The last response on the Connect website was that it's an 'internal' API and recommended that developers should not use that API on the phone. It's their 'polite' way of telling db4o to go bugger off and that they don't have any current plans on changing it.
    jersiovic
    New Member
    New Member
    Posts: 6


    --
    29 Apr 2011 12:10 PM

    Is Versant  looking for a workaround to avoid this bug?

    Do you have any hope of finding a solution without Microsoft help?

    I'm very interested on include db4o in my WP7 project.

     

    Regards

     

    You are not authorized to post a reply.
    Page 1 of 212 > >>


    Active Forums 4.3