System.UriFormatException: Invalid URI: The hostname could not be parsed. #479
See original GitHub issueDescribe the bug
Facing this exception while testing with dotnet test on ubuntu-latest on Azure DevOps:
I still have no idea of the value that DefaultAssemblyDirectoryFormatter
is passing to Uri from the Assembly, no idea which Assembly in this the loop.
The assembly directory depends on what framework you’re using, among other things, like whether you bundled the entrypoint project into a single DLL solution or not. This isn’t exactly a RazorLight question, though.
The project is not bundle into a single DLL. This is happening during test on ubuntu. I’m trying to debug to see what Assembly is causing the error, but anyway simply passing Assembly.Location
over to UriBuilder
is known to cause problems. Don’t we need a check?
To Reproduce Steps to reproduce the behavior: Just run tests on a setup with Embedded Resource Project.
Expected behavior Probably expect that you might get an assembly with no valid location, as according to https://github.com/dotnet/corert/issues/5467, the location may or may not exist, or could even be null.
Information (please complete the following information):
- OS: ubuntu-lastest (from azure devops)
- Platform: .NET 6.0
- RazorLight version: stable 2.0.0
- Are you using the OFFICIAL RazorLight package? Official
- Visual Studio version [ e.g Visual Studio Community 17.8.5 ] Azure Devops, .NET 6.0 sdk / MSTEST
Additional context It is a good practice to discuss before simply closing an issue. Thanks for understanding.
System.UriFormatException: Invalid URI: The hostname could not be parsed.
Stack Trace:
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
at System.Uri..ctor(String uriString)
at System.UriBuilder..ctor(String uri)
at RazorLight.Compilation.DefaultAssemblyDirectoryFormatter.GetAssemblyDirectory(Assembly assembly)
at RazorLight.Compilation.DefaultMetadataReferenceManager.<Resolve>b__12_2(Assembly p)
at System.Linq.Enumerable.SelectArrayIterator`2.ToList()
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at RazorLight.Compilation.DefaultMetadataReferenceManager.Resolve(Assembly assembly, DependencyContext dependencyContext)
at RazorLight.Compilation.DefaultMetadataReferenceManager.Resolve(Assembly assembly)
at RazorLight.Compilation.RoslynCompilationService.EnsureOptions()
at RazorLight.Compilation.RoslynCompilationService.get_ParseOptions()
at RazorLight.Compilation.RoslynCompilationService.CreateSyntaxTree(SourceText sourceText)
at RazorLight.Compilation.RoslynCompilationService.CreateCompilation(String compilationContent, String assemblyName)
at RazorLight.Compilation.RoslynCompilationService.CompileAndEmit(IGeneratedRazorTemplate razorTemplate)
at RazorLight.Compilation.RazorTemplateCompiler.CompileAndEmitAsync(RazorLightProjectItem projectItem)
at RazorLight.Compilation.RazorTemplateCompiler.OnCacheMissAsync(String templateKey)
at RazorLight.EngineHandler.CompileTemplateAsync(String key)
Issue Analytics
- State:
- Created a year ago
- Comments:20
Top GitHub Comments
@SerhiyBalan Can I get detailed info on your Linux environment, e.g., which linux distro and version and libc and glibc? Maybe best to open a new ticket. This is great - I should be able to figure out a better approach.
So far, the only solution I’ve found is to roll back to version 2.0.0-rc.3. It works well on Linux.