Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method 'WriteTo' does not have an implementation #450

Open
junalmeida opened this issue Jun 14, 2021 · 41 comments
Open

Method 'WriteTo' does not have an implementation #450

junalmeida opened this issue Jun 14, 2021 · 41 comments

Comments

@junalmeida
Copy link

junalmeida commented Jun 14, 2021

Describe the bug
RazorLight is throwing the following exception when running engine.CompileRenderAsync

System.TypeLoadException: Method 'WriteTo' in type 'RazorLight.Internal.ViewBuffer' from assembly 'RazorLight, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
   at RazorLight.TemplateRenderer.RenderPageAsync(ITemplatePage page, PageContext context, Boolean invokeViewStarts)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)

To Reproduce
It seems like an incompatibility between dependencies, but I couldn't figure out exactly which one.

Expected behavior
It seems the said WriteTo method in ViewBuffer class is a reference of the interface IHtmlContent, in the assembly Microsoft.AspNetCore.Html.Abstractions v2.1.0. The weird part is that this nuget package is apparently abandoned, the link to the project points to an archived repository, and I expect to see AspNetCore being on version 3.1, not 2.1.

Information (please complete the following information):

  • OS: Windows 10
  • Platform: Net Core 3.1
  • RazorLight version: 2.0.0-rc.3
  • Are you using the OFFICIAL RazorLight package? yes
  • Visual Studio version: Visual Studio Community 2019 16.10.1 ]
@darnmason
Copy link

I have just started experiencing the same exception running in Azure Functions, was just trying to figure out what changed. It looks like it wasn't a change of the functions runtime version. I also didn't update RazorLight, been running RC3 for a while. I can't reproduce it locally.

Are you by any chance running it in Azure Functions? As my first instinct is it could be something they're doing - although I have set the _FunctionsSkipCleanOutput.

Mine is occurring in Azure Functions on Windows, .Net Core 3.1, RazorLight 2.0.0-rc3

@junalmeida
Copy link
Author

junalmeida commented Jun 28, 2021

Mine is occurring in AZ Functions local SDK on Windows, not occurring on az servers (yet). This is my csproj header:

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AzureFunctionsVersion>v3</AzureFunctionsVersion>
    <FunctionsInDependencies>true</FunctionsInDependencies>

    <AddRazorSupportForMvc>true</AddRazorSupportForMvc>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
    <MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
    <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
  </PropertyGroup>

@jzabroski
Copy link
Collaborator

What framework is your func.exe running against?

@junalmeida
Copy link
Author

I added the following code to my initialization method

Console.WriteLine($"Environment: {Environment.Version}");
Console.WriteLine($"TargetFrameworkName: {AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName}");

And this is the result:

Environment: 3.1.13
TargetFrameworkName: .NETCoreApp,Version=v3.1

@jzabroski
Copy link
Collaborator

Can you give me these files:

runtimeconfig.json
deps.json
global.json

@junalmeida
Copy link
Author

junalmeida commented Jun 28, 2021

runtimeconfig.json.txt
deps.json.txt
I don't have global.json

@darnmason
Copy link

Here's my latest startup event showing functions runtime 3.0.15961.

<Event>
  <System>
    <Provider Name="IIS AspNetCore Module V2"/>
    <EventID>1032</EventID>
    <Level>4</Level>
    <Task>0</Task>
    <Keywords>Keywords</Keywords>
    <TimeCreated SystemTime="2021-06-28T23:11:12Z"/>
    <EventRecordID>792258250</EventRecordID>
    <Channel>Application</Channel>
    <Computer>webwk000002</Computer>
    <Security/>
  </System>
  <EventData>
    <Data>Application 'C:\Program Files (x86)\SiteExtensions\Functions\3.0.15961\32bit\' started successfully.</Data>
    <Data>Process Id: 8368.</Data>
    <Data>File Version: 13.1.21133.16. Description: IIS ASP.NET Core Module V2 Request Handler. Commit: 7e8bbb70b266b2fdaf0b11ec47fb3077761fb6bf</Data>
  </EventData>
