Skip to main content
Solved

Error indicium: System.InvalidCastException: Object must implement IConvertible.


Freddy
Forum|alt.badge.img+16
  • Thinkwise Local Partner Brasil
  • 528 replies

What does this error mean? 

 

2023-03-30T00:41:33.4825036+00:00 0HMPFQ6E1BU1B:00000002 [ERR] An unhandled exception occurred while processing the request. (ffba027a)
System.InvalidCastException: Object must implement IConvertible.
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at Indicium.Utils.ConversionUtils.ConvertToODataValue(Type destinationType, Object value) in C:\azp\agent\_work\1\s\src\Indicium\Utils\ConversionUtils.cs:line 28
   at Indicium.Controllers.TableController.<readColumnsODataResource>g__addPropertyToResource|8_0(CustomODataResource resource, TSFTableEntityType tableEntity, ColumnInfo columnInfo, Object value) in C:\azp\agent\_work\1\s\src\Indicium\Controllers\TableController.cs:line 365
   at Indicium.Controllers.TableController.readColumnsODataResource(CustomODataResource resource, IEdmNavigationSource navigationTarget, HashSet`1 eagerFileColumns, List`1 resourceSelectColumns, ITSFDataReader reader) in C:\azp\agent\_work\1\s\src\Indicium\Controllers\TableController.cs:line 348
   at Indicium.Controllers.TableController.GetResourceSet(SelectQuery query, IEdmNavigationSource navigationTarget, HashSet`1 eagerFileColumns, List`1 resourceSelectColumns, String serverTimingName) in C:\azp\agent\_work\1\s\src\Indicium\Controllers\TableController.cs:line 247
   at Indicium.Controllers.TableController.Get() in C:\azp\agent\_work\1\s\src\Indicium\Controllers\TableController.cs:line 167
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Indicium.Extensions.ApplicationBuilderExtensions.<>c.<<SameSiteOpenIDConnectInterceptor>b__0_0>d.MoveNext() in C:\azp\agent\_work\1\s\src\Indicium\Extensions\ApplicationBuilderExtensions.cs:line 57
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.InvokeCore(HttpContext context)
   at Indicium.Middleware.Security.AuthenticationHeadersMiddleware.InvokeAsync(HttpContext context) in C:\azp\agent\_work\1\s\src\Indicium\Middleware\Authentication\AuthenticationHeadersMiddleware.cs:line 48
   at Indicium.Middleware.Security.SecurityHeadersMiddleware.InvokeAsync(HttpContext context, ContentSecurityPolicyBuilder cspBuilder) in C:\azp\agent\_work\1\s\src\Indicium\Middleware\Security\SecurityHeadersMiddleware.cs:line 55
   at Indicium.Middleware.Messages.TSFMessagesMiddleware.Invoke(HttpContext context, IRootApplicationLoader rootApplicationLoader, TSFRequestContext requestContext) in C:\azp\agent\_work\1\s\src\Indicium\Middleware\Messages\TSFMessageMiddleware.cs:line 45
   at Indicium.Middleware.Telemetry.ServerTimings.ServerTimingsMiddleware.InvokeAsync(HttpContext context, ServerTimingsBuilder serverTimingsBuilder) in C:\azp\agent\_work\1\s\src\Indicium\Middleware\Telemetry\ServerTimings\ServerTimingsMiddleware.cs:line 43
   at Indicium.Middleware.ExceptionHandlingMiddleware.Invoke(HttpContext context, TSFRequestContext requestContext) in C:\azp\agent\_work\1\s\src\Indicium\Middleware\ExceptionHandlingMiddleware.cs:line 84

 

Best answer by Freddy

Hi Dick. 

I knew the column that was causing it, because it was the only one changed.. the point is that I had to show a date at the time zone of a user. this causes the date to show it with timezone info. Casting the result to the datetime2 of the model kept the error. What did work was a convert(datetime2,...)

coalesce(ftn.start_date_time,pt.start_actual,pt.start_planned) at time zone 'UTC' at time zone ptz.timezone							as start_date_time_1
          ,cast(coalesce(ftn.start_date_time,pt.start_actual,pt.start_planned) at time zone 'UTC' at time zone ptz.timezone    as datetime2)	as start_date_time_2
		  ,convert(datetime2,coalesce(ftn.start_date_time,pt.start_actual,pt.start_planned) at time zone 'UTC' at time zone ptz.timezone )		as start_date_time_3

 

 

 

View original
Did this topic help you find an answer to your question?
This topic has been closed for comments

2 replies

Forum|alt.badge.img+3

Hi Freddy,

It seems Indicium doesn’t know what to do with one of the datatypes when it wants to convert it on a GET request on one of the tables.

Do you know which http request is giving this error? Is this on a view or a table? It might be possible to figure out which column is giving the error by adding ?$select=<column1>,<column2> to the query string. This will help us finding out what can be the cause of this, by looking at the datatypes of the column. It can also be due to an expression column.

In the case of a view or an expression column, it is important to know the datatype sql server returned in that case, not the SF data type.

As a sidenote, I will look into providing a better error message, it should be easy to detect which table/column is giving an error to make this easier.


Freddy
Forum|alt.badge.img+16
  • Author
  • Thinkwise Local Partner Brasil
  • 528 replies
  • Answer
  • March 30, 2023

Hi Dick. 

I knew the column that was causing it, because it was the only one changed.. the point is that I had to show a date at the time zone of a user. this causes the date to show it with timezone info. Casting the result to the datetime2 of the model kept the error. What did work was a convert(datetime2,...)

coalesce(ftn.start_date_time,pt.start_actual,pt.start_planned) at time zone 'UTC' at time zone ptz.timezone							as start_date_time_1
          ,cast(coalesce(ftn.start_date_time,pt.start_actual,pt.start_planned) at time zone 'UTC' at time zone ptz.timezone    as datetime2)	as start_date_time_2
		  ,convert(datetime2,coalesce(ftn.start_date_time,pt.start_actual,pt.start_planned) at time zone 'UTC' at time zone ptz.timezone )		as start_date_time_3

 

 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings