Legacy Dev Forum Posts

 View Only

Sign Up

Type initializer exception

  • 1.  Type initializer exception

    Posted 06-05-2025 18:06

    scm_pa | 2022-06-08 13:36:08 UTC | #1

    Hi. I have a .NET app that is throwing a type initialization error when executing the following code.

    Configuration.Default.ApiClient.ClientSecret = CLIENT_SECRET;

    The exception is System.TypeInitializationException HResult=0x80131534 Message=The type initializer for 'PureCloudPlatform.Client.V2.Client.Configuration' threw an exception. Source=TjuContactImport StackTrace: at TjuContactImport.MainWindow.GetExternalContacts() in D:\TjuContactImport\TjuContactImport\MainWindow.xaml.cs:line 86 at TjuContactImport.MainWindow..ctor() in D:\TjuContactImport\TjuContactImport\MainWindow.xaml.cs:line 42

    Inner Exception 1: TypeLoadException: Could not load type 'RestSharp.IRestClient' from assembly 'RestSharp, Version=108.0.1.0, Culture=neutral, PublicKeyToken=598062e77f915f75'.

    In my project I'm using the latest nuget package for PureCloudPlatform.Client.V2 (ver 146.0.0) and RestSharp looks to be the latest version as well, ver 108.0.1

    Thank you.


    scm_pa | 2022-06-08 14:20:31 UTC | #2

    UPDATE: I downgraded the PureCloud package to 145.0.4 and RestSharp to 106.13.0 to clear up the error. I would still like to understand why the error occurs when using the latest of both packages.


    anon11147534 | 2022-06-08 14:33:27 UTC | #3

    Hi,

    I also got a different error when using the latest version of both packages but using the downgraded package versions solved it. I'll have to look further into the issue. It also works for me if I don't manually include RestSharp in the project as a dependency.


    Eos_Rios | 2022-06-08 15:09:56 UTC | #4

    This is possibly due to the breaking changes from Rest Sharp 107 not having been accounted for in the SDK yet.

    https://restsharp.dev/v107/#restsharp-v107

    if the SDK is compiled against an earlier version you including a newer in your own project would cause conflicts like described.


    scm_pa | 2022-06-08 15:43:30 UTC | #5

    I would say you're correct. Using the latest PureCloud package I don't get the error if the RestSharp package stays below ver 107.

    Thanks


    John_Carnell | 2022-06-10 14:11:13 UTC | #6

    Hi guys,

    We are looking at the issue. We don't have an ETA for a fix yet, but we will post to this thread once we have something sorted out.

    Thanks, John Carnell Manager, Developer Engagement


    scm_pa | 2022-06-10 14:23:23 UTC | #7

    Thank you for the update.


    anon11147534 | 2022-06-10 14:33:06 UTC | #8

    We will update to the latest version of RestSharp. I can't guarantee exactly when we will release the update but we'll include a message in the release notes when it happens.


    system | 2022-07-11 14:33:40 UTC | #9

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 15055