IBatis.Net学习笔记二--下载、编译、运行NPetShop

时间:2022-12-25 18:36:38
下载地址: http://ibatis.apache.org/dotnetdownloads.cgi
有最新版的IBastis.Net的源代码等,还有NPetShop的例子(例子比较老)

将NPetShop的例子下载好之后,由于原来是基于VS2003的版本,在本地用VS2005打开后编译、运行时有一些问题,主要问题和解决方法如下:
1、转换成VS2005的版本
   a、直接打开NPetshop.sln文件,按提示一直点击"下一步"进行转换
   b、转换后不能找到web项目,把原来的web项目删除,然后通过添加现有网站的方式加入NPetshop.Web

2、修改配置文件
   最简单的方式是直接修改NPetshop.Web目录下的dao.config,如下一条语句:
IBatis.Net学习笔记二--下载、编译、运行NPetShop< dataSource name = " Access "  connectionString = " Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Study\_Net\框架\iBATIS.NET\NPetshop\NPetshop.Web\npetshop.mdb " />
IBatis.Net学习笔记二--下载、编译、运行NPetShop
   将其中的路径改成你自己的路径。
   PS:npetshop.mdb是一个access文件,在NPetshop.Web目录下

3、编译时报错:不允许循环文件引用
   由于VS2005和VS2003有一定的区别导致,找到文件:NPetshop.Web\UserControls\Catalog\SearchProduct.ascx
将如下代码:
IBatis.Net学习笔记二--下载、编译、运行NPetShop<% @ Register TagPrefix = " uc1 "  TagName = " TopBar "  Src = " ../TopBar.ascx "   %>
IBatis.Net学习笔记二--下载、编译、运行NPetShop
<% @ Register TagPrefix = " uc1 "  TagName = " Banner "  Src = " ../Banner.ascx "   %>
IBatis.Net学习笔记二--下载、编译、运行NPetShop
<% @ Register TagPrefix = " cc1 "  Namespace = " NPetshop.Presentation.Controls "  Assembly = " NPetshop.Presentation "   %>
IBatis.Net学习笔记二--下载、编译、运行NPetShop
< uc1:Banner id = " Banner "  runat = " server " ></ uc1:Banner >
IBatis.Net学习笔记二--下载、编译、运行NPetShop
< uc1:TopBar id = " TopBar "  runat = " server " ></ uc1:TopBar >
IBatis.Net学习笔记二--下载、编译、运行NPetShop
   修改成:
IBatis.Net学习笔记二--下载、编译、运行NPetShop<% @ Register TagPrefix = " uc1 "  TagName = " TopBar "  Src = " ../TopBar.ascx "   %>
IBatis.Net学习笔记二--下载、编译、运行NPetShop
<% @ Register TagPrefix = " uc2 "  TagName = " Banner "  Src = " ../Banner.ascx "   %>
IBatis.Net学习笔记二--下载、编译、运行NPetShop
<% @ Register TagPrefix = " cc1 "  Namespace = " NPetshop.Presentation.Controls "  Assembly = " NPetshop.Presentation "   %>
IBatis.Net学习笔记二--下载、编译、运行NPetShop
< uc2:Banner id = " Banner "  runat = " server " ></ uc2:Banner >
IBatis.Net学习笔记二--下载、编译、运行NPetShop
< uc1:TopBar id = " TopBar "  runat = " server " ></ uc1:TopBar >
主要就是不能出现相同的uc1

4、运行时报错
   按如上操作后,应该就可以进入首页了,但是运行时可能报系统错误,通过单步调试,发现需要手工给
NPetShop.Web项目添加引用,引用位置:NPetshop\External-bin\ByteFX.MySqlClient.dll

这样,NPetShop的例子应该就可以正常运行了