类型或命名空间名称'数据'命名空间中不存在'系统' - 创建AWS Lambda函数

时间:2017-09-21 02:17:40

标签: c# .net amazon-web-services lambda

我正在尝试使用Visual Studio AWS Toolkit在.NET Core 1.0中创建AWS Lambda函数。我创建了一个空的Lambda函数,并尝试添加所需的程序集以使用SQL Server数据库(我还有其他项目,我已经能够成功完成此操作)。

由于某些原因,即使添加了所需的包,我也无法解析System.Data.SqlClient。它说的类型'数据'系统'中不存在。这通常意味着我还没有添加正确的装配。但是我有!我有System.Data.Common 4.3.0和System.Data.SqlClient 4.1.0。我究竟做错了什么?这是Nuget输出,所以你可以看到我添加了它们:

PM> install-package System.Data.Common -version 4.3.0
  GET https://api.nuget.org/v3/registration3-gz/system.data.common/index.json
  OK https://api.nuget.org/v3/registration3-gz/system.data.common/index.json 906ms
Restoring packages for C:\LambdaBuild\LambdaProcessBounce\LambdaProcessBounce\LambdaProcessBounce\LambdaProcessBounce.csproj...
Installing NuGet package System.Data.Common 4.3.0.
Committing restore...
Writing lock file to disk. Path: C:\LambdaBuild\LambdaProcessBounce\LambdaProcessBounce\LambdaProcessBounce\obj\project.assets.json
Restore completed in 1.58 sec for C:\LambdaBuild\LambdaProcessBounce\LambdaProcessBounce\LambdaProcessBounce\LambdaProcessBounce.csproj.
Successfully uninstalled 'Microsoft.NETCore.Platforms 1.0.2' from LambdaProcessBounce
Successfully uninstalled 'Microsoft.NETCore.Targets 1.0.3' from LambdaProcessBounce
Successfully uninstalled 'System.Collections 4.0.11' from LambdaProcessBounce
Successfully uninstalled 'System.Globalization 4.0.11' from LambdaProcessBounce
Successfully uninstalled 'System.IO 4.1.0' from LambdaProcessBounce
Successfully uninstalled 'System.Reflection 4.1.0' from LambdaProcessBounce
Successfully uninstalled 'System.Reflection.Primitives 4.0.1' from LambdaProcessBounce
Successfully uninstalled 'System.Resources.ResourceManager 4.0.1' from LambdaProcessBounce
Successfully uninstalled 'System.Runtime 4.1.0' from LambdaProcessBounce
Successfully uninstalled 'System.Runtime.Extensions 4.1.0' from LambdaProcessBounce
Successfully uninstalled 'System.Text.Encoding 4.0.11' from LambdaProcessBounce
Successfully uninstalled 'System.Text.RegularExpressions 4.1.0' from LambdaProcessBounce
Successfully uninstalled 'System.Threading 4.0.11' from LambdaProcessBounce
Successfully uninstalled 'System.Threading.Tasks 4.0.11' from LambdaProcessBounce
Successfully installed 'Microsoft.NETCore.Platforms 1.1.0' to LambdaProcessBounce
Successfully installed 'Microsoft.NETCore.Targets 1.1.0' to LambdaProcessBounce
Successfully installed 'System.Collections 4.3.0' to LambdaProcessBounce
Successfully installed 'System.Data.Common 4.3.0' to LambdaProcessBounce
Successfully installed 'System.Globalization 4.3.0' to LambdaProcessBounce
Successfully installed 'System.IO 4.3.0' to LambdaProcessBounce
Successfully installed 'System.Reflection 4.3.0' to LambdaProcessBounce
Successfully installed 'System.Reflection.Primitives 4.3.0' to LambdaProcessBounce
Successfully installed 'System.Resources.ResourceManager 4.3.0' to LambdaProcessBounce
Successfully installed 'System.Runtime 4.3.0' to LambdaProcessBounce
Successfully installed 'System.Runtime.Extensions 4.3.0' to LambdaProcessBounce
Successfully installed 'System.Text.Encoding 4.3.0' to LambdaProcessBounce
Successfully installed 'System.Text.RegularExpressions 4.3.0' to LambdaProcessBounce
Successfully installed 'System.Threading 4.3.0' to LambdaProcessBounce
Successfully installed 'System.Threading.Tasks 4.3.0' to LambdaProcessBounce
Executing nuget actions took 1.14 sec
Time Elapsed: 00:00:04.2014899
PM> install-package System.Data.SqlClient -version 4.1.0
  GET https://api.nuget.org/v3/registration3-gz/system.data.sqlclient/index.json
  OK https://api.nuget.org/v3/registration3-gz/system.data.sqlclient/index.json 878ms
Restoring packages for C:\LambdaBuild\LambdaProcessBounce\LambdaProcessBounce\LambdaProcessBounce\LambdaProcessBounce.csproj...
Installing NuGet package System.Data.SqlClient 4.1.0.
Committing restore...
Writing lock file to disk. Path: C:\LambdaBuild\LambdaProcessBounce\LambdaProcessBounce\LambdaProcessBounce\obj\project.assets.json
Restore completed in 1.15 sec for C:\LambdaBuild\LambdaProcessBounce\LambdaProcessBounce\LambdaProcessBounce\LambdaProcessBounce.csproj.
Successfully installed 'runtime.native.System.Data.SqlClient.sni 4.0.0' to LambdaProcessBounce
Successfully installed 'runtime.win7-x64.runtime.native.System.Data.SqlClient.sni 4.0.1' to LambdaProcessBounce
Successfully installed 'runtime.win7-x86.runtime.native.System.Data.SqlClient.sni 4.0.1' to LambdaProcessBounce
Successfully installed 'System.Data.SqlClient 4.1.0' to LambdaProcessBounce
Successfully installed 'System.IO.Pipes 4.0.0' to LambdaProcessBounce
Executing nuget actions took 1.76 sec
Time Elapsed: 00:00:04.0019743
PM> 

1 个答案:

答案 0 :(得分:0)

这对我有用。我使用.NET Core 1.0运行VS2015。

在Nuget Package控制台下运行以下命令。

Install-Package System.Data.SqlClient -Version 4.1.0

注意,它可能不适用于其他版本。我看到一个博客,其中4.1为他们工作,但不是更高。它可能取决于您使用的是哪个版本的.NET Core。