Error compiling

Feb 28, 2011 at 5:24 PM

Hi,

I create Demo.xaml

<pfx:EffectBuilderCollection
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:pfx="http://www.codeplex.com/perspectivefx"
    EffectDirectory="sources"
    EffectNamespace="FxDemo.Effects">
    <pfx:EffectBuilder
        EffectName="SolarizerEffect">
        <pfx:Solarizer FilterName="Solarizer"/>
    </pfx:EffectBuilder>
</pfx:EffectBuilderCollection>

Create FxGen.bat contains line: FxGeneratorCmd.exe Demo.xaml

After run this bat file get error:

 Target PixelShaderCompile:
    MSBUILD : error MSB4018: The "PixelShaderBuildTask" task failed unexpectedly.
    MSBUILD : error MSB4018: System.BadImageFormatException: Could not load file or assembly 'Perspective.PixelShader.Compiler, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    MSBUILD : error MSB4018: File name: 'Perspective.PixelShader.Compiler, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
    MSBUILD : error MSB4018:    at Perspective.PixelShader.BuildTask.PixelShaderBuildTask.Execute()
    MSBUILD : error MSB4018:    at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)
    MSBUILD : error MSB4018: 
    MSBUILD : error MSB4018: WRN: Assembly binding logging is turned OFF.
    MSBUILD : error MSB4018: To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
    MSBUILD : error MSB4018: Note: There is some performance penalty associated with assembly bind failure logging.
    MSBUILD : error MSB4018: To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
    MSBUILD : error MSB4018: Done building target "PixelShaderCompile" in project "" -- FAILED.

Done building project "" -- FAILED.

Build FAILED.

MSBUILD : error MSB4018: The "PixelShaderBuildTask" task failed unexpectedly.
MSBUILD : error MSB4018: System.BadImageFormatException: Could not load file or assembly 'Perspective.PixelShader.Compiler, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
MSBUILD : error MSB4018: File name: 'Perspective.PixelShader.Compiler, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
MSBUILD : error MSB4018:    at Perspective.PixelShader.BuildTask.PixelShaderBuildTask.Execute()
MSBUILD : error MSB4018:    at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)
MSBUILD : error MSB4018:
MSBUILD : error MSB4018: WRN: Assembly binding logging is turned OFF.
MSBUILD : error MSB4018: To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
MSBUILD : error MSB4018: Note: There is some performance penalty associated with assembly bind failure logging.
MSBUILD : error MSB4018: To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
MSBUILD : error MSB4018:
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.04

 

Coordinator
Mar 1, 2011 at 6:14 PM

Hi,

Is d3dx9_*.dll missing in C:\Windows\System32 ? If so, please install the DirectX End-User Runtime
http://www.microsoft.com/downloads/en/details.aspx?familyid=2DA43D38-DB71-4C1B-BC6A-9B6652CD92A3&displaylang=en

Otherwise please give me more informations about your system.

Olivier

Mar 1, 2011 at 6:47 PM

Hi,

I installed the DirectX End-User Runtime, in C:\Windows\System32 found d3dx9_24.dll ... d3dx9_43.dll, but the error remained.

I have installed Windows 7 Pro x64, Visual Studio 2010 Ultimate with SP1 Beta.

Coordinator
Mar 2, 2011 at 6:12 PM

The Perspective.PixelShader.Compiler.dll is a 32 bits dll, and the other assemblies try to run in a 64 bits mode on a 64 bits OS. So it does not work...

I will publish an update soon.

Meanwhile you can try to compile a 64 bits version of Perspective.PixelShader.Compiler.dll.

Mar 3, 2011 at 10:59 AM

Hi Olivier,

I compiled the assembly with the effects of a 32 bit computer. Added the assembly in a simple console application to test the effects applied:

- FxDemo.Effects.dll

and WPF assemblies:

- PresentationFramework.dll
- WindowsBase.dll
- System.Xaml.dll

