Connection error on UserManager CreateAsync - mysql

I am getting the following error when trying to create a new user using the UserManager CreateAsync method. I am using an unmodified IdentityUser and IdentityRole. I have a few DBSets which populate with data from the database, so reading is not an issue, just writing to it seems to be.
{System.InvalidOperationException: Connection must be valid and open to commit transaction at MySql.Data.MySqlClient.MySqlTransaction.Commit()
at Microsoft.EntityFrameworkCore.Storage.RelationalTransaction.Commit()
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.<ExecuteAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.<SaveChangesAsync>d__54.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.<SaveChangesAsync>d__52.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.EntityFrameworkCore.DbContext.<SaveChangesAsync>d__35.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`9.<CreateAsync>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Identity.UserManager`1.<CreateAsync>d__68.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Identity.UserManager`1.<CreateAsync>d__73.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Controllers.Auth.AuthController.<Register>d__9.MoveNext() in AuthController.cs:line 102}
I'm using;
MySQL Entity Framework Core 7.0.7-m61
Visual Studio 2017
ASP.NET Core MVC 1.1.0
Identity 1.1
Line 102 mentioned in the error is var result = await userManager.CreateAsync(newUser, model.Password);
[HttpPost]
public async Task<ActionResult>Register(RegisterViewModel model)
{
try
{
if (ModelState.IsValid)
{
var newUser = new IdentityUser
{
Email = model.Email,
UserName = model.Username
};
var result = await _userManager.CreateAsync(newUser, model.Password);
if (result.Succeeded)
{
await _signInManager.SignInAsync(newUser, false);
_logger.LogInformation($"New user account created: {model.Username}");
return RedirectToAction("Index", "App");
}
_logger.LogError($"Registration failed for {model.Username}: ", result.Errors);
return View(model);
}
return View(model);
}
catch (Exception ex)
{
_logger.LogError("Database Failure: ", ex);
return View(model);
}
}
I'm learning asp.net and am stumbling here on what I'm hoping is an obvious error as it seems to be a basic connection issue but it's not making sense as the database can be queried using IdentityDBContext but not through the UserManager, which in my understanding uses the IdentityDBContext connection.

Do not use MySql.Data.EntityFrameworkCore-7.0.7-m61 provider and use something else. Oracle manages to embarrass themselves with each pre-release version of it.
With this release they managed to brake the package so hard, that it's unusable as that provider seems to close it's connection after every query. Use Pomelo.EntityFrameworkCore.MySql 1.1.0 instead (or wait for the next release of Oracles provider). Oracle was never strong at supporting ADO.NET/EF with current provider versions
Even better, use PostgreSQL or SqlServer instead.

Related

I'm getting a startup error on a BlobStorage Trigger

I'm getting the following error when I create a blob storage triggered function (v2).
The function runtime is unable to start. Microsoft.WindowsAzure.Storage: Requested value 'DELETE,GET,HEAD,MERGE,POST,OPTIONS,PUT,PATCH' was not found. System.Private.CoreLib: Requested value 'DELETE,GET,HEAD,MERGE,POST,OPTIONS,PUT,PATCH' was not found.
This happens if I create the function in VSTS or if I create it through the Azure portal.
The KUDO logs show the following error:
2019-06-24T13:00:38.588 [Error] A host error has occurred
Microsoft.WindowsAzure.Storage.StorageException : Requested value 'DELETE,GET,HEAD,MERGE,POST,OPTIONS,PUT,PATCH' was not found. ---> System.ArgumentException : Requested value 'DELETE,GET,HEAD,MERGE,POST,OPTIONS,PUT,PATCH' was not found.
at System.Enum.TryParseEnum(Type enumType,String value,Boolean ignoreCase,EnumResult& parseResult)
at System.Enum.Parse(Type enumType,String value,Boolean ignoreCase)
at Microsoft.WindowsAzure.Storage.Shared.Protocol.ServiceProperties.<>c.<ReadCorsPropertiesFromXml>b__67_0(XElement rule)
at System.Linq.Enumerable.SelectEnumerableIterator.ToList()
at System.Linq.Enumerable.ToList[TSource](IEnumerable source)
at Microsoft.WindowsAzure.Storage.Shared.Protocol.ServiceProperties.ReadCorsPropertiesFromXml(XElement element)
at Microsoft.WindowsAzure.Storage.Shared.Protocol.ServiceProperties.FromServiceXml(XDocument servicePropertiesDocument)
at Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpResponseParsers.ReadServiceProperties(Stream inputStream)
at Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient.<>c.<GetServicePropertiesImpl>b__60_2(RESTCommand cmd,HttpResponseMessage resp,OperationContext ctx)
at async Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteAsyncInternal[T](RESTCommand cmd,IRetryPolicy policy,OperationContext operationContext,CancellationToken token)
End of inner exception
at async Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteAsyncInternal[T](RESTCommand cmd,IRetryPolicy policy,OperationContext operationContext,CancellationToken token)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Blobs.Listeners.BlobLogListener.EnableLoggingAsync(CloudBlobClient blobClient,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Blobs\Listeners\BlobLogListener.cs : 188
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Blobs.Listeners.BlobLogListener.CreateAsync(CloudBlobClient blobClient,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Blobs\Listeners\BlobLogListener.cs : 42
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Blobs.Listeners.PollLogsStrategy.RegisterAsync(CloudBlobContainer container,ITriggerExecutor triggerExecutor,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Blobs\Listeners\PollLogsStrategy.cs : 73
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Blobs.Listeners.ScanBlobScanLogHybridPollingStrategy.RegisterAsync(CloudBlobContainer container,ITriggerExecutor triggerExecutor,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Blobs\Listeners\ScanBlobScanLogHybridPollingStrategy.cs : 61
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Blobs.Listeners.BlobListenerFactory.RegisterWithSharedBlobListenerAsync(String hostId,SharedBlobListener sharedBlobListener,CloudBlobClient blobClient,CloudQueue hostBlobTriggerQueue,IMessageEnqueuedWatcher messageEnqueuedWatcher,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Blobs\Listeners\BlobListenerFactory.cs : 155
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Blobs.Listeners.BlobListenerFactory.CreateAsync(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Blobs\Listeners\BlobListenerFactory.cs : 93
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.ListenerFactory.CreateAsync(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs : 426
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Listeners.HostListenerFactory.CreateAsync(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Listeners\HostListenerFactory.cs : 62
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Listeners.ListenerFactoryListener.StartAsyncCore(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Listeners\ListenerFactoryListener.cs : 45
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Listeners.ShutdownListener.StartAsync(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Listeners\ShutdownListener.cs : 29
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.JobHost.StartAsyncCore(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\JobHost.cs : 101
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.ScriptHost.StartAsyncCore(CancellationToken cancellationToken) at C:\azure-webjobs-sdk-script\src\WebJobs.Script\Host\ScriptHost.cs : 241
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.WebHost.WebJobsScriptHostService.StartHostAsync(CancellationToken cancellationToken,Int32 attemptCount,JobHostStartupMode startupMode) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\WebJobsScriptHostService.cs : 163
2019-06-24T13:00:38.696 [Information] Stopping JobHost```
As the exception stack explains, it can't parse the 'DELETE,GET,HEAD,MERGE,POST,OPTIONS,PUT,PATCH' into a single http method value. The reason why this is happening is due to some discovery process of the azure storage common library. It will fetch an xml server configuration to get the values of your cors rules. While the user interface allows you to select multiple methods, this library can not parse the value and will throw an exception.
A possible workaround could be to select only one method per rule.
I created a git hub issue for this.
Edit1
As remarked in comments only verbs 'GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, CONNECT, MERGE' are known 'PATCH' is not a known verb.
Edit2
The issue will not be solved in version 11 of the storage SDK which is annoying as this version is also used by the Azure function libraries version 4. To get it solved we need to wait till version 5 is available, as it will pick up the version 12 of the storage SDK.
I just removed the CORS policy, and it worked !
Removing CORS header broke forms recognizer.
Turns out this was a bug in the sdk when CORS was enabled - https://github.com/Azure/azure-storage-net/issues/916 .
Updating to the latest functions and storage sdk resolved the issue.

ComponentActivatorException: Instance is already being tracked

I update to TenantManger constructor to include "RoleManager roleManager". I am not getting the exception below.
public TenantManager(IUnitOfWorkManager unitOfWorkManager, IRepository<User, long> userRepository, IRepository<Tenant> tenantRepository, IRepository<TenantFeatureSetting, long> tenantFeatureRepository, IRepository<RolePermissionSetting, long> rolePermissionRepository, EditionManager editionManager, RoleManager roleManager, IAbpZeroFeatureValueStore featureValueStore/*, UserStore userStore*/)
I am not sure to fully understand the meaning the following exception. What am I missing? How do I resolve this?
Castle.MicroKernel.ComponentActivator.ComponentActivatorException: Instance Castle.Proxies.TenantManagerProxy of component MyProject.MultiTenancy.TenantManager_027bb11f-f5ee-469b-84c5-8e53430d3caa is already being tracked.
The factory method providing instances of the component is reusing instances, but the lifestyle of the component is Transient which requires new instance each time.
In most cases it is advised for the factory method not to be handling reuse of the instances, but to chose a lifestyle that does that appropriately.
Alternatively, if you do not wish for Windsor to track the objects coming from the factory change your regustration to '.UsingFactoryMethod(yourFactory, managedExternally: true)'
at Castle.MicroKernel.Releasers.LifecycledComponentsReleasePolicy.Track(Object instance, Burden burden)
at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)
at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments, IReleasePolicy policy)
at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy)
at Abp.Events.Bus.Factories.IocHandlerFactory.GetHandler()
at Abp.Events.Bus.EventBus.TriggerHandlingException(Type eventType, Object eventSource, IEventData eventData, List`1 exceptions)
at Abp.Events.Bus.EventBus.Trigger(Type eventType, Object eventSource, IEventData eventData)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at Abp.Domain.Uow.UnitOfWorkBase.OnCompleted()
at Abp.Domain.Uow.UnitOfWorkBase.<CompleteAsync>d__57.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.AspNetCore.Mvc.Uow.AbpUowActionFilter.<OnActionExecutionAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextExceptionFilterAsync>d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ExceptionContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextResourceFilter>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeAsync>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Swashbuckle.SwaggerUi.Application.SwaggerUiMiddleware.<Invoke>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Swashbuckle.SwaggerUi.Application.RedirectMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Swashbuckle.Swagger.Application.SwaggerMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()

Service Fabric Actor remoting call results in "Specified cast is not valid." exception

when trying remoting over actor in Service Fabric I am getting following exception: "Specified cast is not valid.".
My code is as follows:
Initialization of actorProxy
private static Uri serviceUri = new Uri("fabric:/ServiceFabricVoting/MyTestActorService");
private static IMyTestActor myActorProxy = ActorProxy.Create<IMyTestActor>(ActorId.CreateRandom(), serviceUri);
Calling of method:
var number = await myActorProxy.GetCountAsync();
Actor Implementation:
[StatePersistence(StatePersistence.Persisted)]
internal class MyTestActor : Actor, IMyTestActor
{
/// <summary>
/// Initializes a new instance of MyTestActor
/// </summary>
/// <param name="actorService">The Microsoft.ServiceFabric.Actors.Runtime.ActorService that will host this actor instance.</param>
/// <param name="actorId">The Microsoft.ServiceFabric.Actors.ActorId for this actor instance.</param>
public MyTestActor(ActorService actorService, ActorId actorId)
: base(actorService, actorId)
{
}
/// <summary>
/// This method is called whenever an actor is activated.
/// An actor is activated the first time any of its methods are invoked.
/// </summary>
protected override Task OnActivateAsync()
{
ActorEventSource.Current.ActorMessage(this, "Actor activated.");
// The StateManager is this actor's private state store.
// Data stored in the StateManager will be replicated for high-availability for actors that use volatile or persisted state storage.
// Any serializable object can be saved in the StateManager.
// For more information, see https://aka.ms/servicefabricactorsstateserialization
return this.StateManager.TryAddStateAsync("count", 0);
}
/// <summary>
/// TODO: Replace with your own actor method.
/// </summary>
/// <returns></returns>
Task<int> IMyTestActor.GetCountAsync()
{
return this.StateManager.GetStateAsync<int>("count");
}
/// <summary>
/// TODO: Replace with your own actor method.
/// </summary>
/// <param name="count"></param>
/// <returns></returns>
Task IMyTestActor.SetCountAsync(int count)
{
// Requests are not guaranteed to be processed in order nor at most once.
// The update function here verifies that the incoming count is greater than the current count to preserve order.
return this.StateManager.AddOrUpdateStateAsync("count", count, (key, value) => count > value ? count : value);
}
}
And this is stack trace for exception:
" at Microsoft.ServiceFabric.Services.Communication.FabricTransport.Common.NativeServiceCommunication.CreateServiceCommunicationClient(Guid& iid, IntPtr transportSettingsPtr, IntPtr connectionAddress, IFabricCommunicationMessageHandler notificationHandler, IFabricServiceConnectionEventHandler connectionEventHandler)\r\n at Microsoft.ServiceFabric.Services.Communication.FabricTransport.Client.NativeServiceCommunicationClient.CreateNativeClient(FabricTransportSettings transportSettings, String connectionAddress, NativeClientConnectionEventHandler eventHandler, IServiceRemotingCallbackClient contract)\r\n at Microsoft.ServiceFabric.Services.Communication.FabricTransport.Client.NativeServiceCommunicationClient.<>c__DisplayClass2.<.ctor>b__0()\r\n at System.Fabric.Interop.Utility.<>c__DisplayClass13.<WrapNativeSyncInvoke>b__12()\r\n at System.Fabric.Interop.Utility.WrapNativeSyncInvoke[TResult](Func`1 func, String functionTag, String functionArgs)\r\n at System.Fabric.Interop.Utility.RunInMTA(Action action)\r\n at Microsoft.ServiceFabric.Services.Communication.FabricTransport.Client.FabricTransportServiceRemotingClientFactoryImpl.CreateClientAsync(String endpoint, CancellationToken cancellationToken)\r\n at Microsoft.ServiceFabric.Services.Communication.Client.CommunicationClientFactoryBase`1.<CreateClientWithRetriesAsync>d__16.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Communication.Client.CommunicationClientFactoryBase`1.<GetClientAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Communication.Client.CommunicationClientFactoryBase`1.<GetClientAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Remoting.FabricTransport.Client.FabricTransportServiceRemotingClientFactory.<Microsoft.ServiceFabric.Services.Communication.Client.ICommunicationClientFactory<Microsoft.ServiceFabric.Services.Remoting.Client.IServiceRemotingClient>.GetClientAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient`1.<GetCommunicationClient>d__22.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient`1.<InvokeWithRetryAsync>d__7`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Remoting.Client.ServiceRemotingPartitionClient.<InvokeAsync>d__8.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyBase.<InvokeAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyBase.<ContinueWithResult>d__7`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at VotingService.VotingService.<ProcessRequestAsync>d__4.MoveNext() in C:\\Users\\mlani\\Develop\\ServiceFabricVoting\\VotingService\\VotingService.cs:line 148"
I am testing the application on local cluster. Implementation of the actor class and actor interface are default ones, which were generated after adding actor service to the project.
Thank you for any piece of advice.
I have faced the same problem. I was calling an Actor service from a stateless service. The problem was that stateless service used a different version of Microsoft.ServiceFabric.Actors nuget package. After I changed the versions to be the same, the problem went away.
This issue might happen when you have different version of service fabric SDK than you reference from stateless/stateful service.

HockeyApp crashes on back button press on Windows Phone

HockeyApp crashes on pressing back button when it prompts on app launch and asks for sending/deleting crash logs. A NullReferenceException occurs inside HockeyApp; the stacktrace is attached.
The platform is Windows Phone 8.1 RT and HockeyApp version is 2.2.2
How can I fix this issue in my app?
Stacktrace:
{
"contact": null,
"description": null,
"log": "Package: BuggyApp\nVersion: 1.1.0.0\nOS: Windows Phone\nWindows Phone: 8.1\nManufacturer: Microsoft\nModel: Virtual\nDate: 2015-09-07T10:29:41.6261178Z\nProduct-ID: 00000000-0000-0000-0000-000000000000
System.NullReferenceException: Object reference not set to an instance of an object.
at HockeyApp.CrashHandler.<AskUserForAgreementAsync>d__c.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at HockeyApp.CrashHandler.<HandleCrashesAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at HockeyApp.HockeyClientExtensionsWinUniversal.<SendCrashesAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at BuggyApp.App.<OnLaunched>d__e.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__3(Object state)
at System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore()",
"sdk": "HockeySDKWP81",
"sdk_version": "2.2.2",
"userID": null
}
It is bug in the HockeyApp sdk. It was fixed two month ago with this commit. But the lastest version of the sdk (2.2.2) built 8 moth ago.
So you should wrap SendCrashesAsync invocation with try { //... } catch (NullReferenceException) { } and wait for new build of the sdk.

Website in Azure gives database connection error

I just moved my MVC5 web-project to Azure. The project uses a MySql database which is now hosted in Azure as well. I have updated the connection strings, and if I start the website from localhost on my own machine (still pointing to the database on Azure) all works well. But if I start the website from my Azure url, I get an sql error.
System.Data.Entity.Core.ProviderIncompatibleException: The provider
did not return a ProviderManifestToken string. --->
MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the
specified MySQL hosts. ---> System.Net.Sockets.SocketException: An
attempt was made to access a socket in a way forbidden by its access
permissions 127.0.0.1:3306 at
System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) at
MySql.Data.Common.MyNetworkStream.CreateSocketStream(MySqlConnectionStringBuilder
settings, IPAddress ip, Boolean unix) at
MySql.Data.Common.MyNetworkStream.CreateStream(MySqlConnectionStringBuilder
settings, Boolean unix) at
MySql.Data.Common.StreamCreator.GetStream(MySqlConnectionStringBuilder
settings) at MySql.Data.MySqlClient.NativeDriver.Open() --- End of
inner exception stack trace --- at
MySql.Data.MySqlClient.NativeDriver.Open() at
MySql.Data.MySqlClient.Driver.Open() at
MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder
settings) at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() at
MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() at
MySql.Data.MySqlClient.MySqlPool.GetConnection() at
MySql.Data.MySqlClient.MySqlConnection.Open() at
MySql.Data.MySqlClient.MySqlProviderServices.GetDbProviderManifestToken(DbConnection
connection) at
System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection
connection) --- End of inner exception stack trace --- at
System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection
connection) at
System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices
providerServices, DbConnection connection) --- End of inner exception
stack trace --- at
System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices
providerServices, DbConnection connection) at
System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.<>c__DisplayClass1.b__0(Tuple3
k) at
System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey
key, Func2 valueFactory) at
System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection
connection) at
System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection
connection, DbProviderManifest& providerManifest) at
System.Data.Entity.DbModelBuilder.Build(DbConnection
providerConnection) at
System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext
internalContext) at
System.Data.Entity.Internal.RetryLazy2.GetValue(TInput input) at
System.Data.Entity.Internal.LazyInternalContext.InitializeContext() at
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type
entityType) at
System.Data.Entity.Internal.Linq.InternalSet1.Initialize() at
System.Data.Entity.Internal.Linq.InternalSet1.Include(String path) at
System.Data.Entity.Infrastructure.DbQuery1.Include(String path) at
System.Data.Entity.QueryableExtensions.Include[T](IQueryable1 source,
String path) at
System.Data.Entity.QueryableExtensions.Include[T,TProperty](IQueryable1
source, Expression1 path) at
Microsoft.AspNet.Identity.EntityFramework.UserStore6.GetUserAggregateAsync(Expression1
filter) at
Microsoft.AspNet.Identity.EntityFramework.UserStore6.FindByNameAsync(String
userName) at
Microsoft.AspNet.Identity.UserManager2.FindByNameAsync(String
userName) at
Microsoft.AspNet.Identity.Owin.SignInManager2.<PasswordSignInAsync>d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
tripplanner.Controllers.AccountController.<Login>d__2.MoveNext() ---
End of stack trace from previous location where exception was thrown
--- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at
System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult
asyncResult) at
System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult
asyncResult) at
System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult1.CallEndDelegate(IAsyncResult
asyncResult) at
System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase1.End()
at
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult
asyncResult) at
System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
at
System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
at
System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) at
System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult1.CallEndDelegate(IAsyncResult
asyncResult) at
System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult
asyncResult) at
System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.b__1c()
at
System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.b__1e(IAsyncResult
asyncResult);
Hope someone can help.
UPDATE: I was using the wrong web.config file in Azure.