Question

I'm doing research into the OpenXmlSdkTools v2.5 and had a sneak peak inside the OpenXmlSdkTools.Core.DLL and saved it as a c# Project with ILSpy.

While this question is active, here is the OpenXmlSdkTools.Core.DLL as a way to quickly reproduce the problem I'm encountering.

When I tried to compile the single class library project, I get two errors about a missng reference to assembly 'System.Xaml'. eg:

The type 'System.Windows.Markup.IQueryAmbient' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xaml

The type 'System.Windows.Markup.IUriContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xaml

So I added the ref.

After that I'm stuck on what I hope is the last compile error and I can't figure it out.

Cannot convert anonymous method to type 'System.Delegate' because it is not a delegate type C:\TFS\ABC\src\OpenXmlSdkTool.Core\DocumentFormat.OpenXml.Tools\ApplicationExtensions.cs 10

Here is the code:

using System;
using System.Windows;
using System.Windows.Threading;
namespace DocumentFormat.OpenXml.Tools
{
    public static class ApplicationExtensions
    {
        public static void DoEvents(this Application application)
        {
            application.Dispatcher.Invoke(DispatcherPriority.Background, delegate
            {
            });
        }
    }
}

I'm stuck and puzzled that its a decompiled DLL that should be easy to re-compile again. Do you think by me adding the Xaml reference its caused this problem? And why would I need to add the Xaml reference if the Core.DLL is a class library project and ILSpy didn't included it in the csproj file?

I've looked at all the other questions on here with the same error but none of them really helped.

Update

When you add System.Xaml.dll as reference to your project. The interface is declared there. Here is the doc.

So now I'm in a Catch22, if I add the Xaml dll it will solve the first 2 errors but then it will cause this other error.

Was it helpful?

Solution

After reproducing the issue on my machine, I found this http://staceyw1.wordpress.com/2007/12/22/they-are-anonymous-methods-not-anonymous-delegates/ (referenced from Convert this delegate to an anonymous method or lambda).

Adding a cast to Action solved the issue

application.Dispatcher.Invoke(DispatcherPriority.Background, (Action)delegate
        {
        });

But there are probably other solutions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top