Update:  This seems to be related to a race condition in DTF's
implementation of Linq.  The invalid handle exception manifests itself
sometime after a linq query is performed.  The error seems to happen earlier
or later depending on the amount of time that the linq query takes.  If I
remove the linq query all together everything runs fine.  The linq query is
a simple query to a custom table.  Any ideas from anyone?  Linq is much
nicer and smoother than running ExecuteSqlQuery.  The linq code is below.

Thanks

Matt

var sqldbs = from r in database[WixTableName]
                         select
                             new
                             {
                                 key = r[WixKeyColumn],
                                 server = r["Server"],
                                 port = r["Port"],
                                 database = r["Database"],
                                 user = r["User"],
                                 password = r["Password"]
                             };

            foreach (var sqldb in sqldbs)
            {
                SqlDatabase db =
FactoryMethods.Instance.CreateDatabase(WixTableName, sqldb.key);
                db.Server = sqldb.server;

                short port;
                if (short.TryParse(sqldb.port, out port))
                    db.Port = port;

                db.Database = sqldb.database;
                db.Username = sqldb.user;
                db.Password = sqldb.password;

                this.List.Add(db);
            }


On Mon, May 18, 2009 at 11:05 AM, Matt Ziegler <[email protected]> wrote:

> I'm using a view on a binary table to stream out a binary entry to a byte
> array.  After the stream is retrieved the database handle is then invalid.
> I can check this by adding a watch for session.Database.Tables.Count.  Below
> is the piece of code that causes the behavior.  Is this a bug for am I just
> performing this operation incorrectly?
>
> Thanks
>
> Matt
>
> using (View binaryView = session.Database.OpenView("SELECT `Data` FROM
> `Binary` WHERE `Name` = '{0}'", binaryKeyName))
>                 {
>                     binaryView.Execute();
>                     using (Record r = binaryView.Fetch())
>                     {
>                         if (r != null)
>                         {
>                             using (MemoryStream ms = new MemoryStream())
>                             {
>                                 using (Stream s = r.GetStream("Data"))
>                                 {
>                                     int bufLength = 32768; //32K
>                                     byte[] buffer = new byte[bufLength];
>                                     int chunk;
>                                     int read = 0;
>                                     while ((chunk = s.Read(buffer, 0,
> bufLength)) > 0)
>                                     {
>                                         ms.Write(buffer, 0, chunk);
>                                         read += chunk;
>                                     }
>                                 }
>                             }
>                         }
>                         else
>                             throw new Exception(string.Format("There must
> be a binary entry '{0}'", binaryKeyName));
>                     }
>
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
WiX-devs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-devs

Reply via email to