Unmanaged Exports: Cannot compile assembly

南笙酒味 提交于 2019-11-29 02:37:07

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.

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...

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!

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")]

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!