title: Expression Encoder 4 in a WCF service
body: <p>I am trying to write a WCF service that would run in IIS 8 and would use the Expression Encoder SDK to open a video file and then encode it as a WMV. The following code works fine when it's in a desktop application I wrote earlier.</p>
  
  <pre><code>Job job = new Job();
  job.ApplyPreset(Preset.FromFile(HttpRuntime.AppDomainAppPath + "Profiles\\" + profile + ".xml"));
  job.CreateSubfolder = false;
  job.SaveJobFileToOutputDirectory = false;
  job.OutputDirectory = Path.GetDirectoryName(input);
  MediaItem item;
  item = new MediaItem(input);
  item.OutputFileName = "{Original file name}.wmv";
  job.MediaItems.Add(item);
  
  job.EncodeProgress += new EventHandler&lt;EncodeProgressEventArgs&gt;(job_EncodeProgress);
  job.EncodeCompleted += new EventHandler&lt;EncodeCompletedEventArgs&gt;(job_EncodeCompleted);
  job.Encode();
  </code></pre>
  
  <p>But when I try to run this code in a WCF service running on IIS I get the following error</p>
  
  <pre><code>The type initializer for 'Microsoft.Expression.Encoder.SkuManager' threw an exception.
  at Microsoft.Expression.Encoder.SkuManager.IsFeaturedSupported(Feature feature)
  at MS.Internal.Expression.Encoder.FastProperties.FastPropertyCreate.ShouldAddProp(IFastProperty property, PropertyType propType)
  at MS.Internal.Expression.Encoder.FastProperties.FastPropertyCreate.CreatePropertiesArray[T](Type classType, PropertyType propType)
  at MS.Internal.Expression.Encoder.FastProperties.FastPropertyCreate.GetProperties[T](PropertyType propType)
  at MS.Internal.Expression.Encoder.Persistence.JobPersistence.GetJobFilePropertiesCore[T](JobPropertiesMode mode)
  at MS.Internal.Expression.Encoder.Persistence.JobPersistence.GetJobFileProperties[T](JobPropertiesMode mode)
  at Microsoft.Expression.Encoder.JobBase.CreateDefaultValues(JobBase job)
  at Microsoft.Expression.Encoder.JobBase..ctor()
  at Microsoft.Expression.Encoder.Job..ctor()
  </code></pre>
  
  <p>I can run this code in a regular desktop application on the server, but not in a WCF service running on the same machine.</p>