Closed marc-wilson closed 4 years ago
I don't know if this is the reason or not, but the https://github.com/dotnet/sqlclient docs suggest 3.0 isn't supported?
Supportability The Microsoft.Data.SqlClient package supports the below environments:
.NET Framework 4.6+ .NET Core 2.1+ .NET Standard 2.0+. The source code of this library is now available under the MIT license.
But I'm not sure why my web app projects running 3.0 works and the function app does not...
We have this same exact problem
I had this problem on .NET Core 2.1, Functions ~2, when I tried to update to Microsoft.Data.SqlClient from System.Data.SqlClient. It worked when I tried locally using func on Linux, but failed with this exception in the cloud.
@ngg That's the thing. I haven't imported that anywhere. It's packaged with Entity Framework from what I can tell. Upgrading/downgrading that package isn't an option.
I think I know what is going on here. Try adding the following to your .csproj:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy $(OutDir)$(ProjectName).deps.json $(OutDir)bin\function.deps.json" />
</Target>
<Target Name="PostPublish" BeforeTargets="Publish">
<Exec Command="copy $(PublishDir)$(ProjectName).deps.json $(PublishDir)bin\function.deps.json" />
</Target>
(in the future this workaround should not be necessary)
@paulbatum Thanks.
For anyone else having this issue and working on a mac, I had to modify what @paulbatum provided a little bit:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="cp $(OutDir)Chadwick.$(ProjectName).deps.json $(OutDir)/bin/function.deps.json" />
</Target>
<Target Name="PostPublish" BeforeTargets="Publish">
<Exec Command="cp $(PublishDir)Chadwick.$(ProjectName).deps.json $(PublishDir)/bin/function.deps.json" />
</Target>
$(ProjectName) wasn't correct for me. It wanted the namespace I guess? In any case, aside from windows copy
command needing to be cp
on a mac along with minor path updates, this workaround unblocks me. Thanks, @paulbatum
@paulbatum I've attempted to use this solution with no luck. I've verified that when deployed the functions.deps.json is present and accurate, however I still get the same exception as above.
I have tried a few setups to verify that the issue happens regardless of if my Azure Function project directly references Microsoft.Data.SqlClient or not. Any other suggestions if this workaround doesn't solve the issue?
@kaeus you're probably hitting https://github.com/Azure/azure-functions-vs-build-sdk/issues/333. You're also need to add the following to work around that .NET Core 3.0 SDK bug:
<Target Name="PostPublish" AfterTargets="AfterPublish">
<Exec Command="move $(PublishDir)\runtimes $(PublishDir)\bin" />
</Target>
@paulbatum that's awesome that there's hope for that not being needed in the future. Do you have an issue, version, and/or ETA for the fix? There's a long (closed but active) issue, https://github.com/Azure/azure-functions-host/issues/3568, with lots of people reporting the issue but no updates from Microsoft so it was seeming this wasn't ever going to be fixed.
@IGx89 Thanks, that seems to have wrapped up the issue for me (combining that with the previous solutions)!
I'm having a few problems with this work around. I can see the file getting copied to the output directory with the relevant detail to function.deps.json, but my DI assembly scanning is then failing to pick up all of my dependencies. This is my assembly scanning code that then registers the dependencies using Scrutor with the built in .NET Core DI Container:-
string path = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location);
List<Assembly> assemblies = new List<Assembly>();
foreach (string dll in Directory.GetFiles(path, "MyNamespace*.dll"))
{
assemblies.Add(Assembly.LoadFrom(dll));
}
services.Scan(scan => scan
.FromAssemblies(assemblies)
.AddClasses(classes => classes.Where(types => types.FullName.StartsWith("MyNamespace.")))
.UsingRegistrationStrategy(RegistrationStrategy.Append)
.AsMatchingInterface()
.WithTransientLifetime()
);
I've tried the copy command with the actual name of the file too (as opposed to the name function.deps.json) but I'm still not able to resolve my dependencies, despite all the dependencies being configured.
Apologies for this not quite being related to the main problem but it's the only place I could ask the question.
Thanks
For anyone hitting this problem on "zip deployed" (from Visual Studio) azure functions the final .csproject section required is the following:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy $(OutDir)$(ProjectName).deps.json $(OutDir)bin\function.deps.json" />
</Target>
<Target Name="PostPublish" BeforeTargets="Publish">
<Exec Command="copy $(PublishDir)$(ProjectName).deps.json $(PublishDir)bin\function.deps.json" />
<Exec Command="move $(PublishDir)\runtimes $(PublishDir)\bin" />
</Target>
@IGx89 your suggestion fixed the problem, but with "zip deployed" azure functions the directory move was being done after the publishing.
@iRubens all my functions are zip deployed as well but the zipping is done as a separate command after dotnet publish
, right before I POST the zip to Azure. It sounds like you know of a way to get the dotnet CLI to zip up the publish folder for you as well? If so I'd love to know how to do that, I've had zero luck finding out how to do that myself.
@iRubens all my functions are zip deployed as well but the zipping is done as a separate command after
dotnet publish
, right before I POST the zip to Azure. It sounds like you know of a way to get the dotnet CLI to zip up the publish folder for you as well? If so I'd love to know how to do that, I've had zero luck finding out how to do that myself.
If you are using Azure DevOps to publish with the DotNetCoreCLI task you can set zipAfterPublish to true that should do that automatically. I don't know of any way to do that via dotnet publish
alone without an extra step.
@IGx89 at the moment we're deploying our functions directly from Visual Studio (I've updated my comment). Unfortunately don't know either if there's any command for the CLI to obtain the same result.
For those of you working around this -- the deps.json file should now be auto-copied when using Microsoft.NET.Sdk.Functions version 3.0.0-preview1.
There is still a problem with having the runtimes folder moved to under the bin folder during publish -- I'm looking into that now, but the workaround above (https://github.com/Azure/Azure-Functions/issues/1370#issuecomment-546030332) should work.
For anyone hitting this problem on "zip deployed" (from Visual Studio) azure functions the final .csproject section required is the following:
<Target Name="PostBuild" AfterTargets="PostBuildEvent"> <Exec Command="copy $(OutDir)$(ProjectName).deps.json $(OutDir)bin\function.deps.json" /> </Target> <Target Name="PostPublish" BeforeTargets="Publish"> <Exec Command="copy $(PublishDir)$(ProjectName).deps.json $(PublishDir)bin\function.deps.json" /> <Exec Command="move $(PublishDir)\runtimes $(PublishDir)\bin" /> </Target>
@IGx89 your suggestion fixed the problem, but with "zip deployed" azure functions the directory move was being done after the publishing.
My azure function stopped pubishing after adding above code to csproj file : https://stackoverflow.com/questions/58833050/azure-functions-runtime-exception-the-type-initializer-for-system-data-sqlclien
"Publish has encountered an error. Publish has encountered an error. We were unable to determine the cause of the error."
@shailendrarampal -- what OS are you running on? Note that you should not need the deps.json lines anymore when using 3.0.0-preview1.
@shailendrarampal -- what OS are you running on? Note that you should not need the deps.json lines anymore when using 3.0.0-preview1.
I am using windows 10 64bit! But if you go through the link above, my real problem was 'sni.dll was not loded' with aspnet core 3.0 and azure function v3-preview with system.data.sqlclient version 4.7.0
This line should be taking care of that: <Exec Command="move $(PublishDir)\runtimes $(PublishDir)\bin" />
Your stackoverflow post doesn't show that as included, so I'm not sure exactly what you're running -- do you have that in your csproj? Can you share your entire csproj?
This line should be taking care of that:
<Exec Command="move $(PublishDir)\runtimes $(PublishDir)\bin" />
Your stackoverflow post doesn't show that as included, so I'm not sure exactly what you're running -- do you have that in your csproj? Can you share your entire csproj?
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AzureFunctionsVersion>v3-preview</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.8.2" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.0.19269.1" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.30-beta2" />
<PackageReference Include="System.Data.SqlClient" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.8.0" />
</ItemGroup>
<ItemGroup>
<None Include="$(USERPROFILE)\.nuget\packages\\microsoft.data.sqlclient\1.0.19249.1\runtimes\win\lib\netcoreapp2.1\microsoft.Data.SqlClient.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="CopyToBin" BeforeTargets="Build">
<Copy SourceFiles="$(USERPROFILE)\.nuget\packages\microsoft.data.sqlclient\1.0.19249.1\runtimes\win\lib\netcoreapp2.1\microsoft.Data.SqlClient.dll" DestinationFolder="$(OutputPath)\bin" />
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy $(OutDir)$(ProjectName).deps.json $(OutDir)bin\function.deps.json" />
</Target>
<Target Name="PostPublish" BeforeTargets="Publish">
<Exec Command="copy $(PublishDir)$(ProjectName).deps.json $(PublishDir)bin\function.deps.json" />
<Exec Command="move $(PublishDir)\runtimes $(PublishDir)\bin" />
</Target>
</Project>
This line should be taking care of that:
<Exec Command="move $(PublishDir)\runtimes $(PublishDir)\bin" />
Your stackoverflow post doesn't show that as included, so I'm not sure exactly what you're running -- do you have that in your csproj? Can you share your entire csproj?
It worked for me by adding below code in csproj file :
<Target Name="PostPublish" BeforeTargets="Publish">
<Exec Command="move $(PublishDir)\runtimes $(PublishDir)\bin" />
</Target>
Thank you.
I've just pushed Microsoft.Net.Sdk.Functions 3.0.0-preview2. I believe this package now handles all the problems mentioned in this issue. If you could try removing the workarounds and using that package, that'd be helpful. I'm going to close this now, but let me know if something hasn't been fixed and I can re-open (or create a separate issue).
I can confirm both issues are fixed now for me (under Functions v3-preview, .NET Core SDK 3.0), thanks a lot @brettsam!
Should this be working in Visual Studio 2019 Preview? I was able to create the v3-preview function/.net core 3.0 SDK, but I'm still getting the not supported on this platform error message. I do have Microsoft.NET.Sdk.Functions 3.0 preview 2.
UPDATE False alarm. Was reading Microsoft.Data.SqlClient as System.Data.SqlClient. Switching this library seems to resolve my issues. Sorry.
Also make sure you're on Microsoft.Net.Sdk.Functions 3.0.0-preview2. I don't believe our templates create projects with this reference yet.
I am still getting this error with a fresh functions project in Microsoft Visual Studio Enterprise 2019 Preview Version 16.4.0 Preview 6.0.
Project file is as follows
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AzureFunctionsVersion>v3-preview</AzureFunctionsVersion>
<AssemblyName>MyProj.Core</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="1.0.5" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.0-preview2" />
<PackageReference Include="Microsoft.NETCore.App" Version="2.2.8" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
I am also still seeing the same issue,
I'm running VS preview 6.0 see below for the csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AzureFunctionsVersion>v3-preview</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.4" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.0-preview2" />
<PackageReference Include="System.Data.SqlClient" Version="4.7.0" />
<PackageReference Include="System.Text.Json" Version="4.6.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
the function.deps.json does indeed get created into the bin folder properly with the preview2 version of Microsoft.NET.Sdk.Functions
@apapapapapa Can you confirm that you've set the AzureFunctionsHiddenTagsVisible environment variable and pulled down the v3-preview templates (https://dev.to/azure/develop-azure-functions-using-net-core-3-0-gcm)?
Ok I think I did set the ENV var and have the sdk installed but just to make sure, I started from scratch again. made sure to download the .NET Core 3 sdk, created a new function project, see below I pick v3 preview ( I assume this answers your question @zpertee )
i just changed the string in the blob trigger to point at my table. run it locally, works fine.
then,
@apapapapapa Great! Looks like you're definitely on the right track (or at least the track I took myself). What I discovered is that I could not use System.Data.SqlClient v4.7.0, but was able to use Microsoft.Data.SqlClient 1.1.0. It appears that this is new library to use for SQL access: https://devblogs.microsoft.com/dotnet/introducing-the-new-microsoftdatasqlclient/. These two libraries are extremely similar and you should be able to swap out to Microsoft.Data.SqlClient with very minimal (if any) code changes.
oh right, I was confused about this one too, I tried your suggestion(PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.0"), and now I get the same but with Microsoft.Data... "System.PlatformNotSupportedException: 'Microsoft.Data.SqlClient is not supported on this platform.'" Does it matter that in my runtime folder I do not see a netcoreapp3.0 with that assembly in it? I only have a netcoreapp2.0, netcoreapp2.1 and netstandard2.0.
@apapapapapa Ok. I will have to leave this one to Microsoft (@brettsam). Sorry. Figured I'd at least share my two cents of what worked for me. Not worth much, I know...
I'm able to reproduce this with the System.Data.SqlClient
nuget package (investigating it now) -- but when I switch to Microsoft.Data.SqlClient
, it starts to work.
@apapapapapa -- is that your latest project file above, or have you tweaked it since then? I see you're using both Microsoft.Data.SqlClient
and System.Data.SqlClient
there, which may be the problem...
Okay I think I know why System.Data.SqlClient
isn't working. I've filed https://github.com/Azure/azure-functions-host/issues/5315 to fix this in v3.
If you need to use this, you'll need to reference 4.3.1 for now -- but I think that swapping to Microsoft.Data.SqlClient
should work for most cases.
Ok, this is odd. Either something changed or I did have the reference to the System.Data.SqlClient in there somehow. Today I tried again, and it seems to be all working now. For reference I am using the following csproj successfully now:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AzureFunctionsVersion>v3-preview</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.4" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.0-preview2" />
<PackageReference Include="System.Text.Json" Version="4.6.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Okay, at least that narrows it down. Glad that the other package is working for you. We've made the change to get System.Data.SqlClient working as well -- that will roll out with our next host release within a few weeks.
Still getting the MIcrosoft.Data.SqlClient platform not supported error even on the latest version (updated 8th Dec 2019).
Here is the cs.proj file, runtime version and I am running Microsoft Visual Studio Enterprise 2019 Preview Version 16.5.0 Preview 1.0.
My project is blocked on this. Connecting to SQL Server shouldn't be this hard. Can anyone advise how to collect extra debug to find out why the wrong dll is being copied/cached in the runtime?
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3-preview</AzureFunctionsVersion>
<AssemblyName>TestSqlDb.Core</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="1.0.5" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.1" />
<PackageReference Include="Microsoft.NETCore.App" Version="2.2.8" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LinkLibrary\LinkLibrary.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Azure Functions Core Tools (3.0.1958 Commit hash: c4ee36af2a3666307cafb854aabab0d36434f104)
Function Runtime Version: 3.0.12915.0
Did you try targeting netcoreapp3.0? We don't yet support 3.1.
Hmm, that may not be the issue. This is failing locally when you hit F5 from within VS? I just tried to reproduce this (even with netcoreapp3.1) and it worked fine for me locally, so there must be something else subtle happening.
Can you share your sample project on github somewhere and I can see if I can reproduce it locally?
According to the SqlClient team (6 days ago) I should upgrade to the latest version of .Net core (https://github.com/dotnet/SqlClient/issues/289#issuecomment-560128834). So I am a bit confused as to what version of .Net Core I should be using.
I will create a simple project and see if I can just zip up and attach. But it obviously won't have the local settings with the SQL Server connection string.
Did a fresh install of VS2019 on a different machine and set the AzureFunctionsHiddenTagsVisible environment variable to 1 to get the new templates. But I am getting an object reference exception when using the "Azure Functions v3 Prerelease (.NET Core)" project template. Are there any other tools/sdks that need to be installed?
Is it like this? https://twitter.com/pksorensen/status/1202638801379696641. What version of VS 2019 are you using?
No its the generic message, have attached a screenshot. I am running a clean install of VS2019 Enterprise Preview (see details below).
Microsoft Visual Studio Enterprise 2019 Preview Version 16.5.0 Preview 1.0 VisualStudio.16.Preview/16.5.0-pre.1.0+29521.150 Microsoft .NET Framework Version 4.8.03752
Installed Version: Enterprise
Visual C++ 2019 00433-90100-95975-AA508 Microsoft Visual C++ 2019
ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools
ASP.NET and Web Tools 2019 16.5.126.18061 ASP.NET and Web Tools 2019
ASP.NET Web Frameworks and Tools 2019 16.5.126.18061 For additional information, visit https://www.asp.net/
Azure App Service Tools v3.0.0 16.5.126.18061 Azure App Service Tools v3.0.0
Azure Data Lake Node 1.0 This package contains the Data Lake integration nodes for Server Explorer.
Azure Data Lake Tools for Visual Studio 2.4.1000.0 Microsoft Azure Data Lake Tools for Visual Studio
Azure Functions and Web Jobs Tools 16.5.126.18061 Azure Functions and Web Jobs Tools
Azure Stream Analytics Tools for Visual Studio 2.4.1000.0 Microsoft Azure Stream Analytics Tools for Visual Studio
C# Tools 3.5.0-beta1-19571-01+fb3f812a3e4b7534bef784fa2df1c21d1f67864d C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Fabric.DiagnosticEvents 1.0 Fabric Diagnostic Events
GitHub.VisualStudio 2.10.8.8121 A Visual Studio Extension that brings the GitHub Flow into Visual Studio.
IntelliCode Extension 1.0 IntelliCode Visual Studio Extension Detailed Info
Microsoft Azure HDInsight Azure Node 2.4.1000.0 HDInsight Node under Azure Node
Microsoft Azure Hive Query Language Service 2.4.1000.0 Language service for Hive query
Microsoft Azure Service Fabric Tools for Visual Studio 16.0 Microsoft Azure Service Fabric Tools for Visual Studio
Microsoft Azure Stream Analytics Language Service 2.4.1000.0 Language service for Azure Stream Analytics
Microsoft Azure Stream Analytics Node 1.0 Azure Stream Analytics Node under Azure Node
Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.21108.1
Microsoft Continuous Delivery Tools for Visual Studio 0.4 Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.
Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft Library Manager 2.1.3+g9c91cdec24 Install client-side libraries easily to any web project
Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers
Microsoft Visual C++ Wizards 1.0 Microsoft Visual C++ Wizards
Microsoft Visual Studio Tools for Containers 1.1 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.
Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package
NuGet Package Manager 5.5.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info
Snapshot Debugging Extension 1.0 Snapshot Debugging Visual Studio Extension Detailed Info
SQL Server Data Tools 16.0.61911.21070 Microsoft SQL Server Data Tools
ToolWindowHostedEditor 1.0 Hosting json editor into a tool window
TypeScript Tools 16.0.11113.2001 TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 3.5.0-beta1-19571-01+fb3f812a3e4b7534bef784fa2df1c21d1f67864d Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 10.4 for F# 4.6 16.5.0-beta.19556.3+c2b6d5980a7f64dd4e46448b9b4f5d96eb415aeb Microsoft Visual F# Tools 10.4 for F# 4.6
Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
Visual Studio Container Tools Extensions (Preview) 1.0 View, manage, and diagnose containers within Visual Studio.
Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers
Visual Studio Tools for Kubernetes 1.0 Visual Studio Tools for Kubernetes
Same issue with Microsoft.NET.Sdk.Functions v3.0.1 and System.Data.SqlClient v4.8.0. Once I downgraded to v4.6.1, the problem went away.
Seriously it shouldn't be this hard to connect to SQL Server. This should be a core use case and tested thoroughly. Seems like quite a few people are having problems with this.
@Robzilla / @joefeser -- Can either of you create a repro on github that I can try?
@Robzilla, I tried what you have above and I don't get the exception. I don't have your code or your referenced project -- so maybe something there is breaking it? But when I use our repro above (var conn = new SqlConnection();
) -- it's able to load the type and continue. This failed a couple of versions ago b/c we weren't correctly copying native references in .NET Core 3 projects. Is there a different line of code throwing this for you? If so, I can try that.
If you can't get a repro together, you can try building from the command line with "dotnet build {yourproject} /bl" and emailing me your msbuild.binlog file -- my microsoft email is in my github profile.
@brettsam FWIW, I've also tested what's above without issue. The only issues I've had to date were when this was still in preview (i.e. issues expected) and those were quickly worked through-- thank you. I agree that whatever @Robzilla issue is, it's likely confined to the machine and/or the specific code.
Why is this issue closed? I can confirm it doesn't work yet. I just tried today with everything updated, and no, doesn't work.
It's closed because the original issue above was fixed (as several people have confirmed).
It's clear that there are other scenarios broken here -- but I haven't gotten a repro that I've been able to run locally.
@erick2red -- Can you share your project file with us so we can take a look? Ideally it'd be an entire project on github that fails for you so I can clone it and give it a try.
My project files are these, first the function
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="StackExchange.Redis" Version="2.0.601" />
<PackageReference Include="System.Text.Json" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Libraries\CoreDbAccess\CoreDbAccess.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Then the dependency
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
<Configurations>Debug;Release;ProductionPublish</Configurations>
<Platforms>AnyCPU;x86;x64</Platforms>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.30" />
<PackageReference Include="Dapper.Contrib" Version="2.0.30" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="StackExchange.Redis" Version="2.0.601" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.0" />
<PackageReference Include="System.Text.Json" Version="4.7.0" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.3" />
</ItemGroup>
</Project>
I am migrating from a functions 2.0 project to a 3.0 project. I followed the steps outlined here but am unable to run the project (fails at runtime)
Error:
Here is my package dependencies:
However, I suspect that this error is coming from my Database Project which is using Entity Framework 3.0. Here's those dependencies:
I am not explicitly pulling in
Microsoft.Data.SqlClient
anywhere within my project / solution. I did find the reference in the Entity Framework packages though, so I assume it's coming from that.The only other thing worth mentioning here is that my Web App (running dotnet 3.0) is able to utilize the same database project without any issues.
dotnet --info