Wednesday, April 27, 2011

Combining WMV Videos

I had some videos downloaded from the internet in WMV format which I wanted to combine to a single file. After trying Windows Movie Maker which did combine my files but make the end result both larger and with less resolution I tried downloading another app “Easy Video Joiner” and wasn’t impressed.

It was half a solution because:

  1. It’s free – which is always a plus (it used to be order based but the company just grants the registration for free here)
  2. It joins WMVs and doesn’t reduce quality nor size! - a plus
  3. It has errors popping up from time to time – a minus
  4. It closes while joining the files without any error – a minus
  5. It wasn’t updated since Jun 30, 2003 – which considering all the errors probably mean it has no support – a minus
  6. The app is very random in its responses meaning running it twice might cause an error once and the next time to succeed, or just drop dead. So no one should delete the source without checking the result first!

So I just wanted to check out how hard will it be to implement a joiner of my own and just looking for managed code for doing that took too long. At the end I found Microsoft Expression Encoder SDK which is supposed to enable this.

//TODO: try it out

 

Keywords: Encoding video, wmv

IceRocket Tags: ,

Wednesday, April 20, 2011

HTTP Error 503. The service is unavailable.

I was trying to solve a problem with Silverlight/WCF error when I actually got this error:

Service-unavailable-error

Someone suggested this solution:

In the IIS Manager\App Pools\Application’s AppPool –> Advanced Settings –> Load User Profile = false:

iis-advanced-settings-load-user-profile

If it helps you please post a response and I will move the solution to my real blog.

 

You can still read my tortured experience (though in the end only format solved it):

I was using IISreset, IISreset /stop, IISreset /start like crazy.

Going to the IIS I found one of the AppPool was stopped so I decided to start it:

IIS-app-pool-start

For like 2 minutes I thought that have been a mistake since it just didn’t complete. But when it completed it was still stopped.

Restart didn’t solve the problem.

Looking at the event log I found one error:

Log Name:      System
Source:        Microsoft-Windows-WAS
Date:          03/02/2011 15:08:03
Event ID:      5002
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Description:
Application pool 'ASP.NET v4.0' is being automatically disabled due to a series of failures in the process(es) serving that application pool.

And about 5 warnings:

Log Name:      System
Source:        Microsoft-Windows-WAS
Date:          03/02/2011 15:08:03
Event ID:      5022
Task Category: None
Level:         Warning
Keywords:      Classic
User:          N/A
Description:
The Windows Process Activation Service failed to create a worker process for the application pool 'ASP.NET v4.0'. The data field contains the error number.

 

Now I know I did some changes in the web.config file – so I decided to undo those. And try to start the App Pool again.

 

I found this error in the Event Viewer: Application Log (it started around the time I started having problems):

Log Name:      Application
Source:        Microsoft-Windows-User Profiles Service
Date:          03/02/2011 14:36:20
Event ID:      1500
Task Category: None
Level:         Error
Keywords:     
User:          IIS APPPOOL\ASP.NET v4.0
Description:
Windows cannot log you on because your profile cannot be loaded. Check that you are connected to the network, and that your network is functioning correctly.

DETAIL - Only part of a ReadProcessMemory or WriteProcessMemory request was completed.

This is an Error for ITs though…

 

But the simplest solution did work – I just moved my applications to another App Pool… Until I had to restart my and then got my trouble doubled:

IIS-double-trouble

(I am starting to use “temp” named App Pools – God Save Me!)

 

Hope I won’t need to format this computer…
Format seems to solve this problem (formatted for a different reason)…

Keywords: IIS, Error

IceRocket Tags: ,

Friday, April 15, 2011

Tuesday, April 12, 2011

LINQ and WCF

I am sure that for most of you this will be back to the basics but I had this exception yesterday:

Type 'System.Linq.Enumerable+WhereSelectEnumerableIterator`2[ClassA,ServiceClassA]' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.  See the Microsoft .NET Framework documentation for other supported types.

That I couldn’t find a solution for in Google, though I solved it fairly easily.

 

The situation was this I had a service lets just call it ClassService with this method:

  1. [ServiceContract]
  2. public interface IClassService
  3. {
  4.     void SomeMethod(ServiceEntity entity);
  5. }

ServiceEntity was defined as:

  1. [DataContract]
  2. public class ServiceEntity
  3. {
  4.     [DataMember]
  5.     public IEnumerable<ServiceClassA> As { get; set; }
  6. }
  7.  
  8. [DataContract]
  9. public class ServiceClassA { }

 

Now the client looked something like:

  1. public IClassService ClassService { get; set; }
  2.  
  3. public void CallService(IEnumerable<ClassA> list)
  4. {
  5.     ClassService.SomeMethod(new ServiceEntity{As = list.Select(Convert)});
  6. }
  7.  
  8. private ServiceClassA Convert(ClassA a)
  9. {
  10.     return new ServiceClassA();
  11. }

(just imagine the constructor initializing the ClassService)

Do you see the mistake?

The problem comes from the line:

  1. ClassService.SomeMethod(new ServiceEntity{As = list.Select(Convert)});

Or most specifically:

  1. new ServiceEntity{As = list.Select(Convert)}

The problem is that LINQ doesn’t actually executes this query. It wait until you try to do something with it like converting it to a list or try using one of the entities. The IEnumrable actually has the type of 'System.Linq.Enumerable+WhereSelectEnumerableIterator`2[ClassA,ServiceClassA]' which is not a WCF DataCotract.

 

The solution is fairly easy:

  1. ClassService.SomeMethod(new ServiceEntity{As = list.Select(Convert).ToList()});

Just use the LINQ query by creating a List out of it is enough.

 

Keywords: LINQ, WCF, Exception

IceRocket Tags: ,,