RazorLight icon indicating copy to clipboard operation
RazorLight copied to clipboard

there is a bug when our project contains an unmanaged dll.

Open introspection3 opened this issue 6 years ago • 27 comments

Describe the bug there is a bug when our project contains an unmanaged dll. System.NullReferenceException:“Object reference not set to an instance of an object.” To Reproduce Steps to reproduce the behavior: project contains a unmanaged dll, such as https://github.com/bp74/Zstandard.Net Expected behavior A clear and concise description of what you expected to happen.

Information (please complete the following information):

  • OS: [ e.g Ubuntu 16.04, Windows Server 2016, etc ] windows
  • Platform [.NET Framework 4.x / .NET Core 2.x , etc] .NET Core 3.x
  • RazorLight version [ e.g 2.0-beta9 ] 2.0-beta9
  • Are you using the OFFICIAL RazorLight package? https://www.nuget.org/packages/razorlight
  • Visual Studio version [ e.g Visual Studio Community 17.8.5 ]

Additional context Add any other context about the problem here.

introspection3 avatar Sep 17 '20 07:09 introspection3

Can you provide more of the stack trace?

jzabroski avatar Sep 17 '20 13:09 jzabroski

@HamiltonManalo Does your fix for #352 address this?

jzabroski avatar Sep 17 '20 13:09 jzabroski

@jzabroski It may allow a work around by excluding those particular assemblies. @564064202 Could you give an example package/dll you're running into issues with and I will see if I can test against that?

Thanks.

HamiltonManalo avatar Sep 17 '20 15:09 HamiltonManalo

@HamiltonManalo Hi,so sorry ,I'm late. you can use .net core with MySql.Data(Contains libzstandard)

introspection3 avatar Sep 19 '20 09:09 introspection3

@564064202 I tried to recreate it by adding RazorLight and the Nuget package and compiling templates but wasn't able to recreate it. Could you provide more details on where/how the error occurs and a stack trace? Does it look anything like the stack trace here #352?

HamiltonManalo avatar Sep 19 '20 10:09 HamiltonManalo

System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=RazorLight StackTrace: at RazorLight.Compilation.RoslynCompilationService.CompileAndEmit(IGeneratedRazorTemplate razorTemplate) at RazorLight.Compilation.RazorTemplateCompiler.CompileAndEmit(RazorLightProjectItem projectItem) at RazorLight.Compilation.RazorTemplateCompiler.OnCacheMissAsync(String templateKey) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at RazorLight.EngineHandler.<CompileTemplateAsync>d__15.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at RazorLight.EngineHandler.d__191.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Common.WebApi.ApiDefaultController.d__3.MoveNext() in Api\ApiDefaultController.cs:line 120

introspection3 avatar Sep 19 '20 11:09 introspection3

image It may allow a work around by excluding those particular assemblies-->NOT WORK

introspection3 avatar Sep 19 '20 11:09 introspection3

@HamiltonManalo HI?HOW TO RESOLVE IT

introspection3 avatar Sep 20 '20 02:09 introspection3

@jzabroski sir ,how to resove it

introspection3 avatar Sep 22 '20 00:09 introspection3

@564064202 I'm not sure yet. I am releasing 2.0.0-beta10 now, so hopefully that helps you out. You would have to do the guidance in #352 as part of trying it out.

jzabroski avatar Sep 22 '20 14:09 jzabroski

@564064202 I just pushed beta10 up now - it should show up in your feed within the next hour. The underlying theory as to why #352 would help you is it would allow you to exclude arbitrary assemblies from the compilation context. It should work if the issue is identical to #352 where the windows metadata dll is also unmanaged.

jzabroski avatar Sep 22 '20 14:09 jzabroski

@564064202 Unfortunately I wasn't able to recreate the bug by adding MySQL.Data. Could you reproduce the bug in a simple project and provide a repo for it? If you can I will look into it further.

HamiltonManalo avatar Sep 22 '20 16:09 HamiltonManalo

I see, you can use ZStandardNet

codeneno avatar Sep 23 '20 01:09 codeneno

when project contains an unmanaged dll

codeneno avatar Sep 23 '20 02:09 codeneno

Are you referring to this package https://github.com/bp74/Zstandard.Net

jzabroski avatar Sep 23 '20 02:09 jzabroski

yes ,we pack mysql.data( own),and mysql.data refer it (contains libzstd.dll)

codeneno avatar Sep 23 '20 02:09 codeneno

@jzabroski Have you fixed it?

introspection3 avatar Oct 07 '20 09:10 introspection3

@564064202 I will try to look at this issue this week.

@HamiltonManalo Do you have your code around still from your failed repro attempt? That would help jump start my investigation, thank you.

jzabroski avatar Nov 25 '20 17:11 jzabroski

@codeneno Silly question, but just so we're comparing apples to apples, what version of https://github.com/bp74/Zstandard.Net are you reproducing your problem with? Which TargetFramework? @564064202 Same - what version of Mysql.Data? I think they're removing some unmanaged dependencies, although I don't know how much remains unmanaged. Your csproj has <TargetFramework>.netcoreapp3.1</TargetFramework> and PackageReferences to Mysql.Data and RazorLight directly?

jzabroski avatar Nov 25 '20 17:11 jzabroski

My csproj has .netcoreapp3.1 and PackageReferences to Mysql.Data and RazorLight directly.

MySQL.data verison 8.0.21

codeneno avatar Nov 26 '20 01:11 codeneno