Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting [NotSupportedException: Generic types are not valid.] after upgrading version from 110.2.0 -> 112.0.0 #2264

Open
NeelamYangal opened this issue Sep 18, 2024 · 8 comments
Labels

Comments

@NeelamYangal
Copy link

Issue Description
I updated the RestSharp version from 110.2.0 to 112.0.0 and encountered the following issue immediately after the site loads:
[NotSupportedException: Generic types are not valid.]

Expected behavior
It should work as it did in version 110.2.0. I expect the same behavior even after upgrading.

Stack trace
[NotSupportedException: Generic types are not valid.]
EPiServer.Framework.Initialization.InitializationModule.EngineExecute(HostType hostType, Action`1 engineAction) +1384
EPiServer.Framework.Initialization.InitializationModule.FrameworkInitialization(HostType hostType) +226
EPiServer.Global..ctor() +42
GMGShop.Web.Global..ctor() +37
ASP.global_asax..ctor() in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\5a2314ef\7a3fa5aa\App_global.asax.0.cs:0

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +142
System.Activator.CreateInstance(Type type, Boolean nonPublic) +107
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +1473
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +186
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +28
System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +80
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +182
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +719

Additional Details
I investigated further to determine which version might have caused the issue and found that the problem exists with RestSharp version 111.3.0. (If it helps to understand the issue)

@techwithjyo
Copy link

Facing same issue in 112.0.0 version.

@alexeyzimarev
Copy link
Member

The issue can be easily resolved by using the latest .NET SDK (8+)

@zcs-git
Copy link

zcs-git commented Oct 31, 2024

Also getting this error after upgrading restsharp, site is using .net framework 4.8.1. I can upgrade to Restsharp 111.2.0 but anything later will result in "Generic Types are Invalid".

@alexeyzimarev
Copy link
Member

Are you getting it at runtime or when you build your code?

@zcs-git
Copy link

zcs-git commented Nov 7, 2024

I get that on runtime on all versions above 111.2.0 using .net framework 4.8.1

@techwithjyo
Copy link

Same here, Getting it in the runtime.

@alexeyzimarev
Copy link
Member

Ok, that's not good. I thought you get it at compile time. It's a bummer that the compiler allows it when building for .NET Framework target, but it cannot be executed. It can easily be fixed, it's not required to use generic attributes.

@zcs-git
Copy link

zcs-git commented Nov 7, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants