Type initializer exception

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.

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.

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.

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.

1 Like

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

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

Thank you for the update.

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.

1 Like

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