This is a migrated thread and some comments may be shown as answers.

An Error like this

1 Answer 88 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Liu Yuanbiao
Top achievements
Rank 1
Liu Yuanbiao asked on 15 Dec 2012, 04:20 PM
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()

1 Answer, 1 is accepted

Sort by
0
Hristo Marinov
Telerik team
answered on 19 Dec 2012, 02:31 PM
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.
Tags
General Discussions
Asked by
Liu Yuanbiao
Top achievements
Rank 1
Answers by
Hristo Marinov
Telerik team
Share this question
or