Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An item with the same key has already been added #10

Closed
OmegaExtern opened this issue Sep 22, 2016 · 2 comments
Closed

An item with the same key has already been added #10

OmegaExtern opened this issue Sep 22, 2016 · 2 comments
Milestone

Comments

@OmegaExtern
Copy link

private static void Main(string[] args)
{
    Print(__arglist("Hello", ' ', "with arglist."));
    Print("Hello", ' ', "with params.");
    Pause();
}

[DllExport]
public static void Pause()
{
    try
    {
        Console.ReadKey(true);
    }
    catch (InvalidOperationException)
    {
        Console.Read();
    }
}

[DllExport(nameof(Print) + "_arglist")]
public static void Print(__arglist) // Export as "Print_arglist"
{
    ArgIterator argIterator = new ArgIterator(__arglist);
    while (argIterator.GetRemainingCount() > 0)
    {
        TypedReference typedReference = argIterator.GetNextArg();
        object obj = TypedReference.ToObject(typedReference);
        Console.WriteLine(obj);
    }
}

[DllExport(nameof(Print) + "_params")]
public static void Print(params object[] args) // Export as "Print_params"
{
    foreach (object obj in args)
    {
        Console.WriteLine(obj);
    }
}

If you try to compile the program from above (note: C# 6), it is going to fail with the following error message:

DllExport.1.3.0\tools\net.r_eg.DllExport.targets(59,5): error : An item with the same key has already been added.

Also, it is the same thing as with UnmanagedExports:

UnmanagedExports.1.2.7\tools\RGiesecke.DllExport.targets(58,3): error : An item with the same key has already been added.

Screenshot of the error

@3F
Copy link
Owner

3F commented Sep 23, 2016

yes, I see what's going on, need to fix it.

the working sample something like this:

  .method public hidebysig static void modopt(['mscorlib']'System.Runtime.CompilerServices'.'CallConvStdcall') 
          'Print'(int32 'a') cil managed
  {
    .vtentry 1 : 1
    .export [0] as 'Print1'
    ...
  }

  .method public hidebysig static void modopt(['mscorlib']'System.Runtime.CompilerServices'.'CallConvStdcall') 
          'Print'(bool 'b') cil managed
  {
    .vtentry 1 : 2
    .export [1] as 'Print2'
    ...
  }
[DllExport("Print1")]
public static void Print(int a) { }

[DllExport("Print2")]
public static void Print(bool b) { }
using(var l = new ConariL(@"Test1.dll"))
{
    l.DLR.Print1(1); // Print(int a)
    l.DLR.Print2(1); // Print(bool b)
}

@3F
Copy link
Owner

3F commented Oct 4, 2016

now should work, try ca1d73a

damn, I have problem with accessing to github on this week :( what's going on <<_

@3F 3F closed this as completed Oct 4, 2016
3F added a commit that referenced this issue Oct 5, 2016
    * FIXED: Fixed bug - `An item with the same key has already been added`. Issue #10
    * FIXED: Bug with Meta library: Incorrect default values. Issue #16
             please note, the __cdecl is the default calling convention for our library
             as and for C and C++ programs.

    * FIXED?: Probably fixed bug - `Script errors on package install` Issue #6
    * FIXED?: Probably fixed bug - `non-English system language - syntax error` Issue #7
    * NEW: GUI Configurator with updated ddNS features.
    * NEW: Implemented feature 'Export for platform': [ x86 / x64 / x86 + x64 ] Issue #9
    * NEW: Implemented feature 'Base for ordinals'. Issue #11
           There is also alternative to configure this number - MSBuild property: DllExportOrdinalsBase

    * NEW: The one (1) now is used by default as Base for all ordinals.
           `Mimic ordinal counter (start from 1 instead of 0)` Issue #8

    * CHANGED: The ddNS features now as binary cmdlet `NSBin`. Use `nsbin.bat` if needed.
    * CHANGED: `Set "Inherited = false" in AttributeUsage for DllExportAttribute`. Issue #15
    * OTHER: other possible changes and fixes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants