An error occurred while learning an embedded resource due to the attributes of an xml file.

Source: Internet
Author: User
The version number in the hbm. xmlnhib.pdf file may cause problems.
<Hibernate-mapping xmlns = "urn: nhibernate-mapping-2.2">
In this example, 2.2 indicates that the version number of the nhibernate must be consistent with the version number of the nhibernate product you have installed. otherwise, for example urn: nhibernate-mapping-2.0, the following error occurs: cocould not find schema information for the element 'urn: nhibernate-mapping-2.0: hibernate-ing '. or: "nhib.pdf. cfg. an exception is thrown when the type of environment is set to an item ".
In the control class, if the attribute does not contain the virtual keyword, it may be reported
Nhibwing. invalidproxytypeexception: the following types may not be used as proxies:
Model. friendlink: method set_description shoshould be virtual
Model. type: method get_typename shocould be virtual .....
This is a solution by adding the virtual keyword to the property. Another solution is to add default-lazy = "false" to the ing file ".

The ing file does not set the attribute to "embedded resource.
This is what I ignore most often. If I ignore it, many errors may be reported, one of which is in the following format:

Nhibted. queryexception: in expected: <end-of-text> (possibly an invalid or unmapped class name was used in the query) [from post order by issetup desc datetime desc hot desc]

"Cocould not find the dialect in the configuration" Exception
Exception description:
Nhibect. mappingexception: cocould not compile the mapping document: model. friendlink. hbm. xml ---> system. invalidoperationexception: cocould not find the dialect in the configuration
In nhibect. dialect. dialect. getdialect (idictionary '2 props)
In nhib.pdf. cfg. configuration. addvalidateddocument (namedxmldocument doc)
Solution:
In the configuration file xmlns = "urn: nhibernate-configuration-2.2" Never forget to make sure you don't forget xmlns = "urn: nhibernate-configuration-2.2" to fix this bug.

<Hibernate-configuration xmlns = "urn: nhibernate-configuration-2.2"> <session-factory> <property name = "connection. provider "> nhib.pdf. connection. driverconnectionprovider </property> <property name = "use_outer_join"> true </property> <property name = "connection. driver_class "> nhib.pdf. driver. sqlclientdriver </property> <property name = "show_ SQL"> true </property> <property name = "dialect"> nhib.pdf. dialect. mssql2005dialect </property> <property name = "connection. connection_string "> server =. \ sqlexpress initial catalog = sblog user id = sa password = 1 </property> <mapping assembly = "xmgl. model "/> </session-factory> "Failed to Load file or assembly castle. dynamicproxy2" Exception
Exception description:
System. typeinitializationexception: An exception occurs when you set the type of "nhib.pdf. proxy. poco. castle. castleproxyfactory. ---> System. io. filenotfoundexception: fails to load the file or the Assembly "castle. dynamicproxy2 version = 2.0.3.0 culture = neutral publickeytoken = 407dd0808d44fbdc" or one of its dependencies. The system cannot find the specified file.
File Name: "castle. dynamicproxy2 version = 2.0.3.0 culture = neutral publickeytoken = 407dd0808d44fbdc"
In nhib.pdf. proxy. poco. castle. castleproxyfactory.. cctor ()

Solution:

The method for this exception is relatively simple to add reference in the Assembly.

Timestamp usage.
I feel that nhib.pdf does not support timestamp well. I defined a timestamp type column in SQL server 2005 and mapped it to the datetime type in the ing file. Then I reported:
Nhib.pdf. adoexception: cocould not cast the value in field upsize2_0 _ of type byte [] to the type timestamptype. please check to make sure that the mapping is correct and that your dataprovider supports this data type. ---> system. invalidcastexception: The type cannot be set to "system. the byte [] object is forcibly converted to the type "system. iconvertible ".
In system. convert. todatetime (object value)
In nhibader. type. timestamptype. get (idatareader rs int32 index)
In nhibernate. type. nullabletype. nullsafeget (idatareader rs string name)
After half a day, I didn't configure it. I could only change the database column to the datetime type, and then configure the ing file in the following format:

<Id name = "contentid" type = "string" unsaved-value = "null">
<Column name = "contentid" length = "36" SQL-type = "nvarchar" not-null = "true" unique = "true" index = "aaaaacontent_pk"/>
<Generator class = "assigned"/>
</Id>
<Timestamp name = "upsizets" column = "upsize_ts"/>
Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)
One cause of this error is that the database is locked. nhibber uses Optimistic Locking by default. For information about Optimistic Locking in nhibber and how to solve the error, see there.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.