static void Main(string[] args)
{
    var image = new BitmapImage(new Uri(@"d:\images\Hydrangeas.jpg"));

    var dv = new DrawingVisual();

    //dv.Effect = new BlurEffect() { Radius = 20 };

    dv.Effect = new GrayScaleEffect();

    using (var dc = dv.RenderOpen())
    {
        dc.DrawImage(image, new Rect(new Size(image.Width, image.Height)));
    }

    var rtb = new RenderTargetBitmap(
        image.PixelWidth,
        image.PixelHeight,
        image.DpiX,
        image.DpiY,
        PixelFormats.Pbgra32);

    rtb.Render(dv);

    using (var stream = new FileStream(@"d:\images\result.jpg", FileMode.Create))
    {
        var encoder = new JpegBitmapEncoder();

        encoder.Frames.Add(BitmapFrame.Create(rtb));

        encoder.Save(stream);               
    }           
}

When I applied BlurEffekt of System.Windows.Media.Effects, the code worked and I got the desired result.

But when I tried to apply GrayScaleEffect of FxDemo.Effects.dll, was an exception System.TypeInitializationException: "The type initializer for 'FxDemo.Effects.GrayScaleEffect' threw an exception."

InnerException: System.NotSupportedException: "The URI prefix is not recognized."

Can I use the effects in such a scenario? Or you can apply effects only to UI elements?

Coordinator
Mar 6, 2011 at 5:04 PM

Yes you can use Perspective FX effects in such a scenario.

The problem you describe is due to a Pack Uri used by Perspective to load HLSL compiled code. Your application needs to be recognized as a WPF application to use Pack Uris (see http://compilewith.net/2009/03/wpf-unit-testing-trouble-with-pack-uris.html). The solution I found consists in instantiating a WPF Application object :

class Program
{
    [STAThread]
    static void Main(string[] args)
    {
        System.Windows.Application app = new System.Windows.Application();
        app.Startup += new StartupEventHandler(app_Startup);
        app.Run();
    }

    static void app_Startup(object sender, StartupEventArgs e)
    {
        var image = new BitmapImage(new Uri(@"D:\Temp\FX\Images\20110306_114539.JPG"));
        var dv = new DrawingVisual();
        // dv.Effect = new BlurEffect() { Radius = 20 };
        dv.Effect = new InvertEffect();
        using (var dc = dv.RenderOpen())
        {
            dc.DrawImage(image, new Rect(new Size(image.Width, image.Height)));
        }
        var rtb = new RenderTargetBitmap(
            image.PixelWidth,
            image.PixelHeight,
            image.DpiX,
            image.DpiY,
            PixelFormats.Pbgra32);
        rtb.Render(dv);
        using (var stream = new FileStream(@"D:\Temp\FX\Images\Result.JPG", FileMode.Create))
        {
            var encoder = new JpegBitmapEncoder();
            encoder.Frames.Add(BitmapFrame.Create(rtb));
            encoder.Save(stream);
        }
        Application.Current.Shutdown(0);
    }
}

Hope this helps...

Mar 8, 2011 at 7:41 PM

Hi,

Thank you for your answers. I did not say, but the effects I need to use a Web application, so the STA model is not suitable.

I need to use the HttpHandler to use on-the-fly the user-selected effect. For example: http://mysite/images/1.jpg?effect=sepia

 

Coordinator
Mar 9, 2011 at 6:51 PM

Hi Denis,

WPF is a client side technology, and unfortunately it seems that you can't use it safely on the server side. You may get memory leaks. However you can try to use it, as these articles suggest it :
http://www.codeproject.com/script/Articles/ArticleVersion.aspx?aid=26681&av=85462
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/a9a485a7-843d-48c7-bd4e-ede1e5b087cd/

Coordinator
Apr 2, 2011 at 9:32 AM

The version 2.1 now works on 32 and 64 bits (Windows 7 64 bits).