Error:You must write an attribute 'type'='object' after writing the attribute with local name '__type'
2012-05-16 14:13
513 查看
昨天在使用WebApi的时候,遇到这个错误。
Exception Details: System.Xml.XmlException: You must write an attribute 'type'='object' after writing the attribute with local name '__type'. 代码如下:
解决方法:
有两种,其中一种简单的是在实例化DbContext时指定 context.Configuration.ProxyCreationEnabled = false;
参考:
http://forums.asp.net/p/1773173/4848023.aspx/1?You+must+write+an+attribute+type+object+after+writing+the+attribute+with+local+name+__type+
http://msdn.microsoft.com/zh-cn/library/bb738612
You must write an attribute 'type'='object' after writing the attribute with local name '__type'.
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.Xml.XmlException: You must write an attribute 'type'='object' after writing the attribute with local name '__type'.
public HttpResponseMessage<List<ArticleSimple>> GetArticles(DateTime date) { //DONE returns top 10 articles ArticleService service = new ArticleService(); var articles = service.GetLatestArticleSimplesByDate(date, null); //DONE using viewModel that do not display Metadata and some useless properties return new HttpResponseMessage<List<ArticleSimple>>(articles, System.Net.HttpStatusCode.OK); }
解决方法:
有两种,其中一种简单的是在实例化DbContext时指定 context.Configuration.ProxyCreationEnabled = false;
参考:
http://forums.asp.net/p/1773173/4848023.aspx/1?You+must+write+an+attribute+type+object+after+writing+the+attribute+with+local+name+__type+
http://msdn.microsoft.com/zh-cn/library/bb738612
相关文章推荐
- Attribute name "aphmodel" associated with an element type "mxg" must be followed by the ' = ' charac
- Compiler Error Message: CS0234: The type or namespace name 'BorderDetails' does not exist in the class or namespace 'Infragistics.WebUI.Shared' (are you missing an assembly reference?)
- AFNetworking 2.0 ERROR:Property with 'retain (or strong)' attribute must be of object type [duplicat
- The value of attribute "title" associated with an element type "question" must not contain the '<' c
- [Error]No enclosing instance of type XX is accessible. Must qualify the allocation with an e
- [Java]Error:No enclosing instance of type E is accessible. Must qualify the allocation with an enclo
- Compiler Error Message: CS0234: The type or namespace name ''(are you missing an assembly reference?)
- No enclosing instance of type * is accessible. Must qualify the allocation with an enclosing instanc
- Java编译错误“No enclosing instance of type AA is accessible. Must qualify the allocation with an enclosing instance of type
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly refere
- Description Resource Path Location Type The value of attribute "schema" associated with an element t
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- No enclosing instance of type B is accessible. Must qualify the allocation with an enclosing ins (20
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instanc
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- 配置c3p0-config.xml报错:Open quote is expected for attribute "name" associated with an element type "pro