I hope this is the correct place for this post.
There appears to be an issue with the SqlDataProvider.AddFile method. It only works correctly when adding new files IE; the first time you try to export the content of a module.
It has a single line here:
Return
CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "AddFile", GetNull(PortalId), FileName, Extension, Size, GetNull(Width), GetNull(Height), ContentType, Folder, FolderID), Integer)
Notice it is casting the return value to an integer. The return value comes from the AddFile stored procedure, the value is the result of the SCOPE_IDENTITY() command at the end of that stored procedure.
The AddFile SP checks to see if the file exists in the Files table already, if so it updates, otherwise it inserts.
The issue is that the SCOPE_IDENTITY value is only an integer when inserting records, so if the AddFile SP is updating, then the returned value from SCOPE_IDENTITY() is null. Then the code is trying to cast null to an integer.
Suggested Fix:
Check for null first, then if null return a NullInteger. Otherwise cast to integer and return.
Dim returnValue As Object = SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & "AddFile", GetNull(PortalId), FileName, Extension, Size, GetNull(Width), GetNull(Height), ContentType, Folder, FolderID)
If returnValue Is DBNull.Value Then
Return Null.NullInteger
Else
Return CType(returnValue, Integer)
End If