'Gentle.Framework.ProviderFactory' threw an exception (1 Viewer)

K24A3

MP Donator
  • Premium Supporter
  • May 1, 2010
    78
    4
    Home Country
    I have my own .NET app (not an MP plugin) that uses the dll's from the MediaPortal source to retrieve the Scheduled recordings.

    I reference TVBusinessLayer.dll in my app and then call the code shown below.

    It was working perfectly in MP 1.6, since I updated the referenced DLL to 1.7 and MediaPortal itself to 1.7, I am getting an exception:

    TVData Initialize EXCEPTION: The type initializer for 'Gentle.Framework.ProviderFactory' threw an exception. System.TypeInitializationException: The type initializer for 'Gentle.Framework.ProviderFactory' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
    at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
    at System.Reflection.RuntimeModule.GetTypes()
    at System.Reflection.Assembly.GetTypes()
    at Gentle.Framework.ProviderRegistry.GetProviderInfo(Assembly assembly)
    at Gentle.Framework.ProviderRegistry.GetProviderInfo(String assemblyName)
    at Gentle.Framework.ProviderRegistry.RegisterProvider(String name, String assembly)
    --- End of inner exception stack trace ---
    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
    at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at Gentle.Common.MethodInvoker.Invoke(Object target, Object[] parameterValues)
    at Gentle.Common.MethodDispatcher.Invoke(Object target, Hashtable parameters)
    at Gentle.Common.CallbackTarget.Configure(Object target, XmlNode node)
    at Gentle.Common.CallbackTarget.Configure(Object target, XmlNodeList nodes)
    at Gentle.Common.ConfigurationMap.Configure(IList handlers, Object obj)
    at Gentle.Common.Configurator.Configure(String configStoreName, Object instance)
    at Gentle.Framework.ProviderRegistry..ctor()
    at Gentle.Framework.ProviderFactory..cctor()
    --- End of inner exception stack trace ---
    at Gentle.Framework.ProviderFactory.SetDefaultProviderConnectionString(String connectionString)



    Code:
                    tvBusinessLayer = new TvBusinessLayer();
              
    
                   // This code was added to test the connection string
                    string sConn = "Server=PC2;Database=MpTvDb;User ID=root;Password=MediaPortal;charset=utf8;Connection Timeout=30;";
                    Gentle.Framework.ProviderFactory.SetDefaultProviderConnectionString(sConn);
    
                   // This line was the original line that threw the exception
                    tvBusinessLayer.CreateGroup(TvConstants.TvGroupNames.AllChannels);

    Both SetDefaultProviderConnectionString and CreateGroup throw the same exception.

    The connection string is the same as in gentle.config, which works fine in MediaPortal itself.

    Both MP and my app are on the same PC.

    If I revert back to a previous version of my app which uses the v1.2 MP dll's it works fine again.

    The DLL's references in my app was originally from MP v1.2, the TV Server was 1.6, this was working fine.
    Perhaps there was a change in the dll v1.3 or higher?
     
    Last edited:

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    I'm confused by all the version numbers! ;)
    Basically all I can suggest is to ensure:
    1. You recompile your application against DLL versions which are consistent with the version of TV Server that you've installed.
    2. The installed versions of TV Server, MediaPortal and the MediaPortal TV/radio plugin should match.
    3. All required DLLs are available to your application.
    If I revert back to a previous version of my app which uses the v1.2 MP dll's it works fine again.
    The DLL's references in my app was originally from MP v1.2, the TV Server was 1.6, this was working fine.
    Perhaps there was a change in the dll v1.3 or higher?
    Yes, it is entirely possible there was a change in any one of the TV Server interface DLLs. They can, have and will change over time.
    As per (1) above: you should attempt to recompile your application against the new DLLs if you want your application to work.
    Possibly this change is relevant:
    https://github.com/MediaPortal/MediaPortal-1/commit/b476adced54dcec6048b9d94b21c4eba29b10bd6

    Beyond that I can't help unless you can provide the full source code for your application.
     

    K24A3

    MP Donator
  • Premium Supporter
  • May 1, 2010
    78
    4
    Home Country
    1. Yep done that, MP + TV Server is 1.7. The DLL's are from the 1.7 source code.
    2. Everything is 1.7. Double checked, all good.
    3. Yes, I have downloaded the SVN 1.7 source (as of today's snapshot). The referenced DLL's are 1.7 in SharpDevelop, no compile errors.

    Thanks for the link, I had a look at the changes, nothing seems obvious that would reflect the issues I am seeing.

    On a side note, when I updated the DLL's from 1.2 to 1.7, log4net.dll assembly was missing, I added it from the 1.7 MP source code which resolved that problem.

    My app is quite large, the code posted is basically the only code that initializes the MP interaction. No need to post all the other code.

    As for the version numbers (same PC):

    WORKING:
    MediaPortal App v1.6
    TV Server 1.6
    DLL's in my app: 1.2


    EXCEPTION THROWN:
    MediaPortal v1.7
    TV Server 1.7
    DLL's in my app: 1.7


    The problem is not a big deal, it all works fine if I use the v1.2 DLL's, they work fine with MP 1.7.
    I like to keep things up to date so I updated the DLL's to 1.7 but ran into this problem.

    As long as the 1.2 DLL's work fine I'm happy, no need to spend time resolving this issue at this stage.
     

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    Yes, I have downloaded the SVN 1.7 source
    You mean git, right?

    Thanks for the link, I had a look at the changes, nothing seems obvious that would reflect the issues I am seeing.
    Well, for example you're not calling SetDefaultProvider like our code does.

    My app is quite large, the code posted is basically the only code that initializes the MP interaction. No need to post all the other code.
    Sometimes the smallest things matter (eg. SetDefaultProvider above). If you don't want to post the full code that is fine, but then we can't help you further.

    On a side note, when I updated the DLL's from 1.2 to 1.7, log4net.dll assembly was missing, I added it from the 1.7 MP source code which resolved that problem.
    Not sure exactly where you were expecting it to be such that you think that it is missing?
     

    K24A3

    MP Donator
  • Premium Supporter
  • May 1, 2010
    78
    4
    Home Country
    Yes I meant git. log4net was the only compile error after updating the dll's to 1.7 so I thought there was a slight chance log4net was causing the problem.

    I tried adding Reset and SetDefaultProvider but it is throwing the same exception on both those lines. The strings are from gentle.config.

    My app launches and then calls the below function when a button is clicked. All the other code is irrelevant.

    Code:
    using System;
    using System.Collections.Generic;
    using TvDatabase;
    using Gentle.Framework;
    using TvControl;
    using TvEngine.Events; //ITvServerEvent
    using TvLibrary;
    using TvLibrary.Epg;
    using TvLibrary.Implementations;
    using TvLibrary.Interfaces;
    using TvLibrary.Implementations.Analog;
    using TvLibrary.Implementations.DVB;
    
     TvBusinessLayer tvBusinessLayer = null;
    
            public void Initialize()
            {
                try
                {
                  
                    Global.Debug("Initializing TVData...");
                   
                    tvBusinessLayer = new TvBusinessLayer();
                   
                    if(tvBusinessLayer == null)
                    {
                        Global.Debug("ABORT: TvBusinessLayer is NULL");
                        return;
                    }
                   
                    Gentle.Framework.ProviderFactory.ResetGentle(true); // exception
                    Gentle.Framework.ProviderFactory.SetDefaultProvider("MySQL"); // exception
                   
                    string sConn = "Server=PC2;Database=MpTvDb;User ID=root;Password=MediaPortal;charset=utf8;Connection Timeout=30;";
                    Gentle.Framework.ProviderFactory.SetDefaultProviderConnectionString(sConn); // exception
    
                   
                    tvBusinessLayer.CreateGroup(TvConstants.TvGroupNames.AllChannels);
    
    
                   
                    Global.Debug("Number of channels: "+tvBusinessLayer.Channels.Count);
                   
                   
                   
                    Global.Debug("TVData populate channels...");
                   
                   
    
                    // Plugin events
                    SetupPluginEvents();
                   
                   
                    // Init flag OK
                    bInitialized = true;
                    Global.Debug("Initializing TVData...DONE");
                   
                    // Populate channels
                    PopulateChannels();
                   
                }
                catch(Exception ex)
                {
                    Global.Debug("TVData Initialize EXCEPTION: "+ex.ToString());
                    Global.DelayedError(ex.Message);
                }
            }
     

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    Following the stack trace down it just looks like gentle is failing to configure itself.
    Have you moved your application or any of its configuration to a different location?
    Have you put a gentle.config file in a location that gentle will find?
    What does your <app>.config file look like?
     

    K24A3

    MP Donator
  • Premium Supporter
  • May 1, 2010
    78
    4
    Home Country
    My app is in the same location, nothing has changed. I code the app on another PC and copy and overwrite the EXE and DLL's over to the TV PC.
    If I copy over the previous EXE and v1.2 TvEngine3 DLL's the TvBusinessLayer works fine again.
    Configuration has not changed at all except for the updated DLL references.
    gentle.config is in the same location as my app's exe file. If I delete gentle.config it throws a different exception saying it cannot find the gentle configuration.

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <configSections>
            <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
                <section name="MPApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
    <!--            <section name="SampleApplication.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />            -->
    <!--            <section name="MPApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e08a" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
                <section name="SampleApplication.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />-->
            </sectionGroup>
        </configSections><startup>
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
        </startup>
        <runtime>
            <legacyUnhandledExceptionPolicy enabled="1" />
        </runtime>
        <userSettings>
            <MPApp.Properties.Settings>   
            </MPApp.Properties.Settings>
        </userSettings>
    </configuration>
     

    Users who are viewing this thread

    Top Bottom