Search code examples
azureasp.net-coreazure-functionsasp.net-core-2.1servicemodelex

Service Model Assembly Error With Azure Functions V2+ (.net Core 2.1)


I have been using azure function V2(.net core 2.1) in my azure function app. I have been using System.ServiceModel.Primitives nuget for my function App which uses ServiceBusEnvironment packages in it.

I am able to compile the code and run the function. While calling the function I get this runtime error.

   Could not load type 'System.ServiceModel.Channels.IBindingRuntimePreferences' 
from assembly 'System.ServiceModel, Version=4.0.0.0'

I googled up many things. But no luck.

I then tried by lowering my azure function from V2 to V1(.net Framework 4.7) and it started working again.

I need to know what I am doing wrong in case of V2. And how can I not get the error in case of V2? Is there any Resolution for the same?


Solution

  • I just came to a solution after lot of search that the azure function v2 is based on .net core and service bus libraries are not working well with v2(.net core)

    The only solution which I found was switching to V1 as Azure functions V1 supports .net FrameWork classes.