Validation failed in Entity Framework, ASP.NET MVC3 - asp.net-mvc-3

My application using ASP.NET MVC3 with EF4.1, deployed on IIS7. Recently I've meet an error when trying to save an entity to an existing database on the production server, but everything goes well on my development machine.
I tried to build deploy package in VS2010 and import that package in IIS7, also, I've tried to upload all the solutions and create an application in IIS7 manually, but both of the 2 sites come to an error when executing a function that saves an entity to the database.
Error message is pasted below, but the physical path in error message does not exist in the production server, it's a path in my local development machine. This makes me confused. Has anybody ever seen this before?
BTW, I've fully backed up my database and restored it on the production server, so all the databases are same.
I'm open to hear any advice.
Thanks
Cheng
Error message:
Server Error in '/xxxx' Application. Validation failed for one or
more entities. See 'EntityValidationErrors' property for more details.
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.Data.Entity.Validation.DbEntityValidationException: Validation
failed for one or more entities. See 'EntityValidationErrors' property
for more details.
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:
[DbEntityValidationException: Validation failed for one or more entities. See
'EntityValidationErrors' property for more details.]
System.Data.Entity.DbContext.SaveChanges() +212
xxxxx.Models.SetupRepository.CreateApplicationOption(Guid companyId) in
D:\xxxx\Models\SetupRepository.cs:59
xxxxx.MvcApplication.MvcApplication_PostAcquireRequestState(Object sender, EventArgs e) > in D:\xxxx\Global.asax.cs:87
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+148 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously) +75

Related

SQL Error on lead form for email - CRM 2015

On the lead form when I enter in Email id and hit save it throws a following SQL error below, but there's no error, if I leave it empty.
here is the log file message
Unhandled Exception:
System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault,
Microsoft.Xrm.Sdk, Version=7.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35]]: Generic SQL error.Detail:
Based on the log file message and the public key token and research, I disabled the plugin activity plugin on lead form, I still receive the error message on form.
How to resolve this issue ?
You will need to debug the Generic SQL Error message to find more detail on the problem. Try turning on server logging and review the CRM log files, failing that try and capture the error within SQL.

Web API 404 File or Directory not Found for "root" routes

