[Mono-list] problem of InsertOnSubmit() function
    Shuping Teng 
    s.teng at ipharro.com
       
    Thu Jan  7 10:34:02 EST 2010
    
    
  
Hello,
 
I am transporting some project to mono platform. I used Linq to do some
transaction with database.
But when encountered  InsertOnSubmit() function, exception was coming as
follow:
 
Unhandled Exception: System.NullReferenceException: Object reference not
set to an instance of an object
 
I paste my code snape in the follow:
 
           VideoFileDataContext pVideoFileDataContext = new
VideoFileDataContext();
            using (TransactionScope scop = new TransactionScope()) {
                foreach (FileInfo pFile in pAllFileList) {
                    // query if the file we wanna store in database if
still exist
                        VideoFileInfo pVideoFileInfo = new
VideoFileInfo();
                        pVideoFileInfo.FileName = pFile.Name;
                        pVideoFileInfo.FilePath = pFile.FullName;
                        pVideoFileInfo.FileSize = (int)(pFile.Length);
                        pVideoFileInfo.MD5Hash =
GetMd5FromFile(pFile.OpenRead());
                        pVideoFileInfo.FoundDate = pFile.LastAccessTime;
                        //every time we set status of file first we
found to Unknow
                        pVideoFileInfo.Status = "Unknow";
 
pVideoFileDataContext.VideoFile.InsertOnSubmit(pVideoFileInfo);
                    }
                    try
                    {
                        pVideoFileDataContext.SubmitChanges();
                    }
Bty: the code is fine when I run them on .net platform
 
Thanks
 
---
Shuping Teng
MSN: Tensping at hotmail.com
QQ:     77630245
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20100107/f42a2dba/attachment.html 
    
    
More information about the Mono-list
mailing list