.Net Core and ORM Profiler

Posts   
 
    
JSobell
User
Posts: 145
Joined: 07-Jan-2006
# Posted on: 05-Jun-2018 02:34:22   

I have to say that I always find getting the profiler to integrate to be something of a chore, as I always hit issues. We might need a documentation review with some more uptodate "getting the frgn thing to work" examples simple_smile

On a .NET Core 2.1 project I'm getting:


System.NullReferenceException: Object reference not set to an instance of an object.
  at at SD.Tools.OrmProfiler.Interceptor.InterceptorCore.GetDbProviderFactories()
  at at SD.Tools.OrmProfiler.Interceptor.InterceptorCore.OverwriteDbProviderFactories(Boolean useNonGenericFactoryWrappers)
  at at SD.Tools.OrmProfiler.Interceptor.InterceptorCore.Initialize(String applicationName, String serverName, Boolean useNonGenericFactoryWrappers)
  at at SD.Tools.OrmProfiler.Interceptor.InterceptorCore.Initialize(String applicationName)
  at Insight.Manager.AppHost.Configure(Container container) in C:\GitHub\insight-server\Manager\insight.manager\AppHost.cs:67
  at at ServiceStack.ServiceStackHost.Init()
  at at ServiceStack.NetCoreAppHostExtensions.UseServiceStack(IApplicationBuilder app, AppHostBase appHost)
  at Server.KestrelStartup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime applicationLifetime) in C:\GitHub\insight-server\Manager\insight.manager\KestrelStartup.cs:41

Any suggestions? This is all coming about because a previously working (but horrible) query written by a past employee now gives an error.


SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of a retrieval query: The multi-part identifier "LPLA_4.QuestionnaireVersionId" could not be bound.
The multi-part identifier "LPLA_4.QMLX" could not be bound.
The multi-part identifier "LPLA_4.QuestionnaireVersionId" could not be bound.
The multi-part identifier "LPLA_4.ProjectDLL" could not be bound.
The multi-part identifier "LPLA_4.ProjectXML" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception. ---> System.Data.SqlClient.SqlException: The multi-part identifier "LPLA_4.QuestionnaireVersionId" could not be bound.
The multi-part identifier "LPLA_4.QMLX" could not be bound.
The multi-part identifier "LPLA_4.QuestionnaireVersionId" could not be bound.
The multi-part identifier "LPLA_4.ProjectDLL" could not be bound.
The multi-part identifier "LPLA_4.ProjectXML" could not be bound.
  at at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
  at at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
  at at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
  at at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
  at at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
  at at System.Data.SqlClient.SqlDataReader.get_MetaData()
  at at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
  at at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
  at at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite, String method)
  at at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
  at at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
  at at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
  at at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.<>c__DisplayClass12_0.<Execute>b__0()
  at at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.TagAndExecuteCommand[TReturn](Func`1 toExecute)
  at at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
  --- End of inner exception stack trace ---
  at at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
  at at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.FetchDataReader(IRetrievalQuery queryToExecute, CommandBehavior readerBehavior)
  at at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.FetchProjection(List`1 valueProjectors, IGeneralDataProjector projector, IRetrievalQuery queryToExecute, Boolean performValueProjectionsOnRawRow, Boolean postProcessDBNullValues, Dictionary`2 typeConvertersToRun)
  at at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.FetchProjection(List`1 valueProjectors, IGeneralDataProjector projector, QueryParameters parameters)
  at at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.<>n__21(List`1 valueProjectors, IGeneralDataProjector projector, QueryParameters parameters)
  at at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.<>c__DisplayClass22_0.<FetchProjection>b__0()
  at at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteWithActiveRecoveryStrategy(Action toExecute)
  at at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchProjection(List`1 valueProjectors, IGeneralDataProjector projector, QueryParameters parameters)
  at at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProvider2.ExecuteValueListProjection(QueryExpression toExecute)
  at at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.ExecuteExpression(Expression handledExpression, Type typeForPostProcessing)
  at at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.PerformExecute(Expression expression, Type resultType)
  at at SD.LLBLGen.Pro.LinqSupportClasses.LLBLGenProProviderBase.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
  at at System.Linq.Queryable.First[TSource](IQueryable`1 source)
  at LLBLGen_Command_Repositories.SurveySetRepository.Get(Guid surveySetId) in C:\GitHub\insight-server\Manager\Repositories\Command.Repositories\SurveySetRepository.cs:928
  at Insight.Jobs.PreExecution.DeployAndPublishJobPreExecutionHandler.AllowedToSchedule(IJobRepository jobRepository, DeployAndPublishJobDetails deployAndPublishJobDetails) in C:\GitHub\insight-server\Manager\Hangfire\Insight.Jobs.PreExecution\DeployAndPublishJobPreExecutionHandler.cs:34
  at Insight.Jobs.Infrastructure.JobScheduler.Schedule[TJobPreExecutionHandler,TJobExecutionHandler,TJobDetails](TJobPreExecutionHandler jobPreExecutionHandler, TJobDetails job) in C:\GitHub\insight-server\Manager\Hangfire\Insight.Jobs.Infrastructure\JobScheduler.cs:31
  at Insight.Manager.ServiceInterface.SurveyService.Post(CreateSurveyDeployJobRequest deployJobRequest) in C:\GitHub\insight-server\Manager\Service.Interface\SurveyService.cs:765
  at at lambda_method(Closure , Object , Object )
  at at ServiceStack.Host.ServiceRunner`1.ExecuteAsync(IRequest req, Object instance, TRequest requestDto)

The query raising it is awful but valid (or at least used to be) so I'm trying to intercept the generated query to help debug it so I can replace it with a view or a TypedList:


                var result = from questionnaireSet in db.QuestionnaireSet
                    join questionnaire in db.Questionnaire on questionnaireSet.QuestionnaireSetId equals questionnaire
                        .QuestionnaireSetId
                    join version in db.QuestionnaireVersion on questionnaire.QuestionnaireId equals version
                        .QuestionnaireId into version_temp
                    where questionnaireSet.QuestionnaireSetId == surveySetId
                    from version in
                        version_temp.DefaultIfEmpty() // outer join required as live survey may not have any versions
                    join versionFiles in db.QuestionnaireVersionFile on version.QuestionnaireVersionId equals
                        versionFiles.QuestionnaireVersionId into versionFiles_temp
                    join versionXml in db.QuestionnaireXml on version.QuestionnaireVersionId equals versionXml
                        .QuestionnaireVersionId into versionXml_temp
                    from versionFiles in versionFiles_temp.DefaultIfEmpty()
                    from versionXml in versionXml_temp.DefaultIfEmpty()
                    select new
                    {
                        SurveySet = questionnaireSet,
                        Questionnaire = questionnaire,
                        Version = version,
                        VersionFiles = versionFiles,
                        VersionXml = versionXml
                    };

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Jun-2018 08:21:07   

JSobell wrote:

I have to say that I always find getting the profiler to integrate to be something of a chore, as I always hit issues. We might need a documentation review with some more uptodate "getting the frgn thing to work" examples simple_smile

On a .NET Core 2.1 project I'm getting:


System.NullReferenceException: Object reference not set to an instance of an object.
  at at SD.Tools.OrmProfiler.Interceptor.InterceptorCore.GetDbProviderFactories()
  at at SD.Tools.OrmProfiler.Interceptor.InterceptorCore.OverwriteDbProviderFactories(Boolean useNonGenericFactoryWrappers)
...

Which version of ORMProfiler are you using? I think that .NET Core 2.1 is not officially supported yet. These are the versions supported by ORMProfiler v1.5:

.NET versions supported: .NET 3.5, .NET 4.0, .NET 4.5.x, .NET 4.6.x, .NET 4.7.x

Also, .NET Core 2.x doesn't have a DbProviderFactories storage, you have to register the factory manually, as .NET core doesn't have a machine.config file where factories are registered on .net full.

JSobell wrote:

The query raising it is awful but valid (or at least used to be) so I'm trying to intercept the generated query to help debug it so I can replace it with a view or a TypedList:


                var result = from questionnaireSet in db.QuestionnaireSet
                    join questionnaire in db.Questionnaire on questionnaireSet.QuestionnaireSetId equals questionnaire
                        .QuestionnaireSetId
                    join version in db.QuestionnaireVersion on questionnaire.QuestionnaireId equals version
                       ...

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 05-Jun-2018 09:05:29   

Regarding .NET Core and ORM Profiler: ORM Profiler doesn't support .NET Core at all. The main reason is that ORM Profiler relies on binary serialization and binary serialization of e.g. types is broken in .NET Core 2.0 (and 2.1), as Microsoft hasn't made the necessary types binary serializable. (just a handful of types in the BCL are binary serializable in .net core). To change this we have to overhaul the data serialization between interceptor and client, which is currently not planned.

for .NET Full, it's actually really simple: just specify the interceptorcore.initialize() call at the start of the program and it works. But in .NET core, that won't help, it simply won't work there at all, I'm sorry.

Frans Bouma | Lead developer LLBLGen Pro
JSobell
User
Posts: 145
Joined: 07-Jan-2006
# Posted on: 05-Jun-2018 09:21:43   

Otis wrote:

... But in .NET core, that won't help, it simply won't work there at all, I'm sorry.

Ah, that's a real bummer. When you're using things like SQL on AWS it's much tricker to quickly hook on to do things like profiling, so something like the profiler would have been awesome. Thanks anyway.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 05-Jun-2018 13:34:28   

yeah I hear you, it's something we have to address at some point, as more and more people move to .net core so orm profiler becomes less and less usable in that case. Problem is, it's not a simple change, as adding this in e.g. an interceptor for .net core 2.0+ requires an updated client as well. But we'll see what we can do later this year. simple_smile

Frans Bouma | Lead developer LLBLGen Pro