</Event>

I just have function.deps.json.txt and extensions.json.txt if they're any use.

@jzabroski
Copy link
Collaborator

I think the right way to solve this problem is to get the function.deps.json.txt for the version that is breaking and the prior version of the func.exe SDK and diff the two, as that will likely show where the issue is. Unfortunately, package search engines like nuget.org dont let you easily query when a method went missing.

@darnmason
Copy link

The key difference in mine looks like Azure.Core bumped from 1.8.1 to 1.15.0 due to adding a reference to Azure.Storage.Blobs.

@darnmason
Copy link

I downgraded Azure.Core to 1.8.1 and the issue is resolved.

So how can Azure.Core have this effect? And should we be creating an issue there?

@vascofernandes
Copy link

Having exactly the same problem as @darnmason .

@jzabroski
Copy link
Collaborator

I'm not sure but it probably has something to do with the order in which assembly binding occurs.

To confirm you will need to turn on logging.

@junalmeida
Copy link
Author

What logging do I need to turn on @jzabroski could you please specify the steps you think will help?

@jzabroski
Copy link
Collaborator

setx CORE_HOSTTRACE 1
and
see also: https://docs.microsoft.com/en-us/dotnet/core/dependency-loading/default-probing#how-do-i-debug-the-probing-properties-construction

I had contributed documentation to this probing page because I was getting a lot of tickets about assembly binding issues, mostly from Azure Functions customers. If you have a long lunch break and need to be bored to death, you can read the PR conversation which is somewhat interesting: dotnet/docs@160ab22

@junalmeida
Copy link
Author

I can see some references to HtmlAbstractions, which I quote below:

...
Adding runtime asset Microsoft.AspNetCore.Html.Abstractions.dll assemblyVersion=3.1.13.0 fileVersion=3.100.1321.11713 from runtimepack.Microsoft.AspNetCore.App.Runtime.win-x64/3.1.13
...
Reconciling library Microsoft.AspNetCore.Html.Abstractions/2.1.0
Library Microsoft.AspNetCore.Html.Abstractions/2.1.0 does not exist
...
Parsed runtime deps entry 160 for asset name: Microsoft.AspNetCore.Html.Abstractions from runtimepack: runtimepack.Microsoft.AspNetCore.App.Runtime.win-x64, library version: 3.1.13, relpath: Microsoft.AspNetCore.Html.Abstractions.dll, assemblyVersion 3.1.13.0, fileVersion 3.100.1321.11713
...
Processing TPA for deps entry [runtimepack.Microsoft.AspNetCore.App.Runtime.win-x64, 3.1.13, Microsoft.AspNetCore.Html.Abstractions.dll]
  Considering entry [runtimepack.Microsoft.AspNetCore.App.Runtime.win-x64/3.1.13/Microsoft.AspNetCore.Html.Abstractions.dll], probe dir [], probe fx level:0, entry fx level:0
    Local path query exists C:\Users\junior\AppData\Local\AzureFunctionsTools\Releases\3.23.5\cli_x64\Microsoft.AspNetCore.Html.Abstractions.dll
    Probed deps dir and matched 'C:\Users\junior\AppData\Local\AzureFunctionsTools\Releases\3.23.5\cli_x64\Microsoft.AspNetCore.Html.Abstractions.dll'
Adding tpa entry: C:\Users\junior\AppData\Local\AzureFunctionsTools\Releases\3.23.5\cli_x64\Microsoft.AspNetCore.Html.Abstractions.dll, AssemblyVersion: 3.1.13.0, FileVersion: 3.100.1321.11713
...

Does it make any meaning to you @jzabroski

@jzabroski
Copy link
Collaborator

Yes, it likely means that it is loading Microsoft.AspNetCore.Html.Abstractions 3.1.13

Assuming you are using the latest official rc https://www.fuget.org/packages/RazorLight/2.0.0-rc.3 , you can see we are linking to 3.1.5, so that will blow up.

