rpgmaker / NetJSON

Faster than Any Binary? Benchmark: http://theburningmonk.com/2014/08/json-serializers-benchmarks-updated-2/
MIT License
225 stars 29 forks source link

Could not load type 'TenantClass' #228

Closed dev-day closed 1 year ago

dev-day commented 4 years ago

Hi,

When I compile the web app, on first click, I get this error. Refreshing, the error goes away for good.

Could not load type 'TenantClass' from assembly 'NetJSONGeneratedAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

When I restart the app, the error comes back once, and then goes away again after refresh.

Is there a specific setting I need to apply to prevent this?

Regards, Dev

rpgmaker commented 4 years ago

Hi, what version, and what framework target are you using?

Could you also post the full exception stack trace if possible

Thanks,

dev-day commented 4 years ago

Hi,

Thank you fo getting back to me,

It's .NET Framework 4.7 and using .NETJSON v 1.3.2

Every time we publish the webapp to Azure, we get the error but on refresh, it goes away and doesn't come back until we restart or republish.

The full stack trace is below.

[TypeLoadException: Could not load type 'TenantClass' from assembly 'NetJSONGeneratedAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.]    List1PlansClass.SetPlans(Char* , Int32& , Plans , String , NetJSONSettings ) +0    List1PlansClass.CreateClassOrDictPlans(Char , Int32& , NetJSONSettings ) +644    List`1PlansClass.CreateListListPlans(Char , Int32& , NetJSONSettings ) +112    List1PlansClass.ReadListPlans(String , NetJSONSettings ) +57    List1PlansClass.Deserialize(String , NetJSONSettings ) +11    NetJSON.NetJSON.Deserialize(String json, NetJSONSettings settings) +58    Nuqlium.v2.Models.BillingFunctions.ListPlans(String currentPlan, String path, String BespokePlan) in H:\Workspaces\Nuqlium\Nuqlium.v2\Nuqlium.v2.Shared\Models_Core\Billing\BillingFunctions.cs:317    Nuqlium.v2.Controllers.BaseController.Initialize(RequestContext requestContext) in H:\Workspaces\Nuqlium\Nuqlium.v2\Nuqlium.v2\Controllers\BaseController.cs:184    System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +157    System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +16    System.Web.Mvc.<>c.b20_0(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +54    System.Web.Mvc.Async.WrappedAsyncVoid1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30    System.Web.Mvc.Async.WrappedAsyncResultBase1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128    System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +427    System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +48    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +443    System.Web.<>c__DisplayClass285_0.b0() +24    System.Web.StepInvoker.Invoke(Action executionStep) +100    System.Web.<>cDisplayClass4_0.b0() +17    Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule.OnExecuteRequestStep(HttpContextBase context, Action step) +64    System.Web.<>cDisplayClass284_0.b0(Action nextStepAction) +54    System.Web.StepInvoker.Invoke(Action executionStep) +84    System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +100    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +163

Regards, Dev

rpgmaker commented 4 years ago

It looks like the issue might be related to multiple threads in your application trying to generate the assembly for the type.

You should consider doing the following as described here: NetJSON.GenerateTypesInto(string asmName, params Type[] types)

Using the above let you gain better performance by allowing you to distribute an assembly that contains the types you want and with the assembly name of your chosen.

https://github.com/rpgmaker/NetJSON/wiki/Quick-Guide

rpgmaker commented 4 years ago

Does the suggestion help or are you looking for a different solution that will prevent the startup issue?>

dev-day commented 4 years ago

Hi rpgmaker,

Thank you for your help and thank you for the follow up too.

I have a high volume of types, so I don't think it's suitable for my application to list all of them. The tenantClass error only happens on first load.

I'm examining other solutions - I may have some additional questions for you!

Regards, Dev

rpgmaker commented 4 years ago

If you can create a simple project reproducing this issue then I can try to find a better solution for you.

rpgmaker commented 4 years ago

I have not forgotten about this. Just been busy recently.

rpgmaker commented 3 years ago

Is this still an issue?

rpgmaker commented 1 year ago

Closing issue. Reopen if it is still need @dev-day