Unmanaged Export: Nicht kompilieren Montage

Ich erstellen möchten .NET-assembly zugegriffen werden kann, von nicht verwaltetem code (Delphi 5).

Habe ich gefunden Unmanaged Export und folgte den Anweisungen, aber ich bin nicht erfolgreich kompilieren, sogar die basic-Beispiel:

using RGiesecke.DllExport;

namespace DelphiNET
{
    public class Class1
    {
        [DllExport("add")]
        public static int Add(int left, int right)
        {
            return left + right;
        }
    }
}

DelphiNET.csproj Projekt-Datei:

...
<ItemGroup>
  <Compile Include="Class1.cs" />
  <Compile Include="DllExport\DllExportAttribute.cs" />
  <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="DllExport\RGiesecke.DllExport.targets" />
...

Hier ist der Fehler:

------ Build started: Project: DelphiNET, Configuration: Release Any CPU ------
c:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:TRACE /debug:pdbonly /filealign:512 /optimize+ /out:obj\Release\DelphiNET.dll /target:library Class1.cs DllExport\DllExportAttribute.cs Properties\AssemblyInfo.cs

Compile complete -- 0 errors, 0 warnings
DelphiNET -> C:\DelphiNET\bin\Release\DelphiNET.dll
ILDasm: calling 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\ildasm.exe' with /quoteallnames /nobar "/out:C:\Documents and Settings\Lukas\Local Settings\Temp\tmp29F\DelphiNET.il" "C:\DelphiNET\bin\Release\DelphiNET.dll"
C:\DelphiNET\bin\Release\DelphiNET.dll : warning EXP0009: Platform is AnyCpu, generating creating binaries for each CPU platform in a separate folder...
ILAsm: calling 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ILAsm.exe' with /nologo "/out:C:\DelphiNET\bin\Release\x86\DelphiNET.dll" "C:\Documents and Settings\Lukas\Local Settings\Temp\tmp29F\DelphiNET.x86.il" /DLL "/resource=C:\Documents and Settings\Lukas\Local Settings\Temp\tmp29F\DelphiNET.res"  /optimize  
C:\DelphiNET\DllExport\RGiesecke.DllExport.targets(8,5): error : 
C:\DelphiNET\DllExport\RGiesecke.DllExport.targets(8,5): error : Assembling 'C:\Documents and Settings\Lukas\Local Settings\Temp\tmp29F\DelphiNET.x86.il'  to DLL --> 'C:\DelphiNET\bin\Release\x86\DelphiNET.dll'
C:\DelphiNET\DllExport\RGiesecke.DllExport.targets(8,5): error : Source file is ANSI
C:\DelphiNET\DllExport\RGiesecke.DllExport.targets(8,5): error : 
C:\DelphiNET\DllExport\RGiesecke.DllExport.targets(8,5): error : Assembled method RGiesecke.DllExport.DllExportAttribute::.ctor
C:\DelphiNET\DllExport\RGiesecke.DllExport.targets(8,5): error : Assembled method RGiesecke.DllExport.DllExportAttribute::.ctor
C:\DelphiNET\DllExport\RGiesecke.DllExport.targets(8,5): error : Assembled method RGiesecke.DllExport.DllExportAttribute::.ctor
C:\DelphiNET\DllExport\RGiesecke.DllExport.targets(8,5): error : Assembled method RGiesecke.DllExport.DllExportAttribute::get_CallingConvention
C:\DelphiNET\DllExport\RGiesecke.DllExport.targets(8,5): error : Assembled method RGiesecke.DllExport.DllExportAttribute::set_CallingConvention
C:\DelphiNET\DllExport\RGiesecke.DllExport.targets(8,5): error : Assembled method RGiesecke.DllExport.DllExportAttribute::get_ExportName
C:\DelphiNET\DllExport\RGiesecke.DllExport.targets(8,5): error : Assembled method RGiesecke.DllExport.DllExportAttribute::set_ExportName
C:\DelphiNET\DllExport\RGiesecke.DllExport.targets(8,5): error : 
C:\DelphiNET\DllExport\RGiesecke.DllExport.targets(8,5): error : ***** FAILURE ***** 
C:\DelphiNET\DllExport\RGiesecke.DllExport.targets(8,5): error : 
Done building project "DelphiNET.csproj" -- FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

OS: WinXPSP3, Microsoft Visual C# 2008 Express Edition mit SP1 .NET 3.5 SP1

Irgendeine Idee was falsch ist? Danke.


Edit 23:40:

Ich habe den Fehler gefunden. Es ist der name der Funktion - hinzufügen und Hinzufügen sind zu gleichen. Wenn Sie eines von beiden ändern, es funktioniert.

  • Haben Sie versucht, mit nur x86-oder x64-statt AnyCPU?
  • Das sollte nicht das problem sein. In diesem Fall wäre es das ursprüngliche Montage unberührt, sondern erstellen Sie Unterordner für x86-und x64-Versionen.
  • Sieht für mich wie es ist, die Behandlung von Diagnose-Ausgang von ilasm.exe als ob Sie Fehler enthalten sind.
  • Die "***** FEHLER *****"-Teil kam von ILAsm.
  • Robert, ich habe festgestellt ein ähnliches problem, kannst du helfen? stackoverflow.com/questions/7264130/...
Schreibe einen Kommentar