Unmanaged Exports: Cannot compile assembly

后端 未结 4 1680
野趣味
野趣味 2020-12-16 07:15

I want to create a .NET assembly that can be accessed from unmanaged code (Delphi 5).

I have found Unmanaged Exports and followed the steps there but I am unable to

相关标签:
4条回答
  • 2020-12-16 07:46

    If anyone also encounters it , i also got this error when the exported function name was "init" so changing the name fixed the problem.

    So this produces such an error:

    [DllExport("init")]

    0 讨论(0)
  • 2020-12-16 08:00

    It seems that [DllExport("...)] with the export name "add" throws an error, same with "sub". Message in vs 2010 from ilasm is "assembling filename to dll ... Source file is UNICODE".

    Thanks for this really great work!

    0 讨论(0)
  • 2020-12-16 08:02

    Incidentally, I just updated the archive. You can even get it all laid out for you, when you take this instead.

    It's a project template that sets everything up and should work just fine.

    I did find some points in the previous version, where I made some assumptions that weren't always true. And one potential problem with my previous implementation was the /optimize switch which is used for release configurations. Sometimes ILAsm would choke on the IL in that case, I haven't seen that with the new version.

    0 讨论(0)
  • 2020-12-16 08:05

    Just in case someone will meet the same problems...

    Some errors on my side:

    file: DllExportAttribute.cs

    public CallingConvention CallingConvention { get; set; }
    public string ExportName { get; set; }
    

    file: $projectname$.csproj

    <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>  <!-- not working -->
    <!-- change to -->
    <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets"/> <!-- working -->
    

    Those are easy to fix.

    Here is one pretty serious. When making implib from resulting \x86\MyDll.dll - the name of dll in lib changes to \MyDll.dll ... you can make tdump MyDll.dll and will get in exports section "\MyDll.dll" instead of "MyDll.dll".

    Because of this problem dll can't be found by the soft that use resulting lib... in my situation it can be found only in c:\MyDll.dll

    Solved by making "coff2omf -lib:ca MyDll.lib" on the initial lib. But before that spent a day for looking solution...

    0 讨论(0)
提交回复
热议问题