代码改变世界

XCopy 部署 DotNetNuke

2008-07-11 23:58  晓风残月  阅读(1394)  评论(2编辑  收藏  举报

装了个闻名遐迩的 DotNetNuke 玩玩,很佩服 DNN 的“自我安装”方式,通过 Web Install Wizard 5分钟之内就配置成功。

本地测试评估之后将网站程序直接上传至远程服务器(XCopy),并连接同一数据库备份,会出现如下错误:

 

Server Error in '/ddn' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
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:

[NullReferenceException: Object reference not set to an instance of an object.]
   DotNetNuke.Entities.Portals.PortalSettings.GetPortalSettings(Int32 TabId, PortalAliasInfo objPortalAliasInfo) +91
   DotNetNuke.Entities.Portals.PortalSettings..ctor(Int32 tabId, PortalAliasInfo objPortalAliasInfo) +83
   DotNetNuke.HttpModules.UrlRewriteModule.OnBeginRequest(Object s, EventArgs e) +3303
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

 

发现DNN官方论坛有两帖提到了该问题:
Can you migrate websites between servers?
XCopy server version redirects to local URL   
以及
Moving DotNetNuke Sites from Dev. To Prod

总结得出几点:

  1. 假如是同一个数据库(或者备份/还原副本),那么XCopy部署是很容易成功的
  2. 确保 web.config 中的 machineKey 配置节信息是一致的
  3. 在数据库中的 PortalAlias 表中修改 HttpAlias,比如我在本机安装的虚拟路径是 http://localhost/dnn,而我远程部署的路径是 http://www.abc.com:8081/dnn
    那么就将对应的 HttpAlias 字段值从 localhost/dnn 修改成 www.abc.com:8081/dnn。记得修改之后,需要重启应用程序(可简单重新保存web.config)。这就解决了上述PortalAliasInfo NullReferenceException 的问题。


另外,对于 DNN 这个 Exception 处理比较失望,没有给出友好性、可读性的 Message,没有去查源码,但可以想象得到
DotNetNuke.Entities.Portals.PortalSettings.GetPortalSettings(Int32 TabId, PortalAliasInfo objPortalAliasInfo)
这个方法内部没有对参数 objPortalAliasInfo 进行 null-checking,并且根据这个堆栈信息,null-checking 应该在
DotNetNuke.Entities.Portals.PortalSettings..ctor(Int32 tabId, PortalAliasInfo objPortalAliasInfo) +83
也就是PortalSettings构造函数内就执行。

因此,除了诸多朋友质疑的性能问题,DNN 程序本身的健壮性怎么样呢?

当然我相信其从IBuySpy继承并不断进化的Framework是值得去学习的。