I am developing a RESTful web api service. It's web api v.1, not v.2. Also I am developing on Visual Studio 2010 SP1. I have installed the MVC 4 for VS2010 SP1.
Please understand and keep in mind that Upgrading to newer versions of VS or Web Api 2 is not an option.
I have the following problem after a Windows Update ocurred.
When I try to use my RESTful api this way....
http://url.com/documents/ (get all the documents) I get the following error...
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Here is the stack trace.
[HttpException]: File does not exist. at System.Web.StaticFileHandler.GetFileInfo(String virtualPathWithPathInfo, String physicalPath, HttpResponse response) at System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext context, String overrideVirtualPath) at System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state) at system.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
If I specify the action name directly, it works. For example...
http://url.com/documents/get (gets all the documents) or
http://url.com/documents/7 (gets document id=7.
It only fails when you call it by its default name. I have already read similar situations here and I have tried to follow their solutions but they are not working for me properly.
Now, I know this is not a "web api routing" issue because I actually get the .net default exception page html markup (I am using Postman to test my webservice). When I force a "routing issue", then I get a JSON error description, which means that the Controller actually got created in the pipeline and returned a response.
Also, I have a custom file (SecurityHandler) that inherits from DelegatingHandler. This file gets executed almost first in the pipeline with each call to the api. Even before the actual Controller. Well, this file is never called when I get the error, which confirms to me that the "webserver" (either VS Development Server or IIS 7) is the one throwing the exception.
I have exhausted every single solution that I have found here. Change my web.config to multiple handlers configurations, re-installed MVC 4 for VS2010, created an entire new project... all these efforts have shown no results whatsoever.
Like I said, this was working perfectly fine until my pc restarted from a Windows Update BUT... why does it fail in the server as well? I did deploy my api to the server after the error started to occur.
Thanks.
The issue is not in Web API (and has nothing to do with it's version or Visual Studio 2010), it's the static file handler trying to serve and failing.
Alternatives:
0. Do you have a documents folder in your site? Get rid of it.
1. Remove the static file handler for directory browsing and re-add it.
2. Use RAMMFAR (less recommended)

ASP.NET MVC3: System.NotSupportedException: Specified method is not supported

Hello I am Developing a ASP.NET MVC3 application and MYSQL Database accessed by entity framework. I am done with the deployment part and now i am trying to deploy it on GO DADDY server after deploying it so far every page is working fine but only in one page the following error is coming
Specified method is not supported.
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.NotSupportedException: Specified method is not supported.
i have tried a lot searching to find the solution of the error please help me with this
following is the snap shot of the error
You happen to have a query that results in the DbApplyExpression node in the command tree. This node is typically translated to CROSS/OUTER APPLY construct in SQL however MySQL does not support CROSS/OUTER APPLY. Most likely you will have to change your query a little bit to avoid the CROSS/OUTER APPLY. Take a look a this msdn article for more details. I also found something at DevArt website that can be helpful

Umbraco installation problem. Can not install starter kit. The key was not present in the dictionary

This is a problem I get when trying to install Umbraco. I know that Umbraco has its own forum, but they have just moved it to another url, and I can not seem to be able to post a question there. So I try here. I know this problem has been reported before, and have tried to implement the solutions other people have reported. But I still can not seem to get it working. I have tried to both use Windows installer, as well as setting up the site myself. Last week I managed to create a site, and install a starter kit. But now I can not make it work. No idea why. I do the exact same steps as last week. I have .NET 4.0, IIS 7 and Windows 7. The Umbraco version is the latest (4.7).
No matter if I use Windows installer, or the binary-package from Codeplex, the installation process works fine until the step when I am presented the choice of installing a starter kit. I press for example the Business Startkit, but then I get the error below. I have given full permission for my application folder in inetpub, to IIS_IUSRS, Network service and Network. I have done the same for C:/Temp folder (as suggested by someone). I am using an app-pool that runs on .NET 4.0 in Integrated mode. I also set it to use Network service. I have also tried to both start off with a blank database, as well as creating a new one. The database gets populated with tables. The folder in inetpub is also filled with all the folders and files that should be there. I have also tried using SQL CE, but with out luck. And I do have a working internet connection.
Does anybody have any ideas on how to solve this? It's getting really frustrating. I think I have tried all the suggestions in the other threads, but I might have misunderstood something, missed some steps, or forgotten some advice. Any suggestions are highly appreciated.
The error I get:
Server Error in '/site_development' Application.
The given key was not present in the dictionary.
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.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
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:
[KeyNotFoundException: The given key was not present in the dictionary.]
System.Collections.Generic.Dictionary`2.get_Item(TKey key) +2258321
umbraco.cms.businesslogic.datatype.controls.Factory.GetNewObject(Guid DataEditorId) +108
umbraco.cms.businesslogic.datatype.DataTypeDefinition.Import(XmlNode xmlData) +459
umbraco.cms.businesslogic.packager.Installer.InstallBusinessLogic(Int32 packageId, String tempDir) +187
umbraco.presentation.install.steps.Skinning.loadStarterKits.SelectStarterKit(Object sender, EventArgs e) +416
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +118
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +113
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +9
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
________________________________________
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.237
Are you able to install Umbraco firstly without the starter kit?
If so it maybe an issue with the starter kit itself.
Or get the latest nightly build from Umbraco here http://nightly.umbraco.org/

Error hosting Silverlight application page with WCF service

I am currently developing a Silverlight application with WCF service. The process flow of my project is as follows.
Silverlight page -> Service1.svc -> SQL Server 2008 and back
What my Silverligth page does is when a user clicks a button it calls a service reference (Service.svc). What the service is doing basically is to query a SQL database (SQL server 2008) and return the query back to the service and in turn the service returns the result back to the Silverlight page where it will be displayed.
When I am debugging and running the webpage from the visual Studio 2010 express all the things go according to plan i.e. when the user clicks the button the data that were acquired from the database are displayed.
But when I try to publish this and run it on Apache server or IIS I am getting an error when clicking the button. The web page is displayed correctly even from another internally connected PC, but the problem occurs when I press the button.
An error message is displayed as shown below:
An exception occurred during the operation, making the result invalid. Check InnerException for exception details.
at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at SilverlightApplication11.ServiceReference1.DoWorkCompletedEventArgs.get_Result()
at SilverlightApplication11.About.client_DoWorkCompleted(Object sender, DoWorkCompletedEventArgs e)
at SilverlightApplication11.ServiceReference1.Service1Client.OnDoWorkCompleted(Object state)
-------------------------------->
I have abosolutley no idea on how to solve this. I am very new to this whole stuff please help I been stuck in this about a week now.
Any snippets of code you guys would like please comment so I can post it here.
Thanks in advance =)
The service call you're making has an equivalent event to tap into. Your handler will be called when the operation completes or fails. The event args passed to your handler will contain information about your error. Keep digging into inner exception until something makes sense.
Also, your silverlight's App.xaml.cs has the ability to do something when an exception is thrown. There's an event called UnhandledException you can tap into. From there, you can output more information for yourself about the InnerException. Sometimes the first exception is not helpful, but there will be an InnerException in the Exception that will have more detail.

Resources