1
I updated my entire project to aspnet 5 core because I was using dnx vnext and apparently everything worked fine, but I performed tests and noticed that some values were not correct and when debugging I realized that the Sqlparameter parameter array is not picking up the values, for example if I have an array with 5 parameters and it contains parameters of type int it populates otherwise not and I believe it is some inconsistency of lib System.Data.Sqlclient, does anyone know anything about it? In the visual studio is underlined, showing the following message:
Assuming assembly reference 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' matches 'System.Data.SqlClient, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35', you may need to supply runtime policy.
This is my project.json
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
"System.Security.Cryptography.Algorithms": "4.2.0",
"Microsoft.AspNetCore.Owin": "1.0.0",
"BundlerMinifier.Core": "2.2.281",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"System.Data.SqlClient": "4.1.0",
"Microsoft.EntityFrameworkCore": "1.0.0",
"System.Runtime": "4.1.0",
"System.Data.Common": "4.1.0",
"Microsoft.AspNetCore.Hosting.Abstractions": "1.0.0"
},
"tools": {
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-dnxcore50+net45+win8+wp8+wpa81"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"_comment": "dotnet bundle",
"precompile": [ "gulp clean", "gulp min" ],
"prepublish": [ "npm install", "bower install" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
},
"tooling": {
"defaultNamespace": "meuprojeto"
}
}
Is there any reference to
System.Web.Mvc
in thereferences
of your project?– Leonel Sanches da Silva
I made a find in Entire Solution for "System.Web.Mvc" did not return anything!
– Diogo Soares
For example if I do something like: var Parameters = new[] { new Sqlparameter("@id", 1), new Sqlparameter("@name", "Diogo"), new Sqlparameter("@age", 30), new Sqlparameter("@email", "[email protected]) }; It only populates the id and age, I’m finding it very strange this behavior
– Diogo Soares
Have you tried forcing the parameter type?
var parametro = new SqlParameter("@email", SqlDbType.VarChar);
, afterwardparametro.Value = "[email protected]"
?– Leonel Sanches da Silva
I did a test now printing the value inside a loop of Sqlparameter, I can read the value more if I position the mouse above I can’t see the value so I think it’s a visual studio bug, I will continue the tests, so much so that all sql related code is underlined in green in my source.
– Diogo Soares