The problem is that "roll forward" technology does not work at runtime, I think (but am not 100% sure about that, but I would wager that is true). So, in the old days of .NET, binding Redirects would work across compile time and run-time, so you would say 0.0.0.0-12.0.0.0 -> 12.0.0.0. But with roll forward, it is all statically linked by the compiler once, and then rolled forward to the latest SDK target at the time dotnet run occurs, UNLESS you do a framework dependent deployment. HOWEVER, as you can infer, since a lot of people are running this in Azure, I dont think there is a way to run framework dependent deployment in Azure (but I use AWS and am definitely not an expert in selling Azure solutions to my clients, however rich it would make me).

@junalmeida
Copy link
Author

junalmeida commented Aug 5, 2021

At this time at least for me it is working well in azure servers. This affects me only when using the local func.exe tool. Questions for you @jzabroski:

  1. Is there any way you recommend to force the version needed for current 2.0.0-rc3?
  2. Does that mean newer versions of Html.Abstractions are not supported?
  3. Do you know any plans to make newer versions compatible with this library?

@jzabroski
Copy link
Collaborator

  1. Yes, you can implement your own "DirtyAssemblyResolveHelper". This is a trick various open source authors use for "framework libraries" where the library itself de facto injects a framework as a dependency, like Fody MSBuild Task, or BenchmarkDotNet, or FluentMigrator. See: https://github.com/fluentmigrator/fluentmigrator/blob/9c87d698b161b3a1bb596a5624c02891a64459c5/src/FluentMigrator.DotNet.Cli/Program.cs#L53-L117
  2. Hmm - I can't answer that since I have not tested it. What it means is that this probably explains why, for non self-contained deployments, some people run into issues using RazorLight. The reason I can't answer your question is for patch-level verison numbers, you would expect Microsoft would not remove public API methods, as that violates semver. But, c'est la vie :)
  3. @toddams mentioned he wanted to become more involved again in this project, so I thought he should decide some of this.

Some people were not happy with how I packaged 2.0.0 binaries in a .NET Core 3.0 context, but I explained that as a trade-off relating to Microsoft's decision to remove ASP.NET Core binaries from nuget and shipping them as an SDK that resides locally on disk, and the workaround would be to use their experimental tree shaking and do self-contained deployments. But that creates its own black hole of problems, since I don't personally feel the whole MSBuild SDK concept was particularly well designed. If you search GitHub, I argued that SDKs should be injectable dependencies, and the way target frameworks were designed was simply wrong. Warts like these are a symptom, but I doubt anyone at Microsoft deeply cares about 100% modular software and SDKs. The focus is more on optimization and efficient binaries, as that is directly mappable to economic benefits like higher operating margins for Azure. (Just my own 2 cents).

@junalmeida
Copy link
Author

The DirtyAssemblyResolveHelper is certainly a thing I will look at, but it is a more complex long-term workaround.
For now what I tried so far is: I removed all old netcore sdk versions, I now have only version 3.1.5 sdk installed, and according to the logs, it seems it is using the 3.1.13 version from func.exe itself.

The issue persists.

I compared both versions 3.1.5 and 3.1.13 (decompiling using JustDecompiler tool) and it seems IHtmlContent interface hasn't changed. Something is not adding up.

@jzabroski
Copy link
Collaborator

Is it using the version from func.exe itself, or from your current SDK on your disk. I am not super familiar with func.exe. Is it a self-contained deployment, or is it rolling forward to the latest patch version? func.exe itself should have a deps.json file in its exe directory, as well as runtimeConfig.json i think

@junalmeida
Copy link
Author

See attached both deps and runtimeConfig
func.deps.json.txt
func.runtimeconfig.json.txt

@jzabroski
Copy link
Collaborator

