Git Product home page Git Product logo

Comments (10)

hernanrz avatar hernanrz commented on August 18, 2024

I managed to work around the error by:

  1. Creating a class that implements IRuntimePlatform
using Couchbase.Lite.DI;

internal class RuntimePlatform : IRuntimePlatform
    {
        public string OSDescription
        {
            get
            {
                return "Desktop";

            }
        }

        public string HardwareName
        {
            get
            {
                return "NET 6";
            }
        }
    }
Then before calling CBLite in my code, I register the class:
using Couchbase.Lite.DI;

           if (!RegisteredRuntimePlatform)
           {
               Service.Register<IRuntimePlatform>(new RuntimePlatform());
               RegisteredRuntimePlatform = true;
           }

It's very inelegant but it avoids the error

from couchbase-lite-net.

jhimes144 avatar jhimes144 commented on August 18, 2024

Also having the same issue, workaround provided fixes issue.

from couchbase-lite-net.

borrrden avatar borrrden commented on August 18, 2024

It's interesting that this is the particular error that happens, and sorry that I didn't notice this ticket. However .NET 6 is still, as of yet, unsupported. 3.1 will be the first release to support it.

from couchbase-lite-net.

borrrden avatar borrrden commented on August 18, 2024

That being said I tried this with 3.0.8

using Couchbase.Lite;

var dbconfig = new DatabaseConfiguration()
{
    Directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MyApp")
};
using var db = new Database("foo", dbconfig);
Console.WriteLine(db.Path);

I didn't see any errors like this. Can you confirm the reproduction steps?

from couchbase-lite-net.

jhimes144 avatar jhimes144 commented on August 18, 2024

@borrrden

I should of clarified that I'm actually on .net Framework 4.7.2. The problem only happens in version 3.0.0+, previous versions do not have this problem.

We are calling the constructor like this

using var db = new Database("pathHere");

I will see if I can create a reproduction repo.

from couchbase-lite-net.

borrrden avatar borrrden commented on August 18, 2024

I tried just now with .net 4.7.2 and 3.0.8, and I do not see the issue. Unrelated, but "pathHere" seems suspicious to me. That should be the database name, not a path.

from couchbase-lite-net.

borrrden avatar borrrden commented on August 18, 2024

Just for sanity sake, how are you observing this error? I believe internally this exception is thrown by SimpleInjector but then caught and handled so it doesn't actually affect the program flow. If you are just hitting it with a debugger set to halt on all exceptions it may trick you into thinking there is actually an issue where there is not. IRuntimePlatform is not a required interface. Couchbase Lite will try to instantiate it, but if it does not exist then it will fall back to some .NET runtime defaults.

See the following:

public static T GetInstance<T>() where T : class
{
try {
return _Collection.GetInstance<T>();
} catch (ActivationException) {
return null;
}
}

from couchbase-lite-net.

jhimes144 avatar jhimes144 commented on August 18, 2024

@borrrden

I think you might be onto something. I have another problem that is crashing our app when we move to 3x that is unrelated to this. I had my debugger set to recording non-user code exceptions and I think what I was seeing was the second problem silently killing the app after I continued through this exception, so I associated this exception as my app killer.

Since I turned off non-user code checks, I only get the unrelated error. Let me keep poking at this and I will get back to you.

from couchbase-lite-net.

jhimes144 avatar jhimes144 commented on August 18, 2024

@borrrden

So you are correct about the code above doing as it intended. My unrelated issue was solved by correctly calling the Database constructor as you mentioned was suspicious. Seems that at some point the old way I was calling that constructor was deprecated. My code now does this.

            database = new Database("nameHere", new DatabaseConfiguration
            {
                Directory = config.Paths.DatabasePath
            });

from couchbase-lite-net.

borrrden avatar borrrden commented on August 18, 2024

Glad to hear that. I am going to close this issue as I think the original poster probably had the same misdiagnosed issue.

from couchbase-lite-net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.