What if you receive the “Invalid type owner for DynamicMethod” error while initializing you NHibernate SessionFactory.
What if you receive the Invalid type owner for DynamicMethod error while initializing you
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you recieve the “Invalid type owner for DynamicMethod” error while initializing you NHibernate SessionFactory then it’s pretty likely that you are using generic methods on some of your lazy loaded/proxied classes.
Nhibernate incorporates a reflection optimization that speeds up the creation of proxy classes. This reflection optimization does not play well with generics. The error it throws is “Invalid type owner for DynamicMethod”. Not very friendly.
So, to fix this you must either stop using generic methods OR turn off the optimization. To turn off the optimization you must run the following code before you initialize your SessionFactory.