func.exe is loading 3.1.13, for sure:

 "targets": {
    ".NETCoreApp,Version=v3.1": {},
    ".NETCoreApp,Version=v3.1/win-x64": {
      "func/3.0.3442": {
        "dependencies": {
          "AccentedCommandLineParser": "2.0.0",
          "Autofac": "4.6.2",
          "Colors.Net": "1.1.0",
          "DotNetZip": "1.13.3",
          "Microsoft.AspNetCore.DataProtection": "2.2.0",
          "Microsoft.Azure.DurableTask.AzureStorage.Internal": "1.4.0",
          "Microsoft.Azure.Functions.JavaWorker": "1.8.2-SNAPSHOT",
          "Microsoft.Azure.Functions.NodeJsWorker": "2.1.0",
          "Microsoft.Azure.Functions.PowerShellWorker.PS6": "3.0.630",
          "Microsoft.Azure.Functions.PowerShellWorker.PS7": "3.0.629",
          "Microsoft.Azure.Functions.PythonWorker": "3.1.1.12",
          "Microsoft.Azure.WebJobs.Script.WebHost": "3.0.15417",
          "Newtonsoft.Json": "12.0.3",
          "YamlDotNet": "6.0.0",
          "runtimepack.Microsoft.NETCore.App.Runtime.win-x64": "3.1.13",
          "runtimepack.Microsoft.AspNetCore.App.Runtime.win-x64": "3.1.13"
        },
        "runtime": {
          "func.dll": {}
        }
      },

I don't think there is a great solution here. I had spoken to Immo Landwerth about these types of modularity problems, and I think it never got addressed (although I do think he wanted to at least respond to my comments if not address the issue).

In java, they have a "bind" tool that does co-constraints the guarantee a single binary version is loaded. It's not great but it's basically what is needed to solve run-time dependencies.

@junalmeida
Copy link
Author

junalmeida commented Aug 6, 2021

I think the problem is not exactly to load 3.1.13 as I can successfully create a "hello world" simple project using that version. I think the problem lives on indirect dependencies when a project starts to get large.
For eg I can see this:
image

In my prod case RazorLight is referenced on a NETStd20 project, which seem to have a lower requirement than the netcore3.1 entry point project.

@jzabroski
Copy link
Collaborator

jzabroski commented Aug 6, 2021

I think the problem is not exactly to load 3.1.13 as I can successfully create a "hello world" simple project using that version. I think the problem lives on indirect dependencies when a project starts to get large.

When you create a direct dependency, you opt in to roll forward. When you have an indirect dependency, it does not. So I believe we are saying the same thing.

The problem is that Roll Forward is based on the host executable. So you can create your own host and even specify Roll Forward LatestMajor, and it will Roll Forward that. But if you then dynamically load a different DLL version, Roll Forward doesnt know about that. The AssemblyLoadContext is literally just loading whatever DLL you give it. When that Assembly is unique, it will load correctly, but then calling functions in that assembly may fail if it transitively references another DLL with different version than one already in the AssemblyLoadContext.

Hope that is clear.

This is pretty complex stuff and nobody likes to admit how complex Microsoft made this. Unofficially, Microsoft's preference is people stop using anything that requires reflection/dynamic code loading and instead use C# Source Generators, as that opts in to the upstream gadgetry of MSBuild SDKs calculating the transitive closure of all static dependencies via ProjectReference and PackageReference, Roll Forward technology, etc.

@junalmeida
Copy link
Author

@jzabroski Thanks for your explanation.
I'm just trying to solve this problem in order to get going, unfortunately I can't and I'm totally stuck with this.

@jzabroski
Copy link
Collaborator

I'll see if I can find some time to play with func.exe.

@jzabroski
Copy link
Collaborator

Can you do me a favor and report your dotnet.exe --info command dump results

@jzabroski
Copy link
Collaborator

Also, while you wait for me, can you try just setting <PublishTrimmed>false</PublishTrimmed>. Again, given everything we have discussed and verified, the only explanation WriteTo would be missing is tree shaking, because the .NET docs say it exists in all versions of the runtime.

I also noticed this documentation - with .NET 5, Azure Functions added a new feature called Isolated Azure Functions which seems like a nicer architecture to me (at a quick glance) because it doesn't commingle the host with the plug-in. https://docs.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide

@junalmeida
Copy link
Author

@jzabroski

$ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.100-preview.6.21355.2
 Commit:    7f8e0d76c0

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19043
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.100-preview.6.21355.2\

Host (useful for support):
  Version: 6.0.0-preview.6.21352.12
  Commit:  770d630b28

.NET SDKs installed:
  3.1.301 [C:\Program Files\dotnet\sdk]
  6.0.100-preview.6.21355.2 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.6.21355.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-preview.6.21352.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-preview.6.21353.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

Yeah I saw that dotnet-isolated feature, however I can't upgrade from 3.1 to 5.0 atm. What I am currently experimenting is removing RazorLight from the netstd2.0 class library, and adding it exclusively to the functions entrypoint, which is a netcoreapp3.1 project. After doing that, now I'm getting a different error, the same as in this thread: https://stackoverflow.com/questions/68637512/razorlight-could-not-load-file-or-assembly-system-threading-accesscontrol
And just like the person, seems like a never ending loop.

I will give a try on <PublishTrimmed>false</PublishTrimmed>.

Thanks in advance for your kind help :D

@jzabroski
Copy link
Collaborator

jzabroski commented Aug 6, 2021

BTW, you can actually see Microsoft makes the same point I claim:

https://docs.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide#benefits-of-running-out-of-process

Fewer conflicts: because the functions run in a separate process, assemblies used in your app won't conflict with different version of the same assemblies used by the host process.

In other words, they're saying their original in-process architecture was a really bad idea. :D

@junalmeida
Copy link
Author

<PublishTrimmed>false</PublishTrimmed> doesn't seem to help, same errors.

@junalmeida
Copy link
Author

Unfortunately I'm using razor on a Durable Function, which is not yet supported by the isolated process method. :(
I'm still trying to understand why this error is happening with this project on my computer, and not happening on either other projects on the same computer and the same project on different computer. Seems like a combination of current installed libs, func version and the dependencies of my project.

@junalmeida
Copy link
Author

junalmeida commented Aug 7, 2021

Continuing on my investigation here @jzabroski, I created a small "hello world" function project, that works well, and then I started adding some of the dependencies I have on my real project, 1 by 1. It starts to give errors after I add the Azure.Storage.Queues dependency (mere fact to have it as dependency is enough, even if I'm not really using it on the test project). To be honest this makes absolutely no sense to me.

Video.mp4

@jzabroski
Copy link
Collaborator

jzabroski commented Aug 10, 2021

I am not sure, either, just yet. Can you try loading just Azure.Core nupkg and see if that breaks it when its in a netstandard2.0 context. I have a feeling they packaged that incorrectly.

The hard part with looking at this stuff, even with Nuget Package Explorer, is you have to know whats supposed to be "in box" vs. "out of box" (OOB) in the System namespace. OOB refers Microsoft-slang word for things that don't ship as part of the SDK but rather ship as nuget packages but live in the reserved System.* namespace on nuget.org - not to be confused with the C# namespace System even though they generally correspond 1:1. Think of it as batteries not included/sold separately.

See: https://nuget.info/packages/Azure.Core/1.15.0 - I dont have a firm intuition as to why the OOB version numbers are so inconsistent and its not easy to mentally reason about which SDKs which version is meant to go against. - This has been a longstanding complaint of mine that Microsoft hasn't addressed.

@junalmeida
Copy link
Author

I can see the problem happening when I simply add System.Text.Encodings.Web which is a dependency of Azure.Core.

@jzabroski
Copy link
Collaborator

jzabroski commented Aug 11, 2021

@junalmeida Thanks for that info. Based on a quick google search for System.Text.Encodings.Web azure.core error, it looks like if you file an issue with Azure Functions, they will simply close it as "by design" and tell you to use "the worker model":

Hi @notaroobob , Apologies for the delay, I was internally checking with the team with all the possibilities here. If you want to use durable functions, then you will have to downgrade the system.text.json to 3.x.x. From 5.x.x, you will have to use the worker model which do not support the durable functions.
-- Azure/Azure-Functions#1898 (comment)

Closing this issue as this is by-design, Please feel free to open a feature request here - https://feedback.azure.com/forums/355860-azure-functions
-- Azure/Azure-Functions#1898 (comment)

Did I ever mention how much I dislike Azure Functions and think they're a complete waste of everyone's time? It looks like out-of-process workers fix these problems, though. Unless you want to use durable functions. Then you should probably use the Durable Task Framework as a workaround. - I don't know if it would be a valid workaround but despite both having the word durable in it, there is nothing in common here between durable azure functions and the durable task framework. The guy who created the Durable Task Framework, @samarabbas, quit Microsoft and is basically selling a "low code" distributed computing framework inspired by the DTF. Durable Tasks are also only C# - whereas Durable Functions is supposed to be language agnostic.

The "worker model" the Microsoft employee refers to is the out-of-process model we just discussed. See: https://github.com/Azure/azure-functions-dotnet-worker

I do think, given Microsoft's rather funny comments that you can't upgrade System.Text.Json even one minor patch number without things breaking, that you should not spend any effort on the "in process" model and instead running everything "out of process." You can see my extended conversation with Microsoft about this, here: dotnet/standard#859 (comment)

Basically, we're in this situation because Microsoft decided binding redirects made customer support extremely difficult, because it exploded the number of library-version interactions that might occur. But, they did not solve the user story binding redirects made so easy to solve, which was a hamfisted DSL for resolving run-time assembly conflicts. As far as I can guess, the reason they don't want to solve this is it can't be checked by the compiler, and so it can produce less reliable systems.

@acmichaud
Copy link

Hi,
Any update on the Issue? I have the same problem here. I will try to implement the dirty loading but it would be nice to make it compatible with azure.core eventually.

Best regards!

@jzabroski
Copy link
Collaborator

jzabroski commented Aug 24, 2021

I will try to implement the dirty loading but it would be nice to make it compatible with azure.core eventually.

I think you misunderstood the conversation. It is not possible without dirty loading. Microsoft even said so. They built a plug-in architecture that does not allow safe loading of dynamically loaded plug-ins, including code written by Microsoft. Your only other option is to use out-of-process worker model, because it converts a dynamic plug-in into a static one. Please re-read. Thank you.

@rdhainaut
Copy link

rdhainaut commented Sep 9, 2021

I have encountered the same issue too.
I have read the thread and the only detail i don t really get it s why it happend now with this version (rc version) and not before ?

If i have well understand i must add this line in my csproj and the issue is gone.

<PropertyGroup>
  <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>

More info here: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/out-of-process-hosting?view=aspnetcore-5.0
Edit: It doesn t work for AzureFunction

I don t really understand all impacts of this line
If someone read this answer, can you tell me if it will have an impact on Azure ? thank you

@jzabroski
Copy link
Collaborator

@rdhainaut The reason is that it's a general problem with dynamic plug-in architecture that Microsoft has not solved in .NET Core/.NET 5/.NET 6. Who knows if they will ever solve it. That said, the property you're settling there is for IIS , NOT AzureFunctions. I doubt it will work for AzureFunctions. It looks like you can start your journey here : https://docs.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide#net-isolated-project

Note that section and the Package References section are requirements.

It's pretty involved and clumsy, in my opinion, but it should nonetheless work and the major benefit is you don't have to worry about Azure Functions terrible use of a dynamic plug-in model.

The same problem exists for Azure App Services.

@rdhainaut
Copy link

@jzabroski thanks for your explanation, your time and the link.

Just in case, I have found a workaround to make it works locally.
Generally, I launch several apps (a wep api and one azure function) locally via the Visual studio launching menu (and use Kestrel so).

The workaround is to open a windows terminal,
then go to the project root dir cd /path/to/AzureFunctionProject
and execute the command: func start

This time I have no error :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants