-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: migration from 1.0.3 -> 1.2.0: BadImageFormatException
PostPosted: Mon Oct 15, 2007 1:39 pm 
Beginner
Beginner

Joined: Thu Nov 02, 2006 5:11 pm
Posts: 32
Location: Toronto
I'm trying to migrate from 1.0.3 to 1.2.0. It seems that any attempt to instantiate a proxy now fails with the exception shown below. None of my code has changed, and it worked fine with 1.0.3.

Any ideas what has changed between 1.0.3 and 1.2.0 that would cause dynamicproxy to suddenly stop working?

Mapping documents:

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="ClearCanvas.Enterprise.Authentication" namespace="ClearCanvas.Enterprise.Authentication">
  <class name="User" table="User_">
    <id name="OID" column="OID_" type="Guid">
      <generator class="guid.comb"/>
    </id>
    <version name="Version" column="Version_"/>
    <property name="UserName" column="UserName_" type="String" length="30" not-null="true" unique="true"/>
    <set name="AuthorityGroups" table="AuthorityGroupUser_" lazy="true" cascade="all" access="nosetter.camelcase-underscore">
      <key column="UserOID_"/>
      <many-to-many column="AuthorityGroupOID_" class="AuthorityGroup" fetch="join"/>
    </set>
  </class>
</hibernate-mapping>


Full stack trace of any exception that occurs:

Code:
2007-10-15 13:30:34,406 [16] ERROR - Creating a proxy instance failed
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
   at CProxyTypeClearCanvas_Enterprise_AuthenticationUserAuthentication_NHibernate_ProxyINHibernateProxy1..ctor(IInterceptor )
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)
   at System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, Object[] args)
   at Castle.DynamicProxy.ProxyGenerator.CreateClassProxyInstance(Type type, IInterceptor interceptor, Object[] argumentsForConstructor)
   at Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type baseClass, Type[] interfaces, IInterceptor interceptor, Boolean checkAbstract, Object[] argumentsForConstructor)
   at NHibernate.Proxy.CastleProxyFactory.GetProxy(Object id, ISessionImplementor session)

[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 16, 2007 11:27 am 
Beginner
Beginner

Joined: Thu Nov 02, 2006 5:11 pm
Posts: 32
Location: Toronto
Nevermind, I realized that my own code is causing the problem. The new validation that NH 1.2 does on proxied classes, to make sure all public members are virtual, caused me to make some previously non-virtual generic methods virtual, which broke dynamic proxy.

This leads to an interesting point though: if NH is going to do validation to make sure all public methods are virtual, it should probably also validate that none of these methods has any generic parameters.

Any thoughts? Perhaps I'll add a feature request.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.