Abstract InjectionMemberElement object cannot be created

Case: Azure webapp. Solution with multiple projects that uses unity.

Working fine on localhost but not when published, getting the message:

An error occurred creating the configuration section handler for unity: An abstract InjectionMemberElement object cannot be created. Please specify a concrete type.”

Unity is defined in the web.config as:

<configuration>
<configSections>
<section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration" />
</configSections>
</configuration>

<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
...
</unity

Isolved it by renaming the unity tags to “unityX” so I suspect that the IIS already has loaded unity from another referenced project in the solution.

After the renaming it doesn’t work locally cause it then can’t find and load unity. But that’s another issue…

 

Entity type is not part of the model for current context

The entity type <Type> is not part of the model for the current context.

ExceptionType:
System.InvalidOperationException
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
vid System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
vid System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()
--- Slut på stackspårningen från föregående plats där ett undantag utlöstes ---
vid System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
vid System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
vid System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()
--- Slut på stackspårningen från föregående plats där ett undantag utlöstes ---
vid System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
vid System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
vid System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()

Cause:
Wrong meta data in the MVC entity framework connection string. Had multiple entity models to seperate databases in the project. But had copied the connection strings to the other databases and changed the database settings and credentials. But forgot to update the entity model names in the meta data section of the connectionstring.

Solution:
Update database model names in the connection strings.

Linq select one id with flattened list (example)

If you have an object with an id property and another property with a list of objects (has inheritance) and wants to get a new list with the inherited list flattened and keep the id. You can do like this:

public class Test
{
private void TestMethod()
{

Category _cat1 = new Category();
_cat1.Color = "Blue";

Category _cat2 = new Category();
_cat2.Color = "Green";

Category _cat3 = new Category();
_cat3.Color = "Red";

Category _cat4 = new Category();
_cat4.Color = "Yellow";

Category _cat5 = new Category();
_cat5.Color = "Lime";

List list1 = new List();
list1.Add(_cat1);
list1.Add(_cat2);
list1.Add(_cat3);

List list2 = new List();
list2.Add(_cat4);
list2.Add(_cat5);

List _listCar = new List();
_listCar.Add(new Car() { Id = 1, Categories = list1 });
_listCar.Add(new Car() { Id = 2, Categories = list2 });

var item = (from x in _listCar
.SelectMany(x => x.Categories, (Ids, Cars) =>
new { Ids, Cars })
select new
{
Id = x.Ids.Id,
Cat = x.Cars.Color
}).ToList();

var aba = item;

}
}
public class Car
{
public int Id { get; set; }
public List Categories { get; set; }

}
public class Category
{
public string Color { get; set; }
}
}

Local IIS failed to map the path ‘/’

Got an exception of System.InvalidOperationException: “Failed to map the path ‘/'” when starting the site on a local IIS.

System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +556

[HttpException (0x80004005): Det gick inte att mappa sökvägen /.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +579
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +118
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +730

——
With my modest knowledge about hosting a site on a local IIS the solution turned out to be really simple.

1. Start a new command prompt in administrator mode.
2. Run command: “iisreset”

TADA!

Windows shortcut show desktop

In order to create a shortcut that shows the desktop you can create a shortcut in the quick launch section. Here is how:

1. Open the quick launch folder.
2. Create a new text file.
3. Copy and paste the following text in to the new file:
[Shell]
Command=2
IconFile=explorer.exe,3
[Taskbar]
Command=ToggleDesktop

4. Save the file.
5. Rename the file to “ShowDesktop.scf”.

Note! .scf files are used for Windows explorer commands.

File not found & dexDebug failed

Had some problem to build a Cordova app in VS. Tried updating java, Android SDK etc..but still same problem (java.lang file not found and dexDebug failed).

Finally I found out that you can’t have a Cordova project inside a path with ‘åäö’ which I had, i.e path to VS project: “C:\Test\Hambörjare\”. When I changed the path to non ‘åäö’ it started to work! =)

I read that this is a reported bug to the Java team at Oracle but I guess it’s not on the their number one todo list..

Call stored procedure via DBContext

Tried to call a SP via Entity framework (DBContext) but got a exception that parameter is not supplied.

My call looked like:
context.Database.ExecuteSqlCommand(“NameOfSP”, new SqlParameter(“@param1”, 1), new SqlParameter(“@param2”, DateTime.Now), new SqlParameter(“@param3”, “test”));

The right call should look like:
context.Database.ExecuteSqlCommand(“NameOfSP @p1, @p2, @p3”, new SqlParameter(“@p1”, 1), new SqlParameter(“@p2”, DateTime.Now), new SqlParameter(“@p3”, “test”));

You should include the parameter name after the name of the stored procedure.