Database db = new Database("C:\\TEST.MSI", DatabaseOpenMode.ReadOnly);
  Microsoft.Deployment.WindowsInstaller.View view = db.OpenView("SELECT `Name`, 
`Data` From `Binary` WHERE `Binary`.`Name` = 'TEST'");
  view.Execute();
  foreach (Record rec in view) using (rec)
  {
  Stream s= rec["Data"] as Stream;
  BinaryReader br = new BinaryReader(s, Encoding.ASCII );
  string test = br.ReadString(); // this line crashes
  //workaround is ReadChar/StringBuilder loop
  }
   
  System.IO.EndOfStreamException was unhandled
  Message="Unable to read beyond the end of the stream."
  Source="mscorlib"
  StackTrace:
       at System.IO.__Error.EndOfFile()
       at System.IO.BinaryReader.ReadString()
       at WindowsFormsApplication1.Form1.Form1_Load(Object sender, EventArgs e) 
in C:\data\Sandbox-CommonInstaller\WindowsFormsApplication1\Form1.cs:line 29
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, 
Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, 
Int32 nCmdShow)
       at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Control.set_Visible(Boolean value)
       at 
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 
reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 
reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at WindowsFormsApplication1.Program.Main() in 
C:\data\Sandbox-CommonInstaller\WindowsFormsApplication1\Program.cs:line 17
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence 
assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext 
executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
   
  

Jason Ginchereau <[EMAIL PROTECTED]> wrote:
                Can you share the stack trace?
   
    From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Christopher 
Karper
Sent: Wednesday, May 21, 2008 1:10 PM
To: Kelly Leahy
Cc: [EMAIL PROTECTED]; wix-users@lists.sourceforge.net
Subject: Re: [WiX-users] DTF Stream Operations Issue

   
  No, it's not, and actually, that was a remnant from a variation I tried.

I thought maybe ReadToEnd wasn't working, so I did it line by line and got the 
same issue.

The exception is thrown from within the Read operation, I know that's where the 
issue lies.  :-)  Good thought though.

Chris
    On Wed, May 21, 2008 at 4:00 PM, Kelly Leahy <[EMAIL PROTECTED]> wrote:
  
dumb question (maybe). 

Is "script" null upon entry into the loop you gave? 

It can't be as far as I know for the += operator to work. 

Kelly 



            "Christopher Karper" <[EMAIL PROTECTED]> 

  Sent by: [EMAIL PROTECTED] 
  05/21/2008 12:38 PM 
            To
      "Christopher Painter" <[EMAIL PROTECTED]> 

      cc
    "wix-users@lists.sourceforge.net" <wix-users@lists.sourceforge.net>
      Subject
    Re: [WiX-users] DTF Stream Operations Issue
   
             
      
I haven't seen a WiX developer yet that wasn't helpful and open.  I'm impressed 
with the fact that the entire team is very active in this mailing list.

On Wed, May 21, 2008 at 3:20 PM, Christopher Painter <[EMAIL PROTECTED]> wrote: 
As an aside,  we do have the source code to all those internal classes :)   And 
more importantly we have a developer who in the very few days I've known him 
has been extremly open and cordial in addressing questions about the classes 
and even taking suggestions from improvement from such an obvious C# rookie as 
me who happens to have a bit of domain knowledge the classes are trying to 
address. 

Christopher Karper <[EMAIL PROTECTED]> wrote: 
Shouldn't matter.   I can get the data to and from the file with no issue.  
It's just trying to get the data into the memorystream instead f the filestream 
is an issue.

The RecordStream object in DTF looks like it might be useful, but in typical MS 
fashion, the useful foundation classes are internal instead of public, LOL.

I appreciate your help.  I'll just keep banging on it from here.

Chris

On Wed, May 21, 2008 at 3:01 PM, Christopher Painter <[EMAIL PROTECTED]> wrote: 
Ok, I was wondering how you were going to read binary data into a string.  I'm 
not the best C# guy in the world but I'll see what I can learn here.  I am 
wondering though,  is your text unicode or ansi and would it even matter? 
  
  

Christopher Karper <[EMAIL PROTECTED]> wrote: 
It's text, and I'm running as a custom action, so my database should already be 
available.

I'm opening the view with a joined query, but getting the same data.  I can get 
the record fine, and I can get the stream fine, it's when I try to read from 
the StreamReader wrapper that I run into issues.


I'm trying to read out the text data stored in the binaries table, then modify 
it.  I'm trying to avoid using a temp file if I can, since I only need it in 
memory.

Chris

On Wed, May 21, 2008 at 2:41 PM, Christopher Painter <[EMAIL PROTECTED]> wrote: 
What is the type of script? 
  
Eitherway, would this work for you? 
  
Database db = new Database("C:\\TEST.MSI", DatabaseOpenMode.ReadOnly); 
View view = db.OpenView("SELECT `Name`, `Data` From `Binary` WHERE 
`Binary`.`Name` = 'ISXMLCFG.DLL'"); 
view.Execute(); 
foreach (Record rec in view) using (rec) 
{ 
Stream stream = rec["Data"] as Stream; 
} 
  
  


Christopher Karper <[EMAIL PROTECTED]> wrote: 
I'm trying to read binary data into a memory stream, but 

   Stream stream = binRec.GetStream("Data");
   using (StreamReader sr = new StreamReader(stream))
   {
       script += sr.ReadToEnd();
   }



Gives me an ArgumentNullException when I try to read the stream.   Am I missing 
a step?


Is this stream not compatible with a streamreader?

Chris 
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users 






      -------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users


  

**************************************************************************************
This communication is intended solely for the addressee and is
confidential. If you are not the intended recipient, any disclosure, 
copying, distribution or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. Unless indicated
to the contrary: it does not constitute professional advice or opinions
upon which reliance may be made by the addressee or any other party,
and it should be considered to be a work in progress. Unless otherwise
noted in this email or its attachments, this communication does not form 
a Statement of Actuarial Opinion under American Academy of Actuaries guidelines.
**************************************************************************************

   

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users


       
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to