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: [email protected]

QQ:     77630245

 

_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to