Add-Migration: type initializer for "System.Net.ServicePointManager" threw an exception

I am trying to migrate Entity Framework code first in Azure Mobile Service. I have a project working locally and add this new class to my model:

using Microsoft.WindowsAzure.Mobile.Service; using System; namespace VCollectAPI.DataObjects { public class TagEdit : EntityData { public string EditedTagId { get; set; } public string SourceTagName { get; set; } public string ResultingTagName { get; set; } public DateTime TimeOfEdit { get; set; } } } 

I also add this property to my VCollectAPIContext: class DbContext

 public DbSet<TagEdit> TagEdits { get; set; } 

and add a line to my TagDomainManager: class EntityDomainManager

 if (changedItems.Contains("Name")) { _context.TagEdits.Add(new TagEdit { EditedTagId = current.Id, SourceTagName = current.Name, ResultingTagName = update.Name, TimeOfEdit = DateTime.UtcNow }); current.Name = update.Name; } 

In PMC (Package Manager Console) I run the command

Add-Migration RecordingTagEdits -Verbose

I expect that to move on to updating the schema, add a new table. Instead, I get the error "Type initializer for" System.Net.ServicePointManager "made an exception."

What am I doing wrong and how to fix it?

Full error tracing:

System.TypeInitializationException: the type initializer for "System.Net.ServicePointManager" threw an exception. ---> System.TypeInitializationException: the type initializer for "System.Net.ComNetOS" throws an exception. ---> System.Configuration.ConfigurationErrorsException: an item can only appear once in this section. (C: \ TFS \ HXDMSRC \ VisualCollections \ Development \ VCollectAPI \ tmp140.tmp line 16) on System.Configuration.BaseConfigurationRecord.EvaluateOne (String [] keys, section entry, logical isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord parentResult) in System.Configuration.BaseConfigurationRecord.Evaluate (FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object & result, object & resultRuntimeObject (GetRuntimeObjectleonblecklefonquelefonetlefonquelefoncleanfunctionname) checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object & result, object & resultRuntimeObject) in System.Configuration.BaseConfigurationRecord.GetSectionRecursive (String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObRegimeObimeObimeOb & result, object & resultRuntimeObject) in System.Configuration.BaseConfigurationRecord.GetSectionRecursive (String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object & result, object & resultRuntimeOconfiguration.bject ) under System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (String sectionName) in System.Configuration.ConfigurationManager.GetSection (String sectionName) in System.Configuration.PrivilegedConfigurationManager.DameName.Get. DiagnosticsConfiguration.Initialize () at System.Diagnostics.DiagnosticsConfiguration.get_Sources () at System.Diagnostics.TraceSource.Initialize () in System.Net.Logging.InitializeLogging () in System.Net.Logging.get_On () in System.Net. ComNetOS..cctor () --- End of the internal trace exception stacks System.Net.ServicePointManager..cctor () --- End of internal exception stack trace --- when System.Net.ServicePointManager.EnsureStrongCryptoSettingsInitialized () in Microsoft.VisualStudio.Platform.VsAppDomainManager.InitializeNewDomainetD AppDomainSystemDomain .AppDomain.CreateAppDomainManager () in System.AppDomain.Setup (arg object) in System.AppDomain.nCreateDomain (String friendlyName, AppDomainSetup setup, Evidence providedSecurityInfo, Evidence creators, SecurityInfoDecreamerInformationDecreamer.DenameDefename , AppDomainSetup appDomainInfo) in System.AppDomainManager.CreateDomain (String friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo) in System.AppDomain.InternalCreateDomain (String friendlyName, Evidence SecurityInfo, AppDomainSet information up) in System.AppDomain.CreateDomain (String friendlyName, Evidence SecurityInfo, AppDomainSetup information) in System.Data.Entity.Migrations.Design.ToolingFacade..ctor (String migrationsAssemblyName, String contextAssemblyName, String configurationTypeName, String workingDirectory, String configFile dataDirectory, DbConnectionInfo connectionStringInfo) in System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade (String configurationTypeName, Boolean useContextWorkingDirectory) with System.Data.Entity.Migrations.AddMigrationCommand.Executeleore Barename, string name, string nameChang .Entity.Migrations.AddMigrationCommand <. > C__DisplayClass2 <.. ctor> b__0 () in System.Data.Entity.Migrations.MigrationsDomainCommand.Execute (Action command) The type initializer for 'System.Net.ServicePointManager' threw an exception.

+4
source share
2 answers

Check web.config, there may be duplicate options.

+8
source

I had the following internal exception, which means that my connectionStrings section was above configSections :

Only one <configSections> element allowed per config file and if present must be the first child of the root <configuration> element

0
source

All Articles