ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Don Dwoske" <...@loraxis.com>
Subject Re: System.InvalidProgramException: Common Language Runtime detected an invalid program on a QueryForObject
Date Mon, 25 Sep 2006 10:23:56 GMT
This is the bug I found last week (I believe).  Look back in the board
for my message about using public fields.

I included source code for the change which you would have to make in
your own local copy (I compiled the source on my own to debug and find
this) - I'm too busy to submit a bug report with a test case and patch
right now...maybe someone else with free time can look at my message
and do that to get this change incorporated into the code base.  I'm a
newbie with C# and also generated code, so I'm not confident what I
did is even makes sense - but it works - so that's all I care about.

To fix your code so that it works with the existing code base - use
properties with getters and setters and not public fields.

-Don


On 9/24/06, Louwris, Wessel <wessel.louwris@satama.com> wrote:
> Hi,
>
> I'm trying to to get ibatis for .Net 1.1 to work with a QueryForObject.
> A QueryForObject which returns a int (select(count)) works
> An Insert works, but the QueryForObject which should return the object
> gives the following error message:
>
>
> Exception Details: System.InvalidProgramException: Common Language
> Runtime detected an invalid program.
>
> Source Error:
>
> An unhandled exception was generated during the execution of the current
> web request. Information regarding the origin and location of the
> exception can be identified using the exception stack trace below.
>
> Stack Trace:
>
>
> [InvalidProgramException: Common Language Runtime detected an invalid
> program.]
>    SetForxsell.XsellRespondent2campaign.Set(Object , Object ) +0
>
> IBatisNet.Common.Utilities.Objects.Members.EmitFieldSetAccessor.Set(Obje
> ct target, Object value) +28
>
> IBatisNet.DataMapper.DataExchange.DotNetObjectDataExchange.SetData(Objec
> t& target, ResultProperty mapping, Object dataBaseValue) +111
>
> IBatisNet.DataMapper.MappedStatements.PropertyStrategy.DefaultStrategy.S
> et(RequestScope request, ResultMap resultMap, ResultProperty mapping,
> Object& target, IDataReader reader, Object keys) +332
>
> IBatisNet.DataMapper.MappedStatements.ResultStrategy.ResultMapStrategy.P
> rocess(RequestScope request, IDataReader& reader, Object resultObject)
> +306
>
> IBatisNet.DataMapper.MappedStatements.MappedStatement.RunQueryForObject(
> RequestScope request, IDalSession session, Object parameterObject,
> Object resultObject) +136
>
> IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForObj
> ect(IDalSession session, Object parameterObject, Object resultObject)
> +88
>
> IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForObj
> ect(IDalSession session, Object parameterObject) +10
>    IBatisNet.DataMapper.SqlMapper.QueryForObject(String statementName,
> Object parameterObject) +146
>    xsell.wwwroot.form.Page_Load(Object sender, EventArgs e) in
> c:\projects\vod\xsell\wwwroot\form.aspx.cs:133
>    System.Web.UI.Control.OnLoad(EventArgs e) +67
>    System.Web.UI.Control.LoadRecursive() +35
>    System.Web.UI.Page.ProcessRequestMain() +750
>
>
>
>
> My XsellRespondent2 class is like:
> public class XsellRespondent2
>         {
>                 public string cust_id;
>                 public string campaign;
>                 public XsellRespondent2() {}
>         }
>
> with the table:
> create table xsell_respondents2 (
> campaign varchar(100),
> cust_id varchar(100)
> )
>
>
> And the statement is:
>         <resultMaps>
>                 <resultMap id="rSelectRespondent"
> class="xsell.XsellRespondent2" >
>                         <result property="campaign" column="campaign" />
>                         <result property="cust_id" column="cust_id" />
>                 </resultMap>
>         </resultMaps>
>
>   <statements>
>
>     <select id="GetByCustId" resultMap="rSelectRespondent"
> parameterClass="string" >
>                 select campaign,cust_id from xsell_respondents where
> cust_id=#cust_id#
>         </select>
>
>   </statements>
>
>
>
> I have no clue how te debug this thing. I guess some sort of generated
> piece of code gives problems.But I hope somebody can help me out here.
>
> btw: the NPetshop.Web seems to work so apparently it can be done, and I
> am doing something wrong. But I dunno what.
> btw2: this is running on XP but a Server 2003 machine gives the same
> results (mssql 2000).
> Thanks a lot for any help.
>
> Wessel
>


-- 

---------------------------------------
Donald Dwoske
Software Journeyman
http://www.loraxis.com/ddwoske

Mime
View raw message