An Error like this

2 posts, 0 answers
  1. Liu Yuanbiao
    Liu Yuanbiao avatar
    1 posts
    Member since:
    Feb 2010

    Posted 15 Dec 2012 Link to this post

    No metadata has been registered for class 'CanFou.Core.Post, CanFou.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. (This usually indicates, that either this class is not declared persistent or it is declared persistent but not enhanced. The class was loaded from file:///d:/Users/Choby/Documents/Visual Studio 2012/Projects/CanFou/CanFou/bin/CanFou.Core.DLL.)
    说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

    异常详细信息: Telerik.OpenAccess.OpenAccessException: No metadata has been registered for class 'CanFou.Core.Post, CanFou.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. (This usually indicates, that either this class is not declared persistent or it is declared persistent but not enhanced. The class was loaded from file:///d:/Users/Choby/Documents/Visual Studio 2012/Projects/CanFou/CanFou/bin/CanFou.Core.DLL.)

    源错误:

    行 26: public new IQueryable<T> GetAll<T>() 行 27: { 行 28: return base.GetAll<T>(); 行 29: } 行 30: public new void SaveChanges()
  2. Hristo Marinov
    Admin
    Hristo Marinov avatar
    13 posts

    Posted 19 Dec 2012 Link to this post

    Hello Liu Yuanbiao,

    The exception "No metadata registered for class [AssemblyName.ClassName]" usually occurs when the process of assembly enhancement included in the project build by OpenAccess ORM could not be completed successfully or was not executed at all.

    In this process, Telerik OpenAccess ORM uses Enhancer, which is a special enhancer program, to read and process compiled .NET assemblies for adding persistence capability. The Enhancer can be called from the command line, but normally the enhancer is called directly by Visual Studio during build time to process the .NET assemblies in your project. The Enhancer injects the lazy loading and change tracking code into your persistent classes and replaces the read and write calls to persistent fields. Enhancement must be executed on all assemblies containing persistent classes or code that touches public fields of persistent objects.

    When using one of the Telerik OpenAccess wizards to configure a project, the enhancement is added to the MsBuild project file and no changes are necessary. But there are scenarios in which the OpenAccess Enhancer needs to be integrated manually. This can be done by editing the .csproj  (.vbproj) file of the project containing the OpenAccess Context.

    Please review your project file and search for this line:
    <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    or for VB:
    <Import Project="$(MSBuildToolsPath)\Microsoft. VisualBasic.targets" />

    After it, this line must be contained:
    <Import Condition="Exists('$(MSBuildExtensionsPath)\OpenAccess.targets')" Project="$(MSBuildExtensionsPath)\OpenAccess.targets" />

    If it is not, please add it. For more detailed information please refer to our articles about “Handling Error: No metadata registered for class [AssemblyName.ClassName]” and “How to: Use OpenAccess ORM Without Installing It”.

    If the provided solution does not help you, please send us more detailed information about what kind of scenario you are using for mapping to the database and if it is possible send us a code snippet or a little sample, isolating the issue. That way you can help us to reproduce the issue and further investigate it.

    I am looking forward to hearing from you.


    All the best,
    Hristo Marinov
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
  3. DevCraft banner
Back to Top