Closed introspection3 closed 3 years ago
Can you provide more of the stack trace?
@HamiltonManalo Does your fix for #352 address this?
@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 Hi,so sorry ,I'm late. you can use .net core with MySql.Data(Contains libzstandard)
@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?
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.ConfiguredTaskAwaitable
1.ConfiguredTaskAwaiter.GetResult()
at RazorLight.EngineHandler.1.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.TaskAwaiter
1.GetResult()
at Common.WebApi.ApiDefaultController.
It may allow a work around by excluding those particular assemblies-->NOT WORK
@HamiltonManalo HI?HOW TO RESOLVE IT
@jzabroski sir ,how to resove it
@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.
@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.
@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.
I see, you can use ZStandardNet
when project contains an unmanaged dll
Are you referring to this package https://github.com/bp74/Zstandard.Net
yes ,we pack mysql.data( own),and mysql.data refer it (contains libzstd.dll)
@jzabroski Have you fixed it?
@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.
@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?
My csproj has
MySQL.data verison 8.0.21
@codeneno Please look at the master branch (above commit hash tag for specific moment in time). I cannot reproduce this issue. Can you please play with the sandbox and submit a PR with an example where this is broken?
I have a feeling that you might be using ServiceCollection incorrectly, and that your ServiceCollection is pulling in eagerly all assemblies. You can use MetadataLoadContext which is the reflective dual to AssemblyLoadContext for choosing what assemblies to load.
I added another sandbox example where I explicitly instantiate ZStandardDictionary and load the sample file Bernhard provides in https://github.com/bp74/Zstandard.Net/blob/master/Zstandard.Net.Sandbox/loremipsum.zdict - still no repro.
Added a third example where no repro is possible.
@jzabroski in DefaultMetadataReferenceManager.cs
public IReadOnlyList<MetadataReference> Resolve(Assembly assembly)
{
var dependencyContext = DependencyContext.Load(assembly);
return Resolve(assembly, dependencyContext);
}
DependencyContext.Load method All the dependent packages will be loaded in,If you include unmanaged assemblies, they will also be loaded。
@softlgl Can you please edit the csproj - I posted three examples where I couldn't get it to fail. Including a ridiculously unnecessarily complicated one where I tried everything I could to break it. I even used two different versions of Zstd.
I think, most likely, this bug is somewhere in your code, and not RazorLight. But if you have a repro, I will re-open. Thank you.
I forgot to check in loremipsum.zdict for examples 2 and 3. It is in master now. Sorry about that.
Unpinning and locking thread. Please open a new ticket with a minimal repro if you still believe RazorLight is at fault.
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):
Additional context Add any other context about the problem here.