Application ID – PayPal Sandbox

Hey everyone,

Just setting up an app that using the .NET Adaptive Payments SDK. Looking through the sandbox I was able to find the api signature, password and username but not the application ID (My Account > Overview > Account Information > API Access).

It turns out that ALL sandbox apps share the same ID:

Application ID: APP-80W284485P519543T

A project with an output type of class library cannot be started directly – MVC Project with Class Library

Hey everyone,

Just another quick post for fixing the following error in a multi-project solution:

A project with an output type of class library cannot be started directly

Simply right click on the project that you want to start and select “Set as StartUp Project”.

Source: http://stackoverflow.com/a/10004706/522859

There is already an open DataReader associated with this Command which must be closed first. – ASP.NET MVC

Hey everyone,

I ran into the following error this morning:

There is already an open DataReader associated with this Command which must be closed first.

It turns out there are a few causes for this. My issue was that I was attempting to open a result set while already iterating over another one.


 //Retrieve list of cart products and create list of suborders
 var cartProducts = db.CartProducts.Where(cartProduct => cartProduct.CartId == userOrder.CartId);

//Loop through each cart product
foreach(var cartProduct in cartProducts)
{
     //Retrieve suborder
     SubOrder subOrder = subOrders.Find(x => x.BusinessId == cartProduct.Product.BusinessId);

The solution to this was pretty easy thankfully. Simply add “ToList()” to the end of the initial request:


 //Retrieve list of cart products and create list of suborders
 var cartProducts = db.CartProducts.Where(cartProduct => cartProduct.CartId == userOrder.CartId).ToList();

An alternative solution is to modify your connection string in order to allow multiple result multiple result sets. Simply add the following to provider part:

MultipleActiveResultSets=true

Checkout these StackOverflow posts for more info:
http://stackoverflow.com/a/10498776/522859
http://stackoverflow.com/a/6064422/522859

Suddenly Getting The EntityFramework package is not installed on project ”. – ASP.NET MVC

Hey everyone,

I am working on a small project done in ASP.NET MVC4 and started getting the following error:

The EntityFramework package is not installed on project ”.

Get-Package : Cannot validate argument on parameter ‘ProjectName’. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
At C:SitesLearnerLessonspackagesEntityFramework.5.0.0toolsEntityFramework.psm1:611 char:40
+ $package = Get-Package -ProjectName <<<< $project.FullName | ?{ $_.Id -eq 'EntityFramework' }
+ CategoryInfo : InvalidData: (:) [Get-Package], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,NuGet.PowerShell.Commands.GetPackageCommand

The confusing thing was that I’d used it no more than an hour ago. The following StackOverflow post reveals the issue (and the fact that I should’ve read the error more carefully):

http://stackoverflow.com/a/14708897/522859

All I needed to do was select the correct project from the “Default Project” dropdown in the Package Manager Console:

The EntityFramework package is not installed on project ''
The EntityFramework package is not installed on project ”

You must call the “WebSecurity.InitializeDatabaseConnection” method before you call any other method of the “WebSecurity” class. This call should be placed in an _AppStart.cshtml file in the root of your site. – MVC4

Hey everyone,

Just another small issue I ran into while attempting to retrieve a user’s ID:

You must call the “WebSecurity.InitializeDatabaseConnection” method before you call any other method of the “WebSecurity” class. This call should be placed in an _AppStart.cshtml file in the root of your site.

Thankfully the first Google result was pretty helpful: http://stackoverflow.com/a/15864133/522859

All you need to do is remove [InitializeSimpleMembership] from the top of the AccountController and then add the following line to App_Start/AuthConfig.cs

WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);

JSON Issue: This request has been blocked because sensitive information – MVC

Hey everyone,

Started redoing Learner Lessons in MVC4 and AngularJS today. I ran into this little issue while trying to retrieve JSON:

This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet

It turns out that this behavious is intentionally prevented in order to avoid JSON hijacking. Thankfully the data I’m working with is not at all sensitive so the workaround is pretty straight forward:

public ActionResult Index()
{
     return Json(db.Regions.ToList(), JsonRequestBehavior.AllowGet);
}

Source: http://stackoverflow.com/a/4616442/522859

For those of you working with sensitive data that don’t want to risk exposing it, posting is suggested as an alternative on StackOverflow: http://stackoverflow.com/a/6440163/522859

Movies.mdf not in App_data Folder – MVC4 Tutorial

Hey everyone,

I’ve decided to take a look MVC4 (C#) and have just started the Movies tutorial. Unfortunately I ran into a bit of trouble with the database setup, for some reason mine wasn’t appearing in the app_data folder.

Apparently there are a few things you can try here:

Click Show All Files
This one is pretty simple, just click Show All Files
– Project > Show All Files

Refresh
Hit the refresh button
– Project > Refresh

Ensure that you’ve created a movie
You’ll need to make sure you’ve created a movie first. Apparently the database is not created until after a new row is inserted.

Final Solution, also the one that worked for me
The database wasn’t actually created under app_data, instead it was placed under: C:Program FilesMicrosoft SQL ServerMSSQL10_50.SQLEXPRESSMSSQLDATA

This StackOverflow post explains why: asp-net-retrieving-data-from-nowhere