Saturday, March 24, 2012
The data is invalid - windows media player error
the following code.
I need to be able to use either response.outpustream or
response.binarywrite since
I will be getting the file from an sql server image field. Other types
of files such as gif or pdf work fine. Here is the code for the wmv:
Dim sql As String
sql = "select * from TblBlobs where blob_id = " & iBlobId
Dim da As New SqlDataAdapter(sql, cn)
Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet
cn.Open()
da.Fill(ds, "Default")
Dim myRow As DataRow
myRow = ds.Tables("Default").Rows(0)
Dim MyData() As Byte
MyData = myRow("filedata")
Response.ClearContent()
Response.ClearHeaders()
Response.Buffer = False
Response.ContentType = "video/x-ms-wmv"
Response.OutputStream.Write(MyData, 0, MyData.Length)
Response.Flush()
Response.Close()
MyCB = Nothing
ds = Nothing
da = Nothing
cn.Close()
cn = Nothing
When the user clicks on a button to run this code, the error "The data
is invalid" is displayed from windows media player. I cannot figure
out what is specific about wmv's that they will not stream.
Thanks Before Hand,
AdielUpdate:
The error when testing on system with Windows Media Player Version
7.10.00.3077 is "The data is invalid"
The error when testing on system with Windows Media Player Version
10.00.00.3700 is "Windows Media Player cannot play the file. The
Player might not support the file type or might not support the codec
that was used to compress the file." and if you click on "More
Information", the error is "C00D1199: Cannot play the file" Error ID =
0xC00D1199, Condition ID = 0x00000000.
Thanks,
Adiel
The data is invalid - windows media player error
the following code.
I need to be able to use either response.outpustream or
response.binarywrite since
I will be getting the file from an sql server image field. Other types
of files such as gif or pdf work fine. Here is the code for the wmv:
Dim sql As String
sql = "select * from TblBlobs where blob_id = " & iBlobId
Dim da As New SqlDataAdapter(sql, cn)
Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet
cn.Open()
da.Fill(ds, "Default")
Dim myRow As DataRow
myRow = ds.Tables("Default").Rows(0)
Dim MyData() As Byte
MyData = myRow("filedata")
Response.ClearContent()
Response.ClearHeaders()
Response.Buffer = False
Response.ContentType = "video/x-ms-wmv"
Response.OutputStream.Write(MyData, 0, MyData.Length)
Response.Flush()
Response.Close()
MyCB = Nothing
ds = Nothing
da = Nothing
cn.Close()
cn = Nothing
When the user clicks on a button to run this code, the error "The data
is invalid" is displayed from windows media player. I cannot figure
out what is specific about wmv's that they will not stream.
Thanks Before Hand,
AdielCAn you scesfully download the WMV file.
"adiel_g@dotnet.itags.org.hotmail.com" wrote:
> I cannot seem to get a wmv file to stream from asp.net. I have tried
> the following code.
> I need to be able to use either response.outpustream or
> response.binarywrite since
> I will be getting the file from an sql server image field. Other types
> of files such as gif or pdf work fine. Here is the code for the wmv:
>
> Dim sql As String
> sql = "select * from TblBlobs where blob_id = " & iBlobId
> Dim da As New SqlDataAdapter(sql, cn)
> Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
> Dim ds As New DataSet
> cn.Open()
> da.Fill(ds, "Default")
> Dim myRow As DataRow
> myRow = ds.Tables("Default").Rows(0)
> Dim MyData() As Byte
> MyData = myRow("filedata")
> Response.ClearContent()
> Response.ClearHeaders()
> Response.Buffer = False
> Response.ContentType = "video/x-ms-wmv"
> Response.OutputStream.Write(MyData, 0, MyData.Length)
> Response.Flush()
> Response.Close()
> MyCB = Nothing
> ds = Nothing
> da = Nothing
> cn.Close()
> cn = Nothing
>
> When the user clicks on a button to run this code, the error "The data
> is invalid" is displayed from windows media player. I cannot figure
> out what is specific about wmv's that they will not stream.
> Thanks Before Hand,
> Adiel
>
No, if I click on the link and choose "Save target as", the error is:
Internet Explorer cannot down from ... _ctl18$lnkLoadImageItem','').
I can understand the above error because the system has to call the
function before it can actually download the file. Basically the
function above is being called from a LinkButton. I have also tried
calling the function from a regular button and same results: I can load
gifs, pdfs, jpgs, etc but windows video files (wmv) receive the error
"The data is invalid" when the system starts Windows Media Player.
Update:
The error when testing on system with Windows Media Player Version
7.10.00.3077 is "The data is invalid"
The error when testing on system with Windows Media Player Version
10.00.00.3700 is "Windows Media Player cannot play the file. The
Player might not support the file type or might not support the codec
that was used to compress the file." and if you click on "More
Information", the error is "C00D1199: Cannot play the file" Error ID =
0xC00D1199, Condition ID = 0x00000000.
Thanks,
Adiel
The element 'compilation' has invalid child element 'compilers
I removed it entirely from web.config as it is apparently unnecessary.
Guess I wish the migration wizard could of either 1) removed it for me or 2)
flagged it as a todo with an explanation.
Thx.
R-
"Juan T. Llibre" wrote:
> In 2.0, the <compilers> section is found in machine.config,
> so you don't need to place it in web.config.
> Check out machine.config.comments in the .Net Framework\config dir.
> The syntax has changed.
> It's now in the <system.codedom> section.
> See : http://msdn2.microsoft.com/en-us/library/e4hwk57e.aspx
>
>
> Juan T. Llibre, ASP.NET MVP
> ASP.NET FAQ : http://asp.net.do/faq/
> ASPNETFAQ.COM : http://www.aspnetfaq.com/
> Foros de ASP.NET en Espa?ol : http://asp.net.do/foros/
> ======================================
> "Robert" <robertv@dotnet.itags.org.noemail.nospam> wrote in message
> news:9999C8CB-CF4F-4F1A-89A5-775753A7B124@dotnet.itags.org.microsoft.com...
>
>Hi Robert,
Yes, what a pity that the migration wizard was not able to automatically
correct this, maybe it is due to the <system.codedom> is outside the
<system.web> that beyond the migration checking. Anyway, the error message
make some sense, also thanks for Juan's informative suggestion.
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
| Thread-Topic: The element 'compilation' has invalid child element
'compilers
| thread-index: AcXpe7dhGIAffoz4SzOtjdSjQDOyUA==
| X-WBNR-Posting-Host: 67.180.214.235
| From: examnotes <robertv@.noemail.nospam>
| References: <9999C8CB-CF4F-4F1A-89A5-775753A7B124@.microsoft.com>
<ewe5xmX6FHA.3924@.TK2MSFTNGP10.phx.gbl>
| Subject: Re: The element 'compilation' has invalid child element
'compilers
| Date: Mon, 14 Nov 2005 16:30:01 -0800
| Lines: 72
| Message-ID: <0A4CC52E-0180-414A-9D4D-DAF5F94820F1@.microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 8bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:358118
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Thanks for the response.
|
| I removed it entirely from web.config as it is apparently unnecessary.
|
| Guess I wish the migration wizard could of either 1) removed it for me or
2)
| flagged it as a todo with an explanation.
|
| Thx.
| R-
|
| "Juan T. Llibre" wrote:
|
| > In 2.0, the <compilers> section is found in machine.config,
| > so you don't need to place it in web.config.
| >
| > Check out machine.config.comments in the .Net Framework\config dir.
| >
| > The syntax has changed.
| > It's now in the <system.codedom> section.
| >
| > See : http://msdn2.microsoft.com/en-us/library/e4hwk57e.aspx
| >
| >
| >
| >
| > Juan T. Llibre, ASP.NET MVP
| > ASP.NET FAQ : http://asp.net.do/faq/
| > ASPNETFAQ.COM : http://www.aspnetfaq.com/
| > Foros de ASP.NET en Espa?ol : http://asp.net.do/foros/
| > ======================================
| > "Robert" <robertv@.noemail.nospam> wrote in message
| > news:9999C8CB-CF4F-4F1A-89A5-775753A7B124@.microsoft.com...
| > >I have a number of web projects converted from 1.1 to 2.0 in VS2005.
| > >
| > > I am methodically seeing the error below:
| > >
| > > The element 'compilation' has invalid child element 'compilers'.
List of
| > > possible elements expected: 'assemblies, buildProviders,
codeSubDirectories,
| > > expressionBuilders'.
| > >
| > > Here's what the web config looks like. The error doesn't cause any
issues
| > > and according to the MSDN documentation this is valid. So why is
VS2005
| > > giving me this bogus error?
| > >
| > > <configuration>
| > > <system.web>
| > > <httpRuntime maxRequestLength="8192"/>
| > > <!-- DYNAMIC DEBUG COMPILATION
| > > Set compilation debug="true" to insert debugging symbols
(.pdb
| > > information)
| > > into the compiled page. Because this creates a larger file
that
| > > executes
| > > more slowly, you should set this value to true only when
debugging
| > > and to
| > > false at all other times. For more information, refer to the
| > > documentation about
| > > debugging ASP.NET files.
| > > -->
| > > <compilation defaultLanguage="vb" debug="true" batch="false">
| > > <compilers>
| > > <compiler language="vb" type="Microsoft.VisualBasic.VBCodeProvider,
| > > System, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=B77A5C561934E089"
| > > extension=".VB" compilerOptions="/define:Debug=True /define:Trace=True
| > >
/imports:Microsoft.VisualBasic,System,System.Collections,System.Configuratio
n,System.Data,System.Drawing,System.Web,System.Web.UI,System.Web.UI.HtmlCont
rols,System.Web.UI.WebControls"/></compilers>
| > > <assemblies>
| > >
| > > etc, etc,
| > >
| > >
| >
| >
| >
|
Thursday, March 22, 2012
The files are downloaded with the html code at the end of them
Try
Response.AddHeader("Content-Disposition", "attachment;filename=" & strFileName)
Dim fs As FileStream = New FileStream("C:\text.txt", FileMode.Open, FileAccess.Read)
Dim fileData As Byte()
ReDim fileData(fs.Length)
Dim bytesRead As Long = fs.Read(fileData, 0, CInt(fs.Length))
fs.Close()
Response.BinaryWrite(fileData)
Catch es as Exception
lblAlert.text = "It was a problem transferring the file."
end try
The problem is that if you open the files with 'notepad' you see that the html code of the page has been incorporated to the end of the file. Something like this:
***************Beginning of the file***************
0000114099 00000 n
0000114243 00000 n
0000114317 00000 n
trailer<</Size 62/ID<79e93880650e9d343ab0837ab878f5cd><79e93880650e9d343ab0837ab878f5cd>]>>
startxref 173 %%EOF
<html>
<head>
<title>HLC Intranet - HLC Eroom</title>
***************rest of the html code***************
Somebody knows what can be? How can I takeout the html code?
Thanks,
BriegaHi,
I presume this is some code-behind code. Check if there is still some html code in your page (this is created automatically when you create a new webform in vs.net). Delete the html code and only leave the Page-directive.
I struggled with this issue also last year and this is what worked for me:
Response.Clear()
Response.ContentType = scan.ContentType
Response.BinaryWrite(scan.Document)
Response.End()
Grz, Kris.
It works!!!
The only part of your code that I don't understand is the
Response.BinaryWrite(scan.Document)
Could you tell me what that does? I've copy the code without it and it works anyway.
Regards,
Briega
Sorry I typed wrong!
What I don't understand is:
Response.ContentType = scan.ContentType
Briega
I'm sorry, I took a little snippet out of my code. scan is an instantiation of a custom made class which retrieves the binary data and it's accompanying contenttype (pdft, excell, word, ...)
You can search for the content types on the internet.
Grz, Kris.