.Net Reflector compilation errors

Asked

Viewed 151 times

4

I’m studying C# and I’m trying to learn a little reverse engineering.

I’m making the following mistake:

private void button1_Click(object sender, EventArgs e)
{
    this.Result = true;
    this.ConfigName = this.textBox1.Text;
    string sourceFileName = new string[] { Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Tibia", this.BaseName }.Aggregate<string>(new Func<string, string, string>(Path.Combine));
    string destFileName = new string[] { Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Tibia", this.ConfigName }.Aggregate<string>(new Func<string, string, string>(Path.Combine));
    File.Copy(sourceFileName, destFileName);
    base.Close();
}

Displays the following error:

Error CS0246 The type or namespace name 'Func' could not be found (are you Missing a using Directive or an Assembly Reference?)

In another part of the code

ConfigFinder.FindConfigs((ConfigFinder.ConfigListHandler) (arr => base.Invoke(() => configcombo.Items.AddRange(arr))));

He introduces me:

Error CS1660 Cannot Convert lambda Expression to type 'Delegate' because it

And still in the code

private void button1_Click(object sender, EventArgs e)
{
    this.Result = true;
    this.ConfigName = this.textBox1.Text;
    string sourceFileName = new string[] { Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Tibia", this.BaseName }.Aggregate<string>(new Func<string, string, string>(Path.Combine));
    string destFileName = new string[] { Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Tibia", this.ConfigName }.Aggregate<string>(new Func<string, string, string>(Path.Combine));
    File.Copy(sourceFileName, destFileName);
    base.Close();
}

shows the error:

Error CS1061 'string[]' does not contain a Definition for 'Aggregate' and no Extension method 'Aggregate' Accepting a first argument of type 'string[]' could be found (are you Missing a using Directive or an Assembly Reference?)

What can it be?

1 answer

2


Well, that’s three different questions.

The first is why you did not import the namespace where the delegate is located Func.

using System;

The CS1660 error is probably because the method FindConfigs does not accept a delegate as a parameter.

The last mistake is because, again, you did not import the namespace of the method Aggregate

using System.Linq;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.