Using Net 6 I have the project structure:
nuget.config
project.code-workspace
- Core
Core.csproj
- Api
Api.csproj
- Sim
notebook.ipynb
My Nuget.config is:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="mysrc" value="https://pkgs.dev.azure.com/me/_packaging/mysrc/nuget/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<moget>
<add key="Username" value="mysrc" />
<add key="ClearTextPassword" value="password" />
</moget>
</packageSourceCredentials>
</configuration>
The package mysrc is working fine with my Core and Api project.
But when I run the Net Interactive Notebook I get the error:
Error: /usr/local/share/dotnet/sdk/6.0.101/NuGet.targets(130,5): error : Unable to load the service index for source ... : error :
Response status code does not indicate success: 401 (Unauthorized).
How to solve this?
Related
I have private nuget repo packages in my solution and when I restore them to build my app in Visual Studio, I get the following error
Severity Code Description Project File Line Suppression State
Error NU1301 Unable to load the service index for source https://myprivate.privatenuget.org/F/privatepackages/api/v3/index.json. MyPrivate.Project.Repository C:\Pth\To\source\repos\Project\src\Project.name\Project.csproj 1
With the popular resolution
Nuget connection attempt failed "Unable to load the service index for source"
I tried deleting %AppData%\Roaming\NuGet\NuGet.Config and restarting VS which is not working for me.
My Nuget.Config looks like this.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="MyGet.orgV3" value="https://myprivate.privatenuget.org/F/privatepackages/api/v3/index.json" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageManagement>
<add key="format" value="1" />
<add key="disabled" value="False" />
</packageManagement>
</configuration>
Even tried dotnet restore --interactive
But in futile
dotnet restore --interactive
Determining projects to restore...
C:\Pth\To\source\repos\Project\src\Project.name\Project.csproj : error NU1301: Unable to load the service index for source https://myprivate.privatenuget.org/F/privatepackages/api/v3/index.json. [C:\Pth\To\source\repos\Project\src\Project.name\Project.csproj]
The repo needs either a password/AzureAAD identity for access and I have logged into the visual studio/terminal with the account I have access to the private repo. I think this is somehow stopping the service index to load, but I have a roadblock to achieving it.
The access to the private package repo:
My Package sources looks like this:
I got a dirty solution.
I decided to use private nuget repo username and password in the Nuget.Config ( at least locally ).
I changed the Nuget.Config to:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="MyGet" value="https://myprivate.privatenuget.org/F/privatepackages/api/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<MyGet>
<add key="Username" value="myusername" />
<add key="ClearTextPassword" value="mysecretpassword" />
</MyGet>
</packageSourceCredentials>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageManagement>
<add key="format" value="1" />
<add key="disabled" value="False" />
</packageManagement>
</configuration>
I deleted the NuGet.Config from NuGet folder by running
Then, from VS Developer PowerShell Terminal ( because it is not working with the UI build tab ) I ran dotnet restore and the packages got restored.
I'm looking for better answers to avoid passwords in clear text.
The issue was that I messed with the private package repository password that would be prompted when the VS loads the project. If you entered it wrong once, you would never get the package restored.(which is pathetic....as the reason for the restoration failure is not explicit.)
But we can easily solve this by the following steps:
If Visual Studio does not prompt for credentials but the logging Output shows that you did not authenticate correctly, then go to
Control Panel\User Accounts\Credential Manager
and click "Windows Credentials". You can remove stored credentials for nuget/github there. If they become invalid - for example because you regenerated a token - Visual Studio does not prompt to overwrite the invalid credentials, but after removing the credentials and restarting Visual Studio you do get the prompt.
I found it from the stackoverflow answer here: Nuget Package Source is not prompting for credentials
I am trying to configure multiple Nuget source in nuget.config. Nuget.config is added to the root of the project. With same config I can successfully dotnet build my app on my macbook but when I run the same config in linux I get the following error.
/opt/rh/rh-dotnet31/root/usr/lib64/dotnet/sdk/3.1.100/NuGet.targets(123,5): error : Unable to load the service index for source https://gitlab.xxxyy.gov/api/v4/projects/id/packages/nuget/index.json [/var/www/folder/member/Member.sln]
/opt/rh/rh-dotnet31/root/usr/lib64/dotnet/sdk/3.1.100/NuGet.targets(123,5): error : Response status code does not indicate success: 401 (Unauthorized). [/var/www/netcoreapp3.1/member/Member.sln]
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="gitlab" value="https://gitlab.senate.gov/api/v4/projects/449/packages/nuget/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<packageSourceCredentials>
<gitlab>
<add key="Username" value="xyz" />
<add key="ClearTextPassword" value="dhdhdhdh" />
</gitlab>
</packageSourceCredentials>
</configuration>
I figured it out. I had to manually add source nuget source Add -Name "gitlab" -Source "https://gitlandomain/api/v4/projects/id/packages/nuget/index.json" -UserName xyz#domain.com -Password ddhdhdgdgsgv
After this dotnet nuget restore/build works like charm.
How I do add packages sources in my project?
In my Visual Studio, i go to tools -> options -> Nuget Package Manager -> Package Sources.
And add the package information that in this case is not in Nuget. Now in the App Center I did not find this information and with this my project does not compile
You can create a NuGet.config file as described in the docs.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget" value="https://api.nuget.org/v2/index.json" />
<add key="MyGet" value="https://www.myget.org/F/MyUsername/api/v2/index.json" />
<add key="MyAuthNuget" value="https://nuget.example.com/v2/index.json" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<packageSourceCredentials>
<MyAuthNuget>
<add key="Username" value="$USER_VARIABLE" />
<add key="ClearTextPassword" value="$PASSWORD_VARIABLE" />
</MyAuthNuget>
</packageSourceCredentials>
</configuration>
Maybe this will also help somebody. For me the above solution haven't worked. So what I've discovered - always check if official source of packages is same as in your config. For now nuget source have changed to version 3:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<activePackageSource>
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
</activePackageSource>
</configuration>
I'm getting the following error while trying to connect to an Oracle database from a new ASP.NET MVC 4 application: "ORA-12154: TNS:could not resolve the connect identifier specified". I'm using the Oracle.ManagedDataAccess DLL (version 4.121.1.0) to try to connect to an Oracle 10g database. Here's the thing - I have an integration test assembly that is successfully connecting to the database using this minimal App.config:
<connectionStrings>
<add name="OracleConnection" connectionString="DATA SOURCE=TNS_NAME;PASSWORD=xxx;PERSIST SECURITY INFO=True;USER ID=xxx" providerName="Oracle.ManagedDataAccess.Client" />
</connectionStrings>
However, if I try to run my web app with all the crazy Web.config settings, I'm getting the error "ORA-12154: TNS:could not resolve the connect identifier specified". What am I doing wrong? Why is my config for the integration test assembly so simple and the Web.config so complex? Here's the pertinent sections of my Web.config (taken from Deploying and Configuring ODP.NET to work without installation with Entity Framework):
custom configSection:
<configSections>
<section name="oracle.manageddataaccess.client"
type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
the corresponding config section:
<oracle.manageddataaccess.client>
<version number="*">
<edmMappings>
<edmMapping dataType="number">
<add name="bool" precision="1"/>
<add name="byte" precision="2" />
<add name="int16" precision="5" />
</edmMapping>
</edmMappings>
</version>
</oracle.manageddataaccess.client>
custom system.data node:
<system.data>
<DbProviderFactories>
Remove in case this is already defined in machine.config
<remove invariant="Oracle.DataAccess.Client" />
<remove invariant="Oracle.ManagedDataAccess.Client" />
<add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client"
description="Oracle Data Provider for .NET, Managed Driver"
type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
EntityFramework node:
<entityFramework>
<defaultConnectionFactory type="Victoria.Data.OracleConnectionFactory, EntityFramework" />
</entityFramework>
Update 1: After reading through http://docs.oracle.com/cd/E16655_01/win.121/e17732/featConfig.htm#ODPNT8161, I tried modifying my Web.config oracle.manageddataaccess.client to the following and it works. However, it doesn't seem right to have the connectionString node referencing the TNS name AND this extra reference to the same TNS Names file.
<oracle.manageddataaccess.client>
<version number="*">
<dataSources>
<dataSource alias="SIEBMATS" descriptor="(DESCRIPTION=(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = xxx.yyy.zzz)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = siebmats)))" />
</dataSources>
<edmMappings>
<edmMapping dataType="number">
<add name="bool" precision="1"/>
<add name="byte" precision="2" />
<add name="int16" precision="5" />
</edmMapping>
</edmMappings>
</version>
</oracle.manageddataaccess.client>
One thing you can try is having the connection string like so:
connectionString="Data Source=//SERVER:PORT/INSTANCE_NAME;USER=XXX;PASSWORD=XXX".
Useful references here:
http://www.connectionstrings.com/oracle/
http://docs.oracle.com/cd/E51173_01/win.122/e17732/featConnecting.htm#ODPNT169
This has also helped me while having problems with EF:
Deploying and Configuring ODP.NET to work without installation with Entity Framework
Hope to have helped.
My problem was in incorrect/incomplete Oracle Driver version, had 11.2.0 installed. I add another 12.2.0 version, didn't change anything in web.config and it worked as charm
I suggest to try the solution proposed by #kolbasov in another thread but about the same problem: https://stackoverflow.com/a/20050462/9390179
It worked for me:
<oracle.manageddataaccess.client>
<version number="*">
<settings>
<setting name="TNS_ADMIN" value="C:\Oracle\product\11.1.0\client_1\network\admin" />
</settings>
</version>
</oracle.manageddataaccess.client>
I am trying to open PostgreSQL connection but getting ReflectionTypeLoadException while opening connection.
Please help me out to solve this problem by providing code or let me know how to remove this exception.
Code i am using so far is below:
**/* Connection String
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="superuserDatabase" value="postgres"/>
</appSettings>
<system.data>
<DbProviderFactories>
<clear/>
<add name="Npgsql Data Provider"
invariant="Npgsql"
description=".Net Framework Data Provider for Postgresql Server"
type="Npgsql.NpgsqlFactory, Npgsql" />
</DbProviderFactories>
</system.data>
<connectionStrings>
<add name="Simple.Data.Properties.Settings.DefaultConnectionString"
connectionString="host=localhost;port=5432;database=SimpleData;user id=postgres;password=P#ssw0rdsa;pooling=false"
providerName="Npgsql" />
<add name="Test"
connectionString="host=localhost;port=5432;database=SimpleData;user id=postgres;password=P#ssw0rdsa;pooling=false"
providerName="Npgsql" />
</connectionStrings>
</configuration>**
*/
I am getting following exception when trying to open connection in POSTGRESQL
var namedDb = Database.OpenNamedConnection("Test").Demo.All();
ReflectionTypeLoadException
This ReflectionLoadTypeException is most often caused because the DLLs you're using aren't up to date so the dependency chain fails. Use nuget to update your project with the latest DLLs. v0.16.2.2 of the PostgreSql provider requires
Simple.Data.Core (≥ 0.12.2.2)
Simple.Data.Ado (≥ 0.12.2.2)
Npgsql (≥ 2.0.11)
(via Mark Rendle) Try explicitly installing 0.16.2.2 of Simple.Data.Ado first, then installing the Postgres package.