The type initializer for 'Nested' threw an exception

Feb 12, 2009 at 6:51 AM

With NHibernate and WCF, I am getting the following error:

The type initializer for 'Nested' threw an exception

Could not load type 'MyClass' from assembly 'MyNamespace.Entities, Version=, Culture=neutral, PublicKeyToken=null'

persistent class MyClass, 'MyNamespace.Entities not found


Could not compile the mapping document: MyProjName.Entities.GeneratedCode.Mappings.MyClass.hbm.xml

Any ideas?

Feb 12, 2009 at 11:18 AM
The build action of "MyProjName.Entities.GeneratedCode.Mappings.MyClass.hbm.xml" must be "Embedded Resource" not "Compile" to allow NHibernate to allocate your entity type.
Feb 13, 2009 at 12:36 PM

Just letting you know that I did have them as embedded resource, but I found the problem. 


I had renamed my assemblies, and the old ones were still in the bin folder of the service, so it got confused.
I have success. Many thanks