I cant get Npgsql connection string to work. I've tried some ways, for example
NpgsqlConnection conn = new NpgsqlConnection("Server=192.168.1.220;User Id=pgsql;Password=pgsql;Database=pgsql;");
or
var conn = new NpgsqlConnection("Host=192.168.1.220;Username=pgsql;Password=pgsql;Database=pgsql");
both throws me exception:
The type initializer for 'Npgsql.NpgsqlConnectionStringBuilder' threw an exception.
Im running Windows XP 64bit with VS 2010. I've already tried to connect from that machine to my pgsql server using ODBC or pgAdmin III - both works ok.
Could be this problem related to my Npgsql installation?
I was not able to install it with NuGet, because I got following error:
PM> Install-Package Npgsql
Installing 'Npgsql 3.2.1'.
Successfully installed 'Npgsql 3.2.1'.
Adding 'Npgsql 3.2.1' to Project.
Uninstalling 'Npgsql 3.2.1'.
Successfully uninstalled 'Npgsql 3.2.1'.
Install failed. Rolling back...
Install-Package : Could not install package 'Npgsql 3.2.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0,Profile=Client', but the packag
e does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
At line:1 char:16
+ Install-Package <<<< Npgsql
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
I've tried also to switch target framework to 4.0 or 3.5, but result was exactly the same.
So I installed Npgsql simply by extracting .dll from MSI installation, then load it as reference.
Does anyone know how to make connection string to work?
You forgot about the port. Maybe this is the cause. The standard PostgreSQL server listening on port 5432.
NpgsqlConnection conn = new NpgsqlConnection("Server=192.168.1.220;Port=5432;User Id=pgsql;Password=pgsql;Database=pgsql;");
Example Connection String
Maybe you haven't a library Mono.Security.dll. It is necessary in the older version less then 3.0 or is enabled the system firewall?
Related
Microsoft.SqlServer.SqlManagementObjects 161.47027.0
Microsoft.Data.SqlClient 5.0.0
After upgrading Microsoft.Data.SqlClient from 4.1.0 to 5.0.0
I got this error creating a ServerConnection object:
using Microsoft.SqlServer.Management.Common;
var serverConnection = new ServerConnection("localhost", "sa", "mypwd");
System.MissingMethodException: 'Method not found: 'Void
Microsoft.Data.SqlClient.SqlConnectionStringBuilder.set_Encrypt(Boolean)
It looks for a not implemented set_Encrypt method inside a Microsoft.Data.SqlClient.SqlConnectionStringBuilder
Does it mean Microsoft.SqlServer.SqlManagementObjects has not been updated yet to support Microsoft.Data.SqlClient 5.0.0?
If so do I need to wait for this update before I can upgrade Microsoft.Data.SqlClient 5.0.0 into my project?
You can also upgrade the ServerManagementObjects reference to 170.7.0-preview to resolve. Apparently the issue is with the smo library not the sqlclient library.
https://github.com/dotnet/SqlClient/issues/1702
Their code should be backwards compatible, but they need to be recompiled against MDS 5.0
Below is MyConnectionString"
"Server=tcp:xxx.xxxx.windows.net;Authentication=Active Directory Default;Database=TestDB;TrustServerCertificate=True;MultipleActiveResultSets=True;"
Had the error:
Method not found: 'Void Microsoft.Data.SqlClient.SqlConnectionStringBuilder.set_Encrypt(Boolean)'. When usingMicrosoft.Data.SqlClient 5.0.1.`
Fixed By: Downgraded the package Microsoft.Data.SqlClient to 4.1.0.and Using Microsoft.SqlServer.SqlManagementObjects 161.47021.0.
Fixed the error. Thank you for this post.
We had the same MissingMethodException when attempting the update of Microsoft.Data.SqlClient 4.1.0 to 5.0.0 in our system. Simply updating Microsoft.Data.SqlClient - independently of Microsoft.SqlServer.SqlManagementObjects - resulted in the exception when constructing the Microsoft.SqlServer.Management.Common.ServerConnection using SQL Server Authentication (not Windows Authentication).
This snippet causes the MissingMethodException if using Microsoft.Data.SqlClient 5.0.0 (worked in 4.1.0):
Return New ServerConnection With {
.ApplicationName = My.Application.Info.Title,
.ServerInstance = connectionParameters.DataSource,
.ConnectTimeout = connectionParameters.ConnectionTimeout,
.LoginSecure = False,
.Login = connectionParameters.UserName,
.Password = connectionParameters.Password
}
For now, we are holding off on updating Microsoft.Data.SqlClient, but went ahead with the Microsoft.SqlServer.SqlManagementObjects update (161.47021.0 to 161.47027.0). I am hopeful that an upcoming Microsoft.Data.SqlClient version will fix this issue.
I'm taking a course in MVC that was recorded in 2016, so maybe that has to do with this error. It says to open NuGet console and type in "Enable-Migrations" in order to enable Entity Framework. But when I type that I get all sorts of error messages and yes I double-checked to make sure I'm doing everything the instructor is. I tried different versions of EF in Nuget Package Manager and the error messages change but still happen.
PM> Enable-Migrations
Enable-Migrations : Cannot bind argument to parameter 'Path' because it is null.
At line:1 char:1
+ Enable-Migrations
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Enable-Migrations], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Enable-Migrations
First off, why is this even necessary? From what I've seen of EF and LINQ so far I'd rather code in machine language, but in courses I took before that used EF we never had to do "Migrations" before so I'd like to solve this error message but I don't even see the point of it. I thought I read somewhere that Microsoft in its infinite wisdom has changed the way we do migrations but can't find any updated documentation.
Type following command in package manager console.
dir
or
pwd
pwd show you the path of current directory.
dir list down all folders of current directory. if package manager console is not set to project directory, run
cd "YouProjectDirectory"
and run
Enable-Migrations
If you install required packages in this case entitty framework core packages, it will run successfully.
I tried to run the command 'Enable-Migrations' in the microsoft sample project https://learn.microsoft.com/en-us/ef/ef6/modeling/code-first/migrations/ with visual studio professional 2017, But I got the message:
PM> Enable-Migrations
The term 'Enable-Migrations' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verif
y that the path is correct and try again.
At line:1 char:18
+ Enable-Migrations <<<<
+ CategoryInfo : ObjectNotFound: (Enable-Migrations:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
1、I have tried the re-starting Visual Studio and re-install EntityFramework Packages using "Install-Package EntityFramework -IncludePrerelease" but these are invalid
2、I have tried upgrade my powershell to 4.9.3.5777, but it is also invalid
3、I have tried Import-Module ProjectPath\packages\EntityFramework.6.3.0\tools\EntityFramework6.psd1,but invalid
BTW,I am using EntityFramework6.3.0.
Did you install:
Install-Package EntityFramework
I resloved the question by installing EntityFramework5.0 with .net Framework4.5.
I am new to Asp.Net Core. While reading Adam Freeman's book on Asp.Net Core (2016)
I have done everything properly prior to my problem, however, I can not create database tables using Update-Database Project manager console command as said in the book. Similar topics did not help me. Here is the error.
Invoke must be called on a background thread.
Update-Database : The term 'Update-Database' is not recognized as the name
of a cmdlet, function, script file, or operable program. Check the spelling
of the
name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ Update-Database
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Update-Database:String) [],
Comman
dNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
What version of ASP.NET Core did you select when created the project?
Did you add both Microsoft.EntityFrameworkCore.SqlServer and Microsoft.EntityFrameworkCore.Tools packages, did you do that via the Nuget manager or by editing your .csproj and what versions of that packages did you add?
In the book he adds packages by editing project.json which is no more supported and is replaced by PROJECT_NAME.csproj.
Make sure your dependencies were added and there are no warning signs (In Solution Explorer, expand your project tree. Check if required packages are listed in Nuget section under the "Dependencies" and there is no yellow warning triangle sign on the item).
I'm trying to develop an ASP.Net app ( software app or the web) in visual studio 2013 OR 2015 that uses IBM Watson Visual Recognition service.
I have seen the examples for QA service but it is outdated with the Watson credentials and functionality.
the example: (it requires username and password as credentials, which are not supplied anymore when creating a service):
http://www.nechai.net/2016/07/05/invoking-the-web-api-of-ibm-watsons-speech-to-text-service-from-net/
This example that I have found looks updated to today's credentials ( the API Key instead of username and pass) but I can't import, open or use the sub projects inside it, visual studio does not know how to recognize it)
"https://github.com/watson-developer-cloud/visual-recognition-aspnet"
the two inner projects that the project rely on are VisualRecognition and WatsonServices projects in the main project.
They have a project file with the xproj extension file, which visual studio 2013 AND 2015 seems to not recognize so I can't try it or reuse its code in my test app.
the above example project is too complicated to just grab the code and try it (after failing to import and making it work on VS 2013)
Is there a very simple example on how to connect to a watson service using this type of credentials? :
"credentials": {
"url": "https://gateway-a.watsonplatform.net/visual-recognition/api",
"note": "It may take up to 5 minutes for this key to become active",
"api_key": "********************************************************"
}
I have also tried to install the Watson services SDK by Nuget and by downloading the source and opening it in VS (for visual recognition specifically and the whole services option as well) but with no luck as well.
When opening the source code in VS, it says "incompatible" with all the files.
"https://github.com/watson-developer-cloud/dotnet-standard-sdk"
When trying to install with Nuget I get Errors:
in VS2013:
Install-Package: Could not install package 'IBM.WatsonDeveloperCloud.VisualRecognition.v3 1.0.0'. You are trying to install this package into a project that targets '.NETFram
ework,Version=v4.6', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package IBM.WatsonDeveloperCloud.VisualRecognition.v3
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
in VS 2015:
Install-Package : An error occurred while retrieving package metadata for 'Newtonsoft.Json.10.0.3' from source 'd:\Users*****\Documents\Visual Studio 2015\Projects\FaceDetection\packages'.
At line:1 char:1
+ Install-Package IBM.WatsonDeveloperCloud.VisualRecognition.v3
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
There is no example on how to use or install the SDKs except for using Nuget so I'm lost here.
The Watson Developer Cloud .NET Standard SDK has been updated to 1.1.0. Please try to update the packages. You can see examples of how to invoke the service in the readme for the service.
Additionally, there is an example file of how to invoke the service in the examples directory of the github repo.
Basically you instantiate the service
private VisualRecognitionService _visualRecognition = new VisualRecognitionService();
Set the credentials
_visualRecognition.SetCredential(apikey);
And call the API (classify in this example)
var result = _visualRecognition.Classify(<image-url>);
You should be able to traverse the result object to get the classification results
if (result != null)
{
foreach (ClassifyTopLevelSingle image in result.Images)
foreach (ClassifyPerClassifier classifier in image.Classifiers)
foreach (ClassResult classResult in classifier.Classes)
Console.WriteLine(string.Format("class: {0} | score: {1} | type hierarchy: {2}", classResult._Class, classResult.Score, classResult.TypeHierarchy));
}
You can also see the result in json format by serializing the result object
Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));