3001 AG_E_INVALID_FILE_FORMAT errorin Silverlight in browser


Hi, I am able to use silverlight application with out of browser enabled but when I include it into existing project and set it as in browser app I get this error "3001 AG_E_INVALID_FILE_FORMAT" when I try to start playback. I included clientaccesspolicy.xml to avoid security issues I faced earlier, and streams are healthy.
This is how my clientaccesspolicy.xml looks like:
      <allow-from http-request-headers="*" http-methods="*">
        <domain uri="http://*"/>
        <domain uri="https://*"/>
        <resource path="/" include-subpaths="true"/>
Enables Silverlight 2 clients to continue to work normally 
        <domain uri="*"/>
        <resource path="/" include-subpaths="true"/>
        <domain uri="*"/>
        <socket-resource port="4502-4506" protocol="tcp"/>
I assume that this policy is ok, I also see in fiddler that few chunks are downloaded but the error occurs repeatedly.
It also happens with http://www.nasa.gov/multimedia/nasatv/NTV-Public-IPS.m3u8 stream.


henric wrote May 13, 2015 at 5:34 AM

Since segments did get downloaded, it is probably not a security policy issue.

Could you upload some of that Debug.WriteLine() output? There might be something in there. PM if you don't want it public.

(I've been a bit distracted lately trying to get W10 working on my dev laptop. Apart from the start menu not working, settings not launching, reboots and even logouts hanging, and "Refresh PC" refusing to do anything, it worked great.)

mchadesh wrote May 13, 2015 at 6:51 AM

The way I added phonesm to the project no project symbols are being loaded so debugging is "blind". I will send you PM also regarding this issue.

Sorry to hear that, I am a big Windows fanboy but I will wait until they release 10.1 (aka SE) or something. I could download technical preview while ago but they are always pushing products too early to prod.

henric wrote May 14, 2015 at 11:03 PM

Take a look at the project references (including the NuGet packages) used by HlsView.Silverlight. At least on some platforms (I don't recall which, off the top of my head), there are references required for the thing to run that are not required for the thing to compile. Probably due to a needed assembly not otherwise getting copied to the output directory.

henric wrote May 14, 2015 at 11:07 PM

You might try catching all exceptions to see what stack traces turn up.

palethorn wrote Jun 9, 2015 at 1:13 PM

Same error after I tried to integrate sample player into my app. I'm guessing it has something to do with the assembly versions. I'll try and take a close look, but in the meantime, here is the debug output:
'iexplore.exe' (Silverlight): Loaded 'Anonymously Hosted DynamicMethods Assembly'
SmMediaManager.SetMediaState() Idle -> OpenMedia
SmMediaManager.OpenAsync() state OpenMedia
SmMediaManager.ReportState() state OpenMedia message 
SmMediaManager.SetMediaState() OpenMedia -> Opening
MediaStreamFacadeBase.MediaManagerOnStateChange() to Opening: 
SmMediaManager.ReportState() state Opening message 
MediaStreamFacadeBase.MediaManagerOnStateChange() to Opening: 
HttpWebRequestWebReaderManager.DetectContentTypeAsync() url ext "" type M3U8 (application/vnd.apple.mpegurl)
HlsPlaylistSegmentManager.UpdatePlaylist: playlist dynamic False segments 5 url loaded with 5 entries. index: -1 dynamic: False expires: 00:00:00 (09/06/2015 14:00:46 +01:00)
HttpWebRequestWebReaderManager.DetectContentTypeAsync() url ext "" type MPEG-2 Transport Stream (video/MP2T)
Unable to get us-ascii encoding
Unable to get Windows-1252 encoding
Unable to get iso-8859-1 encoding
++++ Starting at 09/06/2015 14:00:46 +01:00.  Total memory: 6.24 MiB
Create PES Video stream (AVC video stream conforming to one or more profiles defined in Annex A of ITU-T Rec. H.264 | ISO/IEC 14496-10 or AVC video sub-bitstream as defined in 2.1.78) with PID 256
Create PES Audio stream (ISO/IEC 13818-7 Audio with ADTS transport syntax) with PID 257
H264Configurator.ComputeFrameRate() 25/1 -> 25.0000 fps
Configuration H.264 "Baseline" profile, level 3 854x480
Configuration AAC layer 0 profile "AAC LC (Low Complexity), 44.1kHz 1 channels" channels 1 sampling 44.1kHz length 280 CRC False
TsTimestamp.ProcessPackets() syncing pts 15:40:01.4464444 dts 10675199.02:48:05.4775807 target 00:00:00 => offset 15:40:01.4464444
TsMediaStreamSource.ConfigureAudioStream(): CodecPrivateData: 1016010044AC000000000000010010000E000100FE0000000000000000001208
MediaStreamConfigurator.ConfigureVideoStream(): CodecPrivateData: 000000016742C01EDA0360F79BC044000003000400000300C83C58BA800000000168CE0FC8
SmMediaManager.SetMediaState() Opening -> Playing
SmMediaManager.ReportState() state Playing message 
MediaStreamFacadeBase.MediaManagerOnStateChange() to Playing: 
---- Completed at 09/06/2015 14:00:46 +01:00 (00:00:00.2073876).  Total memory: 8.03 MiB
++++ Starting at 09/06/2015 14:00:46 +01:00.  Total memory: 8.03 MiB
BufferingManager.UpdateBuffering done buffering: duration 00:00:09.9200000 size 415782 starting True memory 8.07 MiB
  Video count 249 size 295695 newest 00:00:09.9200000 oldest 00:00:00
  Audio count 430 size 120087 newest 00:00:09.9773245 oldest 00:00:00.0159667
TsTimestamp.ProcessPackets() resyncing expected pts 00:00:10.0005445 actual pts 00:00:00.0159667 target 00:00:00 => offset 15:39:51.4618666 (was 15:40:01.4464444)
---- Completed at 09/06/2015 14:00:46 +01:00 (00:00:00.0123097).  Total memory: 8.47 MiB
++++ Starting at 09/06/2015 14:00:46 +01:00.  Total memory: 8.47 MiB
TsTimestamp.ProcessPackets() resyncing expected pts 00:00:19.9851223 actual pts 00:00:10.0005445 target 00:00:00 => offset 15:39:41.4772888 (was 15:39:51.4618666)
---- Completed at 09/06/2015 14:00:46 +01:00 (00:00:00.0104137).  Total memory: 8.96 MiB
++++ Starting at 09/06/2015 14:00:46 +01:00.  Total memory: 8.97 MiB
MediaElement State: Opening
---- Completed at 09/06/2015 14:00:46 +01:00 (00:00:00.0066779).  Total memory: 9.33 MiB
++++ Starting at 09/06/2015 14:00:46 +01:00.  Total memory: 9.33 MiB
TsTimestamp.ProcessPackets() resyncing expected pts 00:00:29.9697001 actual pts 00:00:39.9775001 target 00:00:00 => offset 15:39:51.4850888 (was 15:39:41.4772888)
BufferingManager.UpdateState read blocking -> True duration 00:00:30.3949134 size 1303590 memory 9.35 MiB
  Video count 774 size 937717 newest 00:00:30.8813556 oldest 00:00:00
  Audio count 1310 size 365873 newest 00:00:30.4108801 oldest 00:00:00.0159667
---- Completed at 09/06/2015 14:00:46 +01:00 (00:00:00.0058582).  Total memory: 9.36 MiB
MediaElement State: Opening
Media OpenMediaAsyncCalled: Idle -> Opening at 09/06/2015 14:00:48 +01:00
TsMediaStreamSource: ReportOpenMediaCompleted (2 streams)
TsMediaStreamSource: ReportOpenMediaCompleted Duration = 410000000
TsMediaStreamSource: ReportOpenMediaCompleted CanSeek = True
Media CallingReportOpenMediaCompleted: Opening -> AwaitSeek at 09/06/2015 14:00:48 +01:00
MediaElement State: Opening
ValidateEvent Invalid state transition: state AwaitSeek event CloseMediaCalled
MediaElement State: Opening
SmMediaManager.SetMediaState() Playing -> Closing
TsMediaStreamSource.CloseAsync(): close RanToCompletion
SmMediaManager.CloseReadersAsync() closing readers
BufferingManager.UpdateState done buffering (eof): duration none size none starting True memory 9.54 MiB
  Video count 1 size 0 newest  oldest 
  Audio count 1 size 0 newest  oldest 
SmMediaManager.CloseReadersAsync() readers closed
ValidateEvent Invalid state transition: state AwaitSeek event DisposeCalled
The thread 'TsMediaStreamSource' (0x444) has exited with code 0 (0x0).
SmMediaManager.DisposeReaders() completed
SmMediaManager.SetMediaState() Closing -> Closed
SmMediaManager.ReportState() state Closed message 
MediaStreamFacadeBase.MediaManagerOnStateChange() to Closed: 
SmMediaManager.CloseAsync() completed
SmMediaManager.SetMediaState() Closed -> Closing
SmMediaManager.SetMediaState() Closing -> Closed
SmMediaManager.ReportState() state Closed message 
SmMediaManager.CloseAsync() completed
MediaStreamFacadeBase.CleanupMediaManager() completed
SubPool 327680: new 6 alloc 7 free 7 allocSize 18157
SubPool 1310720: new 0 alloc 0 free 0 allocSize 0
Pool clear: alloc 7 free 7 req bytes 18157, alloc bytes 2293760 free bytes 2293760
SubPool 327680: new 0 alloc 0 free 0 allocSize 0
SubPool 1310720: new 0 alloc 0 free 0 allocSize 0
The same stream runs in the sample application. Video codec is x264, audio codec is AAC. Stream is running on my local network

palethorn wrote Jun 9, 2015 at 1:38 PM

I forgot to mention it's an in browser application. It seems sample project also has issues with it.

palethorn wrote Jun 9, 2015 at 1:53 PM

Sorry, sample project actually runs fine even as an in browser application

palethorn wrote Jun 10, 2015 at 12:08 PM


I created separate Silverlight project and added following projects as references:


Updated nuget packages. Enabled elevated persmissions. Fired it up as an out of browser application and it still reports the same message. Assembly references are identical.

henric wrote Jun 11, 2015 at 3:16 AM

There are some settings in App.xaml.cs that you might need. IIRC, that stuff predates phonesm's switch to a DI container; it may not be the best place for those settings anymore.

Could you give those a try if you didn't see them earlier?


palethorn wrote Jun 11, 2015 at 8:06 AM

Ok, I've found those settings:

AacDecoderSettings.Parameters.UseRawAac = true;
AacDecoderSettings.Parameters.ConfigurationFormat = AacDecoderParameters.WaveFormatEx.RawAac;

Now it works, but it requires elevated permissions. I would like to avoid that if it's possible. It seems like silverlight doesn't allow inheriting TaskScheduler

{Autofac.Core.DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(SM.Media.IMediaStreamControl)' on type 'TsMediaStreamSource'. ---> Inheritance security rules violated while overriding member: 'SM.Media.Utility.SingleThreadSignalTaskScheduler.QueueTask(System.Threading.Tasks.Task)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden. (See inner exception for details.) ---> System.TypeLoadException: Inheritance security rules violated while overriding member: 'SM.Media.Utility.SingleThreadSignalTaskScheduler.QueueTask(System.Threading.Tasks.Task)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
at SM.Media.TsMediaStreamSource..ctor(IMediaStreamControl mediaStreamControl)
at lambda_method(Closure , Object[] )
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
--- End of inner exception stack trace ---
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable
1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.Core.Resolving.ResolveOperation.ResolveComponent(IComponentRegistration registration, IEnumerable
1 parameters)
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable1 parameters)
at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable
1 parameters)
at lambda_method(Closure )
at SM.Media.MediaStreamConfigurator.CreateMediaStreamSourceAsync[TMediaStreamSource](CancellationToken cancellationToken)}

Any way I can get around this?

henric wrote Jun 15, 2015 at 11:23 PM

Hmmm... The custom task scheduler is used to avoid some serious problems on Windows 7. One might be able to get rid of that stuff entirely for Silverlight. IIRC, whatever replaces it would need to make sure that the relevant code is still serialized; SignalTask might work.

henric wrote Jun 16, 2015 at 2:21 AM

Errr... By "Windows 7" I meant "Windows Phone 7".

palethorn wrote Jun 22, 2015 at 6:43 AM

I'll see what I can do.

henric wrote Jul 2, 2015 at 4:56 AM

Any luck? I haven't had a chance to look at the phonesm stuff for a while.

palethorn wrote Jul 10, 2015 at 6:33 AM

I've bypassed SingleThreadSignalTaskScheduler. So, instead of signaling to task scheduler, I just invoke the handler method directly. Haven't had any issues yet.