I've tried to implement an azure functions but keep getting the following exception.
"TypeLoadException: Could not load type 'System.UriTemplate' from assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
It seems that there's a few other who get the same exceptions. https://github.com/Azure/azure-functions-host/issues/3568
I've implemented my solution with .NETCore 3.0 and AzureFunctions with v2.0 and use WindowsAzure.ServiceBus v6.0.0, System.private.ServiceModel 4.6.0 and System.ServiceModel.Primitives 4.6.0. As far as i can tell there shouldn't be problem with versions but at this point I'm not sure.
In the link there are quite a few workaround and I've tried them but with no result. In all of them I've changed the file structure to match mine. ( I know some of them are meant for other types of projects and so on but none the less it was worth a shot).
<Target Name="FixForDotnetWcfIssueBuild" BeforeTargets="PostBuildEvent"> <Copy SourceFiles="$(OutputPath)bin\runtimes\win\lib\netstandard2.0\System.Private.ServiceModel.dll" DestinationFolder="$(OutputPath)bin" /> </Target>
<Target Name="FixForDotnetWcfIssuePublish" AfterTargets="AfterPublish"> <Copy SourceFiles="$(PublishDir)bin\runtimes\win\lib\netstandard2.0\System.Private.ServiceModel.dll" DestinationFolder="$(PublishDir)bin" /> </Target>
So to me it seems that WindowsAzure.ServiceBus 6.0.0 isn't compatible with .NETCoreApp v3.0.
Hopefully someone knows something I don't and are willing to help and I've told enough to solve this puzzle.
Azure Function has two Versions. One is based on .NET Framework and another is based on .NET Core. From your description, seems you are using .NET Core 3.0
, Function v2.0
.
Your project use WindowsAzure.ServiceBus v6.0.0
, but have you seen the instructions of this Nuget package?
https://www.nuget.org/packages/WindowsAzure.ServiceBus/
It is based on .NET Framework.
if you using this package on the false technical stack, off course this exception will appear.