我在使用VB编写的DNN DAL2模块时遇到问题。这是DNN 7.3.2安装。
模块的Get方法工作正常,但Create,Update和Delete方法会抛出这样的错误:
DotNetNuke.Services.Exceptions.ModuleLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at DotNetNuke.Data.RepositoryBase`1.GetPropertyValue[TProperty](T item, String propertyName)
at DotNetNuke.Data.RepositoryBase`1.GetScopeValue[TProperty](T item)
at DotNetNuke.Data.RepositoryBase`1.ClearCache(T item)
at DotNetNuke.Data.RepositoryBase`1.Update(T item)
at TAC.DNN.Modules.TAC_NPIDal2.Components.ForumReadController.UpdateForumRead(ForumRead t) in D:\Websites\npi1-2017\DesktopModules\TAC_NPIDal2\Components\ForumReadController.vb:line 79
at TAC.DNN.Modules.TAC_NPIForum.Thread.Page_Load(Object sender, EventArgs e) in D:\Websites\npi1-2017\DesktopModules\TAC_NPIForum\Thread.ascx.vb:line 121
The Forum class is defined like this:
<TableName("NPIForum_Read")>
<PrimaryKey("ID", AutoIncrement:=True)>
<Cacheable("NPIForumRead", CacheItemPriority.Default, 20)>
<Scope("ForumID")>
Public Class ForumRead
Private _ID As Integer
Private _userID As Integer
Private _forumID As Integer
Private _threadID As Integer
Private _lastViewed As DateTime
(以及适当的获取和设置)
And the UpdateForumRead method is defined like this:
Public Sub UpdateForumRead(ByVal t As ForumRead)
Using ctx As IDataContext = DataContext.Instance()
Dim rep As IRepository(Of ForumRead) = ctx.GetRepository(Of ForumRead)()
rep.Update(t)
End Using
End Sub
现在,数据库实际上已更新。生成的SQL代码运行时没有错误,并且ForumThreads表会更新。发生此错误。单步执行时,“结束使用”语句会抛出异常。此外,t对象没问题,没有问题。
关于这个的任何想法?
由于
答案 0 :(得分:0)
我认为当DAL2尝试使缓存无效时,错误发生在更新之后。
两个可能的问题:
答案 1 :(得分:0)
请参阅我对Scott的最后回复。这就是答案!