Skip to content

Invalid program generated by FieldInterceptorProxyBuilder for indexer property getter #3354

Closed
@denisglu

Description

@denisglu

The base class for my POCOs contains an indexer property like
public virtual string this[string colName] { get; }

(which is obviously compiled to string get_Item(string) getter method)

If the class mapping includes properties with lazy="true" (for example CLOB props), then NHibernate generates a dynamic proxy class like MyClassProxyForFieldInterceptor where all getters and setters are overridden. All works good until a call to get_Item() occurs - .Net Framework then throws:

System.InvalidProgramException
  HResult=0x8013153A
  Message=Common Language Runtime detected an invalid program.
  Source=MyClassProxyForFieldInterceptorAssembly
  StackTrace:
   at MyClassProxyForFieldInterceptor.get_Item(String )

Obviously FieldInterceptorProxyBuilder generates a faulty code for indexers' getters and, probably, setters.
I think the fix could be not to override the getters/setters for any indexer property at all since it should not be mapped to data source. Or fix the code generation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions