I am trying to connect to Google Youtube API.
The last thing I changed is : adding the line new FileDataStore(folder). The code works well on localhost but triggers the following error on the server:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ComponentModel.Win32Exception: Access is denied
Here is my code:
public async Task<List<string>> GetSubscriptionsRequest(string id)
{
ClientSecrets secrets = new ClientSecrets() // tutorial : https://developers.google.com/identity/sign-in/web/devconsole-project
{
ClientId = "780499768563-j5dcgafhl5rg6ivh452iihcqe57gjvut.apps.googleusercontent.com",
ClientSecret = "--"
};
string userid = id ?? "user";
System.Diagnostics.Debug.WriteLine("userid " + userid);
var folder = System.Web.HttpContext.Current.Server.MapPath("/App_Data/MyGoogleStorage");
var credentialMethod2 = await GoogleWebAuthorizationBroker.AuthorizeAsync(
secrets,
// This OAuth 2.0 access scope allows an application to upload files to the
// authenticated user's YouTube channel, but doesn't allow other types of access.
new[]
{
YouTubeService.Scope.YoutubeUpload, YouTubeService.Scope.Youtube, YouTubeService.Scope.YoutubeForceSsl
,YouTubeService.Scope.YoutubeReadonly
},
userid, // if I can change this from "user" I get triggered to http://localhost:57464/authorize/?code=4/QUj58_0CI1abkj3fJptZQpw-AxCWUw5eYOLwg9edaqk# to accept Youtube permission for the Google user
CancellationToken.None,
new FileDataStore(folder)
//new FileDataStore(this.GetType().ToString()) // CRITICAL
);
var youtubeService = new YouTubeService(new BaseClientService.Initializer()
{
HttpClientInitializer = credentialMethod2,
ApplicationName = Assembly.GetExecutingAssembly().GetName().Name // will give the name of this .net project
});
var subscriptionsListRequest = youtubeService.Subscriptions.List("snippet");
subscriptionsListRequest.MaxResults = 50;
subscriptionsListRequest.Mine = true;
var subscriptionsListResponse = await subscriptionsListRequest.ExecuteAsync();
List<string> lstSubscriptionId = new List<string>();
foreach (var channel in subscriptionsListResponse.Items)
{
//System.Diagnostics.Debug.WriteLine(channel.Snippet.Title); // The Young Turks
//System.Diagnostics.Debug.WriteLine(channel.Snippet.ResourceId.ChannelId);
lstSubscriptionId.Add(channel.Snippet.ResourceId.ChannelId);
}
return lstSubscriptionId;
}
Here is the stack trace:
Stack Trace:
[Win32Exception (0x80004005): Access is denied]
System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) +756
System.Diagnostics.Process.Start() +131
System.Diagnostics.Process.Start(ProcessStartInfo startInfo) +49
Google.Apis.Auth.OAuth2.<ReceiveCodeAsync>d__6.MoveNext() +280
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Google.Apis.Auth.OAuth2.<AuthorizeAsync>d__8.MoveNext() +540
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Google.Apis.Auth.OAuth2.<AuthorizeAsync>d__4.MoveNext() +395
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Google.Apis.Auth.OAuth2.<AuthorizeAsync>d__1.MoveNext() +268
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Scraper_v1.Infrastructure.<GetSubscriptionsRequest>d__15.MoveNext() +576
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Scraper_v1.Controllers.<Mysubscriptions>d__19.MoveNext() +312
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
lambda_method(Closure , Task ) +33
System.Threading.Tasks.TaskHelpersExtensions.ThrowIfFaulted(Task task) +35
System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +67
System.Web.Mvc.Async.<>c__DisplayClass3f.<BeginInvokeAsynchronousActionMethod>b__3e(IAsyncResult asyncResult) +16
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +49
System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +57
System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +223
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +15
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +49
System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +24
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +102
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +44
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +15
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +16
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +54
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +16
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +44
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +12
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +16
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +44
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +11
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9744373
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Thanks
Related
We are using SSRS to generate reports. System is working fine since years. Today I get following error:
System.Web.Services.Protocols.SoapException: The item 'REPORT_NAME' cannot be found. ---> Microsoft.ReportingServices.Diagnostics.Utilities.ItemNotFoundException: The item 'REPORT_NAME' cannot be found.
at Microsoft.ReportingServices.Library.ReportExecution2005Impl.LoadReport(String Report, String HistoryID, ExecutionInfo2& executionInfo)
at Microsoft.ReportingServices.WebServer.ReportExecutionService.LoadReport(String Report, String HistoryID, ExecutionInfo& executionInfo)
Error disappeared when I recycled the app-pool. However after few minutes (like 30 minutes). I faced same error again. We are using SSRS 2012. Version 11.0.3000.0
Following is the stacktrace:
[FaultException: System.Web.Services.Protocols.SoapException: The item 'REPORT_NAME' cannot be found. ---> Microsoft.ReportingServices.Diagnostics.Utilities.ItemNotFoundException: The item 'REPORT_NAME' cannot be found.
at Microsoft.ReportingServices.Library.ReportExecution2005Impl.LoadReport(String Report, String HistoryID, ExecutionInfo2& executionInfo)
at Microsoft.ReportingServices.WebServer.ReportExecutionService.LoadReport(String Report, String HistoryID, ExecutionInfo& executionInfo)]
System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) +1080
System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result) +235
System.ServiceModel.Channels.<>c__DisplayClass7_01.<CreateGenericTask>b__0(IAsyncResult asyncResult) +146 System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization) +47 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60 System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +92 System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult) +22 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +72 System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +387 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +38 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +188 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38 System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +73
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +39 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38 System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +43 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +73
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
System.Web.CallHandlerExecutionStep.InvokeEndHandler(IAsyncResult ar) +212
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +166
i am kinda new working with Asp.net Rest and i dont know how to solve this, i already read many articles at stackoverflow and no one solved my problem, i tryed firewall i tryed the configurations on internet option and other things, i think the problem can be related to something that is confusing me, do i need to run the webservice before i run my client application ?? how to do it? because what i did was just programming my rest application then i created my asp.net mvc application where i connect to the rest service with this helper
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Http;
namespace ClienteMvcProdutos.Helpers
{
public static class WebApiHttpClient
{
public const string WebApiBaseAddress = "http://localhost:25426/";
public static HttpClient GetClient()
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(WebApiBaseAddress);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
return client;
}
}
}
already checked ports and they matched, already changed ports and it still dont work im kinda desesperating :S here is my stacktrace
[SocketException (0x274d): Nenhuma ligação pôde ser feita porque o computador de destino
as recusou activamente 127.0.0.1:25426]
System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) +6604828
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +249
[WebException: Unable to connect to the remote server]
System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
+606 System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
+64
[HttpRequestException: An error occurred while sending the request.]
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) +58 System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
+28 ClientMvcProdutos.Controllers.<Index>d__1.MoveNext() in C:\Users\Filipe\Documents\Visual Studio
2015\Projects\ClientMvcProdutos\ClientMvcProdutos\Controllers\ProdutosController.cs:25
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) +58 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
+26 System.Threading.Tasks.TaskHelpersExtensions.ThrowIfFaulted(Task task)
+42 System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult
asyncResult) +73
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult
asyncResult) +37
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult
asyncResult) +27
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +68
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult
asyncResult) +34
System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
+69 System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
+230 System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +27
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult
asyncResult) +27
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +68
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult
asyncResult) +34
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
+42 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult
asyncResult) +124
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult
asyncResult) +27
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +30
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult
asyncResult) +29
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult
asyncResult, ExecuteCoreState innerState) +27
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +48
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +30
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +21
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +32
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult
asyncResult, Controller controller) +26
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +40
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +30
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +21 System.Web.Mvc.Controller.EndExecute(IAsyncResult
asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult
asyncResult) +24
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult
asyncResult, ProcessRequestState innerState) +27
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +48
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +30
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +21
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
+29 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult
result) +23
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult
ar) +129
I am getting the value from text field but can not find the reason of not getting saved in the variable.
var user = new ApplicationUser() { UserName = model.Email ,Email = model.Email};
user is null despite Email contains the value. I have found it through debugging.
{
Line 81: var user = new ApplicationUser() { UserName = model.Email ,Email = model.Email};
Line 82: var result = await UserManager.CreateAsync(user, model.Password);
Line 83: if (result.Succeeded)
Line 84: {
Line 82 is the error.
Below is the code.
var user = new ApplicationUser() { UserName = model.Email ,Email = model.Email};
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
var db = new ApplicationDbContext();
var checkingAccount = new CheckingAccount
{
FirstName = model.FirstName,
LastName = model.LastName,
AccountNumber = "111014005",
Balance = 0,
ApplicationUserId = user.Id
};
db.CheckingAccounts.Add(checkingAccount);
db.SaveChanges();
Stack Trace:
[Win32Exception (0x80004005): The system cannot find the file
specified]
[SqlException (0x80131904): A network-related or instance-specific
error occurred while establishing a connection to SQL Server. The
server was not found or was not accessible. Verify that the instance
name is correct and that SQL Server is configured to allow remote
connections. (provider: SQL Network Interfaces, error: 52 - Unable to
locate a Local Database Runtime installation. Verify that SQL Server
Express is properly installed and that the Local Database Runtime
feature is enabled.)]
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean
allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions
userOptions, DbConnectionInternal& connection) +414
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) +78
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) +196
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) +146
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) +16
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
retry) +94
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1
retry) +110 System.Data.SqlClient.SqlConnection.Open() +96
System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.b__36(DbConnection
t, DbConnectionInterceptionContext c) +10
System.Data.Entity.Infrastructure.Interception.InternalDispatcher1.Dispatch(TTarget
target, Action2 operation, TInterceptionContext interceptionContext,
Action3 executing, Action3 executed) +72
System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection
connection, DbInterceptionContext interceptionContext) +360
System.Data.Entity.SqlServer.<>c__DisplayClass33.b__32()
+426 System.Data.Entity.SqlServer.<>c__DisplayClass1.b__0() +10
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func1
operation) +189
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action
operation) +78
System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection
sqlConnection, Action1 act) +175
System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection
sqlConnection, Action1 act) +557
System.Data.Entity.SqlServer.SqlProviderServices.CreateDatabaseFromScript(Nullable1
commandTimeout, DbConnection sqlConnection, String
createDatabaseScript) +86
System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection
connection, Nullable1 commandTimeout, StoreItemCollection
storeItemCollection) +164
System.Data.Entity.Core.Common.DbProviderServices.CreateDatabase(DbConnection
connection, Nullable1 commandTimeout, StoreItemCollection
storeItemCollection) +76
System.Data.Entity.Core.Objects.ObjectContext.CreateDatabase() +134
System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection
connection) +119
System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action
mustSucceedToKeepDatabase) +142
System.Data.Entity.Migrations.DbMigrator.Update(String
targetMigration) +78
System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext
internalContext, Func3 createMigrator, ObjectContext objectContext)
+89 System.Data.Entity.Internal.InternalContext.CreateDatabase(ObjectContext
objectContext, DatabaseExistenceState existenceState) +116
System.Data.Entity.Database.Create(DatabaseExistenceState
existenceState) +218
System.Data.Entity.CreateDatabaseIfNotExists1.InitializeDatabase(TContext
context) +149
System.Data.Entity.Internal.<>c__DisplayClassf1.<CreateInitializationAction>b__e()
+76 System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action
action) +60
System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
+357 System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext
c) +7
System.Data.Entity.Internal.RetryAction1.PerformAction(TInput input)
+110 System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action1
action) +198
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
+73 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type
entityType) +28
System.Data.Entity.Internal.Linq.InternalSet1.Initialize() +53
System.Data.Entity.Internal.Linq.InternalSet1.get_InternalContext()
+15 System.Data.Entity.Infrastructure.DbQuery1.System.Linq.IQueryable.get_Provider()
+38 System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync(IQueryable1
source, Expression1 predicate, CancellationToken cancellationToken)
+138 System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync(IQueryable1
source, Expression1 predicate) +133
Microsoft.AspNet.Identity.EntityFramework.d__6c.MoveNext()
+486 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) +52 Microsoft.AspNet.Identity.CultureAwaiter1.GetResult()
+59 Microsoft.AspNet.Identity.<ValidateUserName>d__4.MoveNext() +592 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) +52 Microsoft.AspNet.Identity.<ValidateAsync>d__0.MoveNext()
+283 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) +52 Microsoft.AspNet.Identity.<CreateAsync>d__0.MoveNext()
+582 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) +52 Microsoft.AspNet.Identity.<CreateAsync>d__d.MoveNext()
+531 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) +52 System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
+24 AutomatedTellerMachine.Controllers.d__9.MoveNext() in e:\Passion\Work\AutomatedTellerMachine\AutomatedTellerMachine\Controllers\AccountController.cs:82
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) +52
System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult
asyncResult) +84
System.Web.Mvc.Async.<>c__DisplayClass37.b__36(IAsyncResult
asyncResult) +17
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult
asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult
asyncResult) +32
System.Web.Mvc.Async.AsyncInvocationWithFilters.b__3d()
+50 System.Web.Mvc.Async.<>c__DisplayClass46.b__3f()
+225 System.Web.Mvc.Async.<>c__DisplayClass33.b__32(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult
asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult
asyncResult) +34
System.Web.Mvc.Async.<>c__DisplayClass2b.b__1c()
+26 System.Web.Mvc.Async.<>c__DisplayClass21.b__1e(IAsyncResult
asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult
asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult
asyncResult) +27
System.Web.Mvc.Controller.b__1d(IAsyncResult
asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.b__15(IAsyncResult
asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +28
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult
asyncResult) +10
System.Web.Mvc.MvcHandler.b__5(IAsyncResult
asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
+31 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult
result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+9514812 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
The stack trace shows that your application cannot connect to your database:
SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)
Note the highlighted section: This indicated that you don't have LocalDb installed. Either install it or change your connection string to point to a database that does exist.
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +357
http://www.asp.net/mvc/overview/getting-started/create-an-aspnet-mvc-5-web-app-with-email-confirmation-and-password-reset#addRes
when i run it and it should send me a email confirmation it gives me a bad request.
[Exception: Bad Request]
SendGrid.<CheckForErrorsAsync>d__b.MoveNext() +165
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
System.Runtime.CompilerServices.TaskAwaiter.GetResult() +21
SendGrid.<DeliverAsync>d__2.MoveNext() +741
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
System.Runtime.CompilerServices.TaskAwaiter.GetResult() +21
WebApplication3.<configSendGridasync>d__3.MoveNext() in c:\Users\kasper\Documents\Visual Studio 2013\Projects\WebApplication3\WebApplication3\App_Start\IdentityConfig.cs:47
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
System.Runtime.CompilerServices.TaskAwaiter.GetResult() +21
WebApplication3.<SendAsync>d__0.MoveNext() in c:\Users\kasper\Documents\Visual Studio 2013\Projects\WebApplication3\WebApplication3\App_Start\IdentityConfig.cs:24
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
System.Runtime.CompilerServices.TaskAwaiter.GetResult() +21
Microsoft.AspNet.Identity.CultureAwaiter.GetResult() +63
Microsoft.AspNet.Identity.<SendEmailAsync>d__129.MoveNext() +963
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
System.Runtime.CompilerServices.TaskAwaiter.GetResult() +21
WebApplication3.Controllers.<Register>d__13.MoveNext() in c:\Users\kasper\Documents\Visual Studio 2013\Projects\WebApplication3\WebApplication3\Controllers\AccountController.cs:166
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
System.Runtime.CompilerServices.TaskAwaiter.GetResult() +21
System.Threading.Tasks.TaskHelpersExtensions.ThrowIfFaulted(Task task) +61
System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +114
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult) +66
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +47
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +136
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +49
System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +117
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +323
System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +44
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +47
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +136
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +50
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +72
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +185
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +34
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +62
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +129
i'm new to this platform and completely clueless, any help appreciated.
I had a similar issue. Examine the MVC example under:
private async Task configSendGridasync(IdentityMessage message)
the credentials to log into SendGrid are defined using:
var credentials = new NetworkCredential(ConfigurationManager.AppSettings["mailAccount"],ConfigurationManager.AppSettings["mailPassword"]);
So I checked with SendGrid documentation for C# and they just simply ask for two strings.
I just passed two strings like so:
var username = "your_sendgrid_username";
var pswd = "your_sendgrid_password";
var credentials = new NetworkCredential(username, pswd);
I hope that helps some people with implementation using SendGrid. Must watch out for changes to SendGrid, using NuGet helps with that:
PM> Install-Package SendGrid
Aslo note that you must refrence some namespaces:
using System;
using System.Net;
using System.Net.Mail;
using SendGrid;
I am trying to pull a list of files from OneDrive to a list and display it to a view with a MVC application. This is my first go at it so I apologize if I am missing something obvious. I am getting an object reference not set to an instance of an object error. here is my code
public async Task<ActionResult> GetOneDriveFiles()
{
List<OneDriveFiles> myFilesList = new List<OneDriveFiles>();
try
{
var fileResults = await _spFilesClient.Files.Take(10).ExecuteAsync();
var files = fileResults.CurrentPage.OfType<Microsoft.Office365.SharePoint.File>().OrderBy(e => e.Name);
foreach (File file in files)
{
OneDriveFiles myFile = new OneDriveFiles();
myFile.Id = file.Id;
myFile.Name = file.Name;
myFile.Url = file.Url;
myFile.Size = file.Size;
myFile.TimeLastModified = file.TimeLastModified;
myFilesList.Add(myFile);
}
}
catch (RedirectRequiredException redir2)
{
return Redirect(redir2.RedirectUri.ToString());
}
return View(myFilesList);
}
here is the error code:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
O365APIURSAITO.Controllers.<GetOneDriveFiles>d__14.MoveNext() +110
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +84
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult) +17
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +50
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +26
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +28
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9651188
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
My issue was I forgot to ensure the client was created. To do this right after the opening bracket for the try statement put:
public async Task<ActionResult> GetOneDriveFiles()
{
List<OneDriveModel> oneDriveFiles = new List<OneDriveModel>();
try
{
await MyFilesApiSample.EnsureClientCreated();
var allMyFiles = await MyFilesApiSample.GetMyFiles();
foreach (var item in allMyFiles)
{
OneDriveModel newFile = new OneDriveModel();
newFile.Name = item.Name;
newFile.Url = item.Url;
newFile.Size = item.Size;
newFile.LastModified = item.TimeLastModified;
oneDriveFiles.Add(newFile);
}
}
catch (RedirectRequiredException ex)
{
return Redirect(ex.RedirectUri.ToString());
}
return View(oneDriveFiles);
}