ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rusty Wright <rusty.wri...@gmail.com>
Subject Re: internal constructor problem
Date Tue, 24 Jul 2007 03:31:18 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Sorry, my computer at work died so I can't look at my code to see how I
did it, but I remember following his instructions closely; i.e., where
he says<br>
<br>
<pre>[assembly: InternalsVisibleTo("My.Test.Assembly")]

</pre>
I replaced My.Test.Assembly with the name of my namespace of my test
assembly. I'm thinking that what may be tricky for you is figuring out
which namespace to use in the InternalVisibleTo.<br>
<br>
<br>
Samnang Chhun wrote:
<blockquote cite="mid46a4577c.1aba720a.1e0d.ffffcd56@mx.google.com"
 type="cite">
  <meta http-equiv="Content-Type" content="text/html; ">
  <meta name="Generator" content="Microsoft Word 12 (filtered medium)">
  <style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Courier;
	panose-1:2 7 4 9 2 2 5 2 4 4;}
@font-face
	{font-family:"Cordia New";
	panose-1:2 11 3 4 2 2 2 2 2 4;}
@font-face
	{font-family:"Cordia New";
	panose-1:2 11 3 4 2 2 2 2 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:Verdana;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman","serif";
	color:black;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
pre
	{mso-style-priority:99;
	mso-style-link:"HTML Preformatted Char";
	margin:0in;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:"Courier New";
	color:black;}
span.HTMLPreformattedChar
	{mso-style-name:"HTML Preformatted Char";
	mso-style-priority:99;
	mso-style-link:"HTML Preformatted";
	font-family:Consolas;
	color:black;}
span.EmailStyle19
	{mso-style-type:personal;
	font-family:"Calibri","sans-serif";
	color:#1F497D;}
span.EmailStyle20
	{mso-style-type:personal;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
span.EmailStyle21
	{mso-style-type:personal-reply;
	font-family:"Calibri","sans-serif";
	color:#1F497D;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-size:10.0pt;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
	{page:Section1;}
-->
  </style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
  <div class="Section1">
  <p class="MsoNormal"><span
 style="font-size: 11pt; font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;
color: rgb(31, 73, 125);">If
I change my constructor to public, it&#8217;s test ok, but I
don&#8217;t want to this constructor to public because the client side can
access
it.<o:p></o:p></span></p>
  <p class="MsoNormal"><span
 style="font-size: 11pt; font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;
color: rgb(31, 73, 125);"><o:p>&nbsp;</o:p></span></p>
  <div>
  <div
 style="border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color
-moz-use-text-color; border-width: 1pt medium medium; padding: 3pt 0in 0in;">
  <p class="MsoNormal"><b><span
 style="font-size: 10pt; font-family: &quot;Tahoma&quot;,&quot;sans-serif&quot;;
color: windowtext;">From:</span></b><span
 style="font-size: 10pt; font-family: &quot;Tahoma&quot;,&quot;sans-serif&quot;;
color: windowtext;">
Rusty Wright
[<a class="moz-txt-link-freetext" href="mailto:rusty.wright@gmail.com">mailto:rusty.wright@gmail.com</a>]
<br>
  <b>Sent:</b> Monday, July 23, 2007 1:44 PM<br>
  <b>To:</b> Samnang Chhun<br>
  <b>Cc:</b> <a class="moz-txt-link-abbreviated" href="mailto:user-cs@ibatis.apache.org">user-cs@ibatis.apache.org</a>;
<a class="moz-txt-link-abbreviated" href="mailto:rusty@berkeley.edu">rusty@berkeley.edu</a><br>
  <b>Subject:</b> Re: internal constructor problem<o:p></o:p></span></p>
  </div>
  </div>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  <p class="MsoNormal">What happens if you change the constructor to
public?<br>
  <br>
The error I received with my problem said something about not being
able to
access an<br>
internal class, and I received the error during compilation.<br>
  <br>
Samnang Chhun wrote: <o:p></o:p></p>
  <p class="MsoNormal">Hi Rusty,<o:p></o:p></p>
  <p class="MsoNormal">&nbsp;<o:p></o:p></p>
  <p class="MsoNormal">I couldn&#8217;t get clearly understand on Tony&#8217;s
advice, could you explain me more detail about this. I have 3 projects
separately Yolk.DTO, Yolk.Data.iBatis, and UnitTest.<o:p></o:p></p>
  <p class="MsoNormal">I let Yolk.Data.iBatis can access to my internal
constructor
of my classes in Yolk.DTO, so I add [assembly:
InternalVisibleTo(&#8220;Yolk.Data.iBatis, Public Key=&#8230;&#8221;) to
assemblyinfo.cs in my Yolk.DTO.<o:p></o:p></p>
  <p class="MsoNormal">How can I access to internal constructor in
sqlMap of
iBatis.Net? But I can access to internal properties. What have I done
something
wrong?<o:p></o:p></p>
  <p class="MsoNormal">When I execute my testing I got an error:<o:p></o:p></p>
  <p class="MsoNormal">&nbsp;<o:p></o:p></p>
  <pre><span
 style="font-size: 8pt; font-family: Courier; color: darkred;">IBatisNet.Common.Exceptions.ConfigurationException:
</span><o:p></o:p></pre>
  <pre><span
 style="font-size: 8pt; font-family: Courier; color: darkred;">- The error occurred while
loading SqlMap.</span><o:p></o:p></pre>
  <pre><span
 style="font-size: 8pt; font-family: Courier; color: darkred;">- Argument property (id)
set the typeHandler attribute.</span><o:p></o:p></pre>
  <pre><span
 style="font-size: 8pt; font-family: Courier; color: darkred;">- The error occurred in
&lt;sqlMap embedded="Maps.Agreement.xml, Yolk.Data.iBatis" xmlns=<a
 href="http://ibatis.apache.org/dataMapper">"http://ibatis.apache.org/dataMapper"</a>
/&gt;.&nbsp; </span><o:p></o:p></pre>
  <pre><span
 style="font-size: 8pt; font-family: Courier; color: darkred;">- Check the Agreement.agreementResult.</span><o:p></o:p></pre>
  <p class="MsoNormal"><span
 style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;"><br>
at
IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Build(XmlDocument
document, DataSource dataSource, Boolean useConfigFileWatcher, Boolean
isCallFromDao) <br>
at
IBatisNet.DataMapper.Configuration.DomSqlMapBuilder.Configure(XmlDocument
document) <br>
at Yolk.Data.iBatis.DirectoryMapper.InitMapper() in <a
 href="cref://210B6FE1-9FD6-4DB5-97E1-DF93C954004C/d:Core/f:DirectoryMapper.cs*34*1">DirectoryMapper.cs:line
34 </a><br>
at Yolk.Data.iBatis.DirectoryMapper.Instance() in <a
 href="cref://210B6FE1-9FD6-4DB5-97E1-DF93C954004C/d:Core/f:DirectoryMapper.cs*50*1">DirectoryMapper.cs:line
50 </a><br>
at Yolk.Data.iBatis.AgreementRepository.GetNextAgreementId() in <a
 href="cref://210B6FE1-9FD6-4DB5-97E1-DF93C954004C/f:AgreementRepository.cs*19*1">AgreementRepository.cs:line
19 </a><br>
at UnitTests.AgreementRepositoryTest.GetNextAgreementId() in <a
 href="cref://32617940-B547-4303-9746-A97F8F86F69E/f:AgreementRepositoryTest.cs*17*1">AgreementRepositoryTest.cs:line
17</a> </span><o:p></o:p></p>
  <p class="MsoNormal"><span
 style="font-size: 8pt; font-family: Courier; color: darkred;">IBatisNet.Common.Exceptions.ConfigurationException:
Could not configure ResultMap named "Agreement.agreementResult",
Cause: Unable to optimize create instance. Cause : Could not find
public
constructor matching specified arguments for type "Agreement".</span><o:p></o:p></p>
  <p class="MsoNormal">&nbsp;<o:p></o:p></p>
  <p class="MsoNormal">Cheers,<o:p></o:p></p>
  <p class="MsoNormal">Samnang<o:p></o:p></p>
  <p class="MsoNormal"><span
 style="font-size: 11pt; font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;
color: rgb(31, 73, 125);">&nbsp;</span><o:p></o:p></p>
  <p class="MsoNormal"><span
 style="font-size: 11pt; font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;
color: rgb(31, 73, 125);">&nbsp;</span><o:p></o:p></p>
  <div>
  <div
 style="border-style: solid none none; border-color: -moz-use-text-color; border-width: 1pt
medium medium; padding: 3pt 0in 0in;">
  <p class="MsoNormal"><b><span
 style="font-size: 10pt; font-family: &quot;Tahoma&quot;,&quot;sans-serif&quot;;
color: windowtext;">From:</span></b><span
 style="font-size: 10pt; font-family: &quot;Tahoma&quot;,&quot;sans-serif&quot;;
color: windowtext;">
Rusty Wright [<a href="mailto:rusty.wright@gmail.com">mailto:rusty.wright@gmail.com</a>]
  <br>
  <b>Sent:</b> Saturday, July 21, 2007 1:54 AM<br>
  <b>To:</b> <a href="mailto:user-cs@ibatis.apache.org">user-cs@ibatis.apache.org</a><br>
  <b>Subject:</b> Re: internal constructor problem</span><o:p></o:p></p>
  </div>
  </div>
  <p class="MsoNormal">&nbsp;<o:p></o:p></p>
  <p class="MsoNormal"><span
 style="font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">I had
a
similar problem with unit tests; see the reply from Tony Bjerstedt
below.<br>
  <br>
  </span><br>
-------- Original Message -------- <o:p></o:p></p>
  <table class="MsoNormalTable" border="0" cellpadding="0"
 cellspacing="0">
    <tbody>
      <tr>
        <td style="padding: 0in;" nowrap="nowrap" valign="top">
        <p class="MsoNormal" style="text-align: right;" align="right"><b>Subject:
        </b><o:p></o:p></p>
        </td>
        <td style="padding: 0in;">
        <p class="MsoNormal">Re: [Nunit-users] name spaces?<o:p></o:p></p>
        </td>
      </tr>
      <tr>
        <td style="padding: 0in;" nowrap="nowrap" valign="top">
        <p class="MsoNormal" style="text-align: right;" align="right"><b>Date:
        </b><o:p></o:p></p>
        </td>
        <td style="padding: 0in;">
        <p class="MsoNormal">Tue, 17 Jul 2007 18:41:24 -0700<o:p></o:p></p>
        </td>
      </tr>
      <tr>
        <td style="padding: 0in;" nowrap="nowrap" valign="top">
        <p class="MsoNormal" style="text-align: right;" align="right"><b>From:
        </b><o:p></o:p></p>
        </td>
        <td style="padding: 0in;">
        <p class="MsoNormal">Charlie Poole <a
 href="mailto:charlie@pooleconsulting.com">&lt;charlie@pooleconsulting.com&gt;</a><o:p></o:p></p>
        </td>
      </tr>
      <tr>
        <td style="padding: 0in;" nowrap="nowrap" valign="top">
        <p class="MsoNormal" style="text-align: right;" align="right"><b>To:
        </b><o:p></o:p></p>
        </td>
        <td style="padding: 0in;">
        <p class="MsoNormal"><a
 href="mailto:nunit-users@lists.sourceforge.net">&lt;nunit-users@lists.sourceforge.net&gt;</a><o:p></o:p></p>
        </td>
      </tr>
    </tbody>
  </table>
  <p class="MsoNormal" style="margin-bottom: 12pt;">&nbsp;<o:p></o:p></p>
  <pre>Hi Rusty, <o:p></o:p></pre>
  <pre>&nbsp;<o:p></o:p></pre>
  <pre>Tony's advice is good, assuming you are using Visual Studio 2005.<o:p></o:p></pre>
  <pre>&nbsp;<o:p></o:p></pre>
  <pre>Note that it's only the use of a separate assembly, not a different<o:p></o:p></pre>
  <pre>namespace that is causing the problem. You can have different namespaces<o:p></o:p></pre>
  <pre>in a single assembly or one namespace across multiple assemblies.<o:p></o:p></pre>
  <pre>&nbsp;<o:p></o:p></pre>
  <pre>You handle assembly visibility with references. Namespace visibility<o:p></o:p></pre>
  <pre>with using (VB=imports) statements.<o:p></o:p></pre>
  <pre>&nbsp;<o:p></o:p></pre>
  <pre>Charlie<o:p></o:p></pre>
  <pre>&nbsp;<o:p></o:p></pre>
  <pre>&gt; -----Original Message-----<o:p></o:p></pre>
  <pre>&gt; From: <a
 href="mailto:nunit-users-bounces@lists.sourceforge.net">nunit-users-bounces@lists.sourceforge.net</a>
<o:p></o:p></pre>
  <pre>&gt; [<a href="mailto:nunit-users-bounces@lists.sourceforge.net">mailto:nunit-users-bounces@lists.sourceforge.net</a>]
On Behalf <o:p></o:p></pre>
  <pre>&gt; Of Rusty Wright<o:p></o:p></pre>
  <pre>&gt; Sent: Tuesday, July 17, 2007 11:20 AM<o:p></o:p></pre>
  <pre>&gt; To: <a href="mailto:Tony.Bjerstedt@audatex.com">Tony.Bjerstedt@audatex.com</a><o:p></o:p></pre>
  <pre>&gt; Cc: <a href="mailto:nunit-users@lists.sourceforge.net">nunit-users@lists.sourceforge.net</a><o:p></o:p></pre>
  <pre>&gt; Subject: Re: [Nunit-users] name spaces?<o:p></o:p></pre>
  <pre>&gt; <o:p></o:p></pre>
  <pre>&gt; Great, sounds like just what I need.&nbsp; Thanks.<o:p></o:p></pre>
  <pre>&gt; <o:p></o:p></pre>
  <pre>&gt; <a href="mailto:Tony.Bjerstedt@audatex.com">Tony.Bjerstedt@audatex.com</a>
wrote:<o:p></o:p></pre>
  <pre>&gt; &gt; If your tests are in a different assembly, they no longer <o:p></o:p></pre>
  <pre>&gt; can see any <o:p></o:p></pre>
  <pre>&gt; &gt; of the classes that they test. Internal scope only allows other
<o:p></o:p></pre>
  <pre>&gt; &gt; classes in the same assembly to have access to the internal
scoped <o:p></o:p></pre>
  <pre>&gt; &gt; classes and members. You can extend internal visibility to
other <o:p></o:p></pre>
  <pre>&gt; &gt; assemblies using the "InternalsVisibleTo" attribute.<o:p></o:p></pre>
  <pre>&gt; &gt;<o:p></o:p></pre>
  <pre>&gt; &gt; Add a statement like:<o:p></o:p></pre>
  <pre>&gt; &gt; &nbsp;&nbsp;&nbsp; [assembly: InternalsVisibleTo("My.Test.Assembly")]<o:p></o:p></pre>
  <pre>&gt; &gt; To you "assemblyinfo.cs" file.<o:p></o:p></pre>
  <pre>&gt; &gt;<o:p></o:p></pre>
  <pre>&gt; &gt;<o:p></o:p></pre>
  <pre>&gt; &gt; -----Original Message-----<o:p></o:p></pre>
  <pre>&gt; &gt; From: <a
 href="mailto:nunit-users-bounces@lists.sourceforge.net">nunit-users-bounces@lists.sourceforge.net</a><o:p></o:p></pre>
  <pre>&gt; &gt; [<a
 href="mailto:nunit-users-bounces@lists.sourceforge.net">mailto:nunit-users-bounces@lists.sourceforge.net</a>]
On <o:p></o:p></pre>
  <pre>&gt; Behalf Of Rusty <o:p></o:p></pre>
  <pre>&gt; &gt; Wright<o:p></o:p></pre>
  <pre>&gt; &gt; Sent: Tuesday, July 17, 2007 12:29 PM<o:p></o:p></pre>
  <pre>&gt; &gt; To: <a href="mailto:nunit-users@lists.sourceforge.net">nunit-users@lists.sourceforge.net</a><o:p></o:p></pre>
  <pre>&gt; &gt; Subject: [Nunit-users] name spaces?<o:p></o:p></pre>
  <pre>&gt; &gt;<o:p></o:p></pre>
  <pre>&gt; &gt; How do people manage their name spaces with NUnit?&nbsp;
I have <o:p></o:p></pre>
  <pre>&gt; a class in <o:p></o:p></pre>
  <pre>&gt; &gt; the namespace ShopsiteOrderApi that I'm testing and my unit
<o:p></o:p></pre>
  <pre>&gt; tests are <o:p></o:p></pre>
  <pre>&gt; &gt; in<o:p></o:p></pre>
  <pre>&gt; &gt;<o:p></o:p></pre>
  <pre>&gt; &gt; the namespace Tests.&nbsp; I tried changing the class in
the <o:p></o:p></pre>
  <pre>&gt; &gt; ShopsiteOrderApi<o:p></o:p></pre>
  <pre>&gt; &gt;<o:p></o:p></pre>
  <pre>&gt; &gt; from public to internal but now the test won't compile.<o:p></o:p></pre>
  <pre>&gt; &gt;<o:p></o:p></pre>
  <pre>&gt; &gt; <o:p></o:p></pre>
  <pre>&gt; ----------------------------------------------------------------------<o:p></o:p></pre>
  <pre>&gt; &gt; --<o:p></o:p></pre>
  <pre>&gt; &gt; -<o:p></o:p></pre>
  <pre>&gt; &gt; This SF.net email is sponsored by DB2 Express Download DB2
<o:p></o:p></pre>
  <pre>&gt; Express C - <o:p></o:p></pre>
  <pre>&gt; &gt; the FREE version of DB2 express and take control of your XML.
No <o:p></o:p></pre>
  <pre>&gt; &gt; limits. Just data. Click to get it now.<o:p></o:p></pre>
  <pre>&gt; &gt; <a href="http://sourceforge.net/powerbar/db2/">http://sourceforge.net/powerbar/db2/</a><o:p></o:p></pre>
  <pre>&gt; &gt; _______________________________________________<o:p></o:p></pre>
  <pre>&gt; &gt; Nunit-users mailing list<o:p></o:p></pre>
  <pre>&gt; &gt; <a href="mailto:Nunit-users@lists.sourceforge.net">Nunit-users@lists.sourceforge.net</a><o:p></o:p></pre>
  <pre>&gt; &gt; <a
 href="https://lists.sourceforge.net/lists/listinfo/nunit-users">https://lists.sourceforge.net/lists/listinfo/nunit-users</a><o:p></o:p></pre>
  <pre>&gt; &gt;&nbsp;&nbsp; <o:p></o:p></pre>
  <pre>&gt; <o:p></o:p></pre>
  <pre>&gt; --------------------------------------------------------------<o:p></o:p></pre>
  <pre>&gt; -----------<o:p></o:p></pre>
  <pre>&gt; This SF.net email is sponsored by DB2 Express Download DB2 <o:p></o:p></pre>
  <pre>&gt; Express C - the FREE version of DB2 express and take control <o:p></o:p></pre>
  <pre>&gt; of your XML. No limits. Just data. Click to get it now.<o:p></o:p></pre>
  <pre>&gt; <a href="http://sourceforge.net/powerbar/db2/">http://sourceforge.net/powerbar/db2/</a><o:p></o:p></pre>
  <pre>&gt; _______________________________________________<o:p></o:p></pre>
  <pre>&gt; Nunit-users mailing list<o:p></o:p></pre>
  <pre>&gt; <a href="mailto:Nunit-users@lists.sourceforge.net">Nunit-users@lists.sourceforge.net</a><o:p></o:p></pre>
  <pre>&gt; <a
 href="https://lists.sourceforge.net/lists/listinfo/nunit-users">https://lists.sourceforge.net/lists/listinfo/nunit-users</a><o:p></o:p></pre>
  <pre>&gt; <o:p></o:p></pre>
  <pre>&nbsp;<o:p></o:p></pre>
  <pre>&nbsp;<o:p></o:p></pre>
  <pre>&nbsp;<o:p></o:p></pre>
  <pre>-------------------------------------------------------------------------<o:p></o:p></pre>
  <pre>This SF.net email is sponsored by DB2 Express<o:p></o:p></pre>
  <pre>Download DB2 Express C - the FREE version of DB2 express and take<o:p></o:p></pre>
  <pre>control of your XML. No limits. Just data. Click to get it now.<o:p></o:p></pre>
  <pre><a href="http://sourceforge.net/powerbar/db2/">http://sourceforge.net/powerbar/db2/</a><o:p></o:p></pre>
  <pre>_______________________________________________<o:p></o:p></pre>
  <pre>Nunit-users mailing list<o:p></o:p></pre>
  <pre><a href="mailto:Nunit-users@lists.sourceforge.net">Nunit-users@lists.sourceforge.net</a><o:p></o:p></pre>
  <pre><a
 href="https://lists.sourceforge.net/lists/listinfo/nunit-users">https://lists.sourceforge.net/lists/listinfo/nunit-users</a><o:p></o:p></pre>
  <pre>&nbsp;<o:p></o:p></pre>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </div>
</blockquote>
<br>
</body>
</html>

Mime
View raw message