Showing posts with label Error Resolutions. Show all posts
Showing posts with label Error Resolutions. Show all posts

Tuesday, September 13, 2016

Error: [ng:areq] Argument 'fn' is not a function, got string

[Error-Messages%255B2%255D.png]

I confronted an error which is shown above during Angular application development which was little tricky to resolve.Though later we could be able to identify an issue  and fix an issue.

At time of module loading in angular we were injecting dependancy like this:

var routingApp = angular.module('routingApp', ['ngRoute'], ['ui.bootstrap']);

Actually this is a wrong way to do ,due to this it was prompting an error

Resolution : The workaround is given below as inject a dependancy in same braket rather in different one.

var routingApp = angular.module('routingApp', ['ngRoute', 'ui.bootstrap']);

Hope it will give you some brief to fix your solution

Thanks

Saturday, April 16, 2016

Ensure that HttpConfiguration.EnsureInitialized() is called in the application's startup

This error prompts you when you forget to initialize the apllication startup to fix this problem kindly use the given below line and add it under global.asax file of solution.

   GlobalConfiguration.Configuration.EnsureInitialized();

image

This is the complete stack trace which comes when you run an application.

<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
The object has not yet been initialized. Ensure that HttpConfiguration.EnsureInitialized() is called in the application's startup code after all other initialization code.
</ExceptionMessage>
<ExceptionType>System.InvalidOperationException</ExceptionType>

<StackTrace>
at System.Web.Http.Routing.RouteCollectionRoute.get_SubRoutes() at System.Web.Http.Routing.RouteCollectionRoute.GetRouteData(String virtualPathRoot, HttpRequestMessage request) at System.Web.Http.WebHost.Routing.HttpWebRoute.GetRouteData(HttpContextBase httpContext)
</StackTrace>

</Error>

Hope it will sort out your issue.

Learn more about MVC and WebApi :

http://www.dotnetpiper.com/search/label/MVC

http://www.dotnetpiper.com/search/label/WCF%20and%20WebAPI

Saturday, April 9, 2016

The request contains an entity body but no Content-Type header
The Simple solution for such issue is please put “ Content-Type: application/json; charset=utf-8” in request.
Kinldy find a screen shot given below for reference:
image
Please refer www.dotnetpiper.com

Monday, April 4, 2016

Concert crowd
Hi Folks,
If you want to access the ModelState property in the View , you can use the ModelState in your Razor View as depicted below in image:

This is the source code as shown below:
  1. @model IEnumerable<MVCSample.Models.EmpRegistration> 
  2. @{ 
  3.     ViewBag.Title = "Verify"; 
  4. if (@ViewContext.ViewData.ModelState.IsValid) 
  5.     { 
  6.         ViewBag.Title = "Verify"; 
  7. if (TempData["EmployeeRegistration"] != null) 
  8.         { 
  9.             var tempDataEmployeeRegistration = TempData["EmployeeRegistration"]; 
  10.         } 
  11.     } 
    Thanks
To learn more about MVC please go to the following link.
MVC Articles
Thanks.
Enjoy coding and reading.

Monday, August 11, 2014

Validation failed for one or more entities. See EntityValidationErrors property for more details.
Error-Messages
Today I encountered an error during data insertion through Entity Framework as per the Title.
There could be a various cause of such issue .Here I am talking about one of them.In database I restricted Name column data Type to nvarchar(10).
 and I was inserting value which has more than 10 character.
 
image
 
As soon as I try to insert value it generates me an error as depicted below:
 
clip_image002
.
 
I have used the code as shown below to identify the root cause.
  1: public ActionResult Create(EmpRegistration collection)
  2:         {
  3:             try
  4:             {
  5:                
  6:             }
  7:             catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
  8:             {
  9:                 Exception raise = dbEx;
 10:                 foreach (var validationErrors in dbEx.EntityValidationErrors)
 11:                 {
 12:                     foreach (var validationError in validationErrors.ValidationErrors)
 13:                     {
 14:                         string message = string.Format("{0}:{1}",
 15:                             validationErrors.Entry.Entity.ToString(),
 16:                             validationError.ErrorMessage);
 17:                         // raise a new exception nesting
 18:                         // the current instance as InnerException
 19:                         raise = new InvalidOperationException(message, raise);
 20:                     }
 21:                 }
 22:                 throw raise;
 23:             }
 24:         }

This code  help you to trace exact error.The way it suggested to me that “The field Name must be a string or array type with a maximum length of '10'.”



image



This is the complete code which runs perfectly as shown below .I wish this code will help you sometime.


  1: public ActionResult Create(EmpRegistration collection)
  2:         {
  3:             try
  4:             {
  5:                 if (ModelState.IsValid)
  6:                 {
  7:                     EmpRegistration empRegis = new EmpRegistration();
  8:                     // TODO: Add insert logic here
  9:                     empRegis.Address = collection.Address;
 10:                     empRegis.City = collection.City;
 11:                     empRegis.Id = 7;
 12:                     empRegis.Name = collection.Name;
 13:                     objEnity.EmpRegistrations.Add(empRegis);
 14:                     objEnity.SaveChanges();
 15: 
 16:                     return View();
 17:                 }
 18:                 return View(objEnity.EmpRegistrations);
 19:             }
 20:             catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
 21:             {
 22:                 Exception raise = dbEx;
 23:                 foreach (var validationErrors in dbEx.EntityValidationErrors)
 24:                 {
 25:                     foreach (var validationError in validationErrors.ValidationErrors)
 26:                     {
 27:                         string message = string.Format("{0}:{1}",
 28:                             validationErrors.Entry.Entity.ToString(),
 29:                             validationError.ErrorMessage);
 30:                         // raise a new exception nesting
 31:                         // the current instance as InnerException
 32:                         raise = new InvalidOperationException(message, raise);
 33:                     }
 34:                 }
 35:                 throw raise;
 36:             }
 37:         }

To learn more about MVC please go through the following link.
MVC Articles
Enjoy coding and readingSmile

Tuesday, August 5, 2014

Could not be loaded because it has a parameter or return type of type System.ServiceModel.Channels.Message in WCF
 
WCF
During an implementation of WCF Operation Contract I encountered an error as per the Title.
I was returning wrong parameter value from Operation contract which takes Message Contract as parameter .Kindly refer an image to understand real fact.
 
image
 
There are some limitation which are listed below,which we should keep in mind during implementation of WCF service








You can use the Message class as an input parameter of an operation, the return value of an operation, or both. If Message is used anywhere in an operation, the following restrictions apply:
  • The operation cannot have any out or ref parameters.
  • There cannot be more than one input parameter. If the parameter is present, it must be either Message or a message contract type.
  • The return type must be either void, Message, or a message contract type
Hope it will help you sometime.
 
To know more about MVC please go through with given below link.
MVC Articles
Enjoy Coding and Reading Smile