Unable to use PngBitmapEncoder() on a .NET 3.5 application - WindowsCodec.dll could not be found

Discussion in 'ASP.NET / ASP.NET Core' started by chgray, Sep 22, 2008.

  1. Hello, apologies if I'm really out in orbit :)</o:p>
    </o:p>
    My application requires using some of the newer WPF API?s on the server side. Specifically I need to build some big geometries, apply transforms, and then output the results into a jpg/png.
    All this works on my development server, Windows Server 2003 with .NET 3.5.
    On DiscountASP.Net I?m getting an error that my app is unable to load WindowsCodec.dll. I?m wondering if there could be some kind of sandboxing going on?
    Any ideas? - I?ve posted all the code below
    Thanks!
    -CG
    -----------------------
    using System;</o:p>
    using System.Collections;</o:p>
    using System.Configuration;</o:p>
    using System.Data;</o:p>
    using System.Web;</o:p>
    using System.Web.Security;</o:p>
    using System.Web.UI;</o:p>
    using System.Web.UI.HtmlControls;</o:p>
    using System.Web.UI.WebControls;</o:p>
    using System.Web.UI.WebControls.WebParts;</o:p>
    using System.IO;</o:p>
    using System.Windows.Media;</o:p>
    using System.Windows.Media.Imaging;</o:p>
    using System.Windows.Media.Media3D;</o:p>
    </o:p>
    namespace TestWPF</o:p>
    {</o:p>
    public partial class _Default : System.Web.UI.Page</o:p>
    {</o:p>
    protected void Page_Load(object sender, EventArgs e)</o:p>
    {</o:p>
    DrawingVisual dv = new DrawingVisual();</o:p>
    </o:p>
    using (DrawingContext dc = dv.RenderOpen())</o:p>
    {</o:p>
    System.Windows.Rect r = new System.Windows.Rect(10,10,200,200);</o:p>
    dc.DrawRectangle(new SolidColorBrush(Color.FromRgb(255, 0, 0)), null, r);</o:p>
    }</o:p>
    </o:p>
    RenderTargetBitmap rtb = new RenderTargetBitmap(640, 480, 96d, 96d, PixelFormats.Pbgra32); ß this is what throws</o:p>
    rtb.Render(dv); </o:p>
    </o:p>
    using (FileStream outStream = new FileStream(Server.MapPath("testing.png"), FileMode.Create))</o:p>
    {</o:p>
    PngBitmapEncoder encoder = new PngBitmapEncoder();</o:p>
    encoder.Frames.Add(BitmapFrame.Create(rtb));</o:p>
    encoder.Save(outStream);</o:p>
    }</o:p>
    }</o:p>
    }</o:p>
    }</o:p>
    </o:p>
     
  2. Hi,
    No need to apologize, this is some hard stuff to keep straight in our minds. [​IMG]
    I'm also having a lot of fun with WPF, instantly viewing all media types on Vista with it, including videos.

    Those methods however are not available to us on the Web, not just yet anyway.
    According to Scott Guthrie we may be moving in that direction but it will take more work.

    To use WPF like media effects on the Web you should be using Silverlight.
    Even that is somewhat crazy because the v2 RTM is still in limbo, a few weeks late now getting to us. [​IMG]

    What are you using? Blend 2.5?
    I'm willing to help you with this and once the Silverlight update is out I'll create a few Webcasts.
    Salute,
    Mark
    http://weblogs.asp.net/markwisecarver/
     
  3. Bruce

    Bruce DiscountASP.NET Staff

    The error indicate that the codec is not installed on the server. Is this a standard codec?


    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  4. It is standard but System.Windows.Media.Media3D is for working with 3D brushes in WPF.
    You can even create meshes with it. Pretty cool, but only in Windows. [​IMG]

    note: The sort of mesh you can create with it are like displacement surfaces.
     

Share This Page