Reputation: 1573
I'm making an Http triggered Azure Function v4 in .NET 4.8 with Microsoft.NET.Sdk.Functions 1.0.24
and my test endpoints that do not reference any other assemblies work correctly.
However, when I try to use a method in a referenced assembly, I get the following error:
Could not load type 'System.Data.SqlClient.SqlParameter' from assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
at Example.Data.PeopleBiz.GetPersonByUserName(String username)
at Example.OperationFunc.DoItFunction.DoItEndpoint(HttpRequestMessage req, TraceWriter log)
I'm sorry I cannot post code due to confidentiality and the scale of the solution. I realize this probably restricts the assistance to people who have overcome this specific issue. Has anyone gotten a large .NET 4.8 Azure Function to work? Running locally in VS2022, this function works flawlessly.
Here are some relevant environment vars:
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~4",
"slotSetting": false
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "dotnet-isolated",
"slotSetting": false
}
Upvotes: 0
Views: 129
Reputation: 15621
You probably need to explicitly add a reference to the correct version of System.Data.SqlClient
, which is the package that holds SqlParameter
.
The version referenced in your error message (4.0.0.0) is not a version that is available on NuGet for System.Data.SqlClient
. I think the fact this runs fine locally is probably because you have SQL or SQL Types installed locally.
Upvotes: 0