.net – 非托管导出:无法编译程序集
发布时间:2020-12-15 10:07:19 所属栏目:大数据 来源:网络整理
导读:我想创建一个可以从非托管代码(Delphi 5)访问的.NET程序集. 我找到了Unmanaged Exports并按照那里的步骤进行了操作但是我甚至无法成功编译基本示例: using RGiesecke.DllExport;namespace DelphiNET{ public class Class1 { [DllExport("add")] public stat
我想创建一个可以从非托管代码(Delphi 5)访问的.NET程序集.
我找到了Unmanaged Exports并按照那里的步骤进行了操作但是我甚至无法成功编译基本示例: using RGiesecke.DllExport; namespace DelphiNET { public class Class1 { [DllExport("add")] public static int Add(int left,int right) { return left + right; } } } DelphiNET.csproj项目文件: ... <ItemGroup> <Compile Include="Class1.cs" /> <Compile Include="DllExportDllExportAttribute.cs" /> <Compile Include="PropertiesAssemblyInfo.cs" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)Microsoft.CSharp.targets" /> <Import Project="DllExportRGiesecke.DllExport.targets" /> ... 这是错误: ------ Build started: Project: DelphiNET,Configuration: Release Any CPU ------ c:WINDOWSMicrosoft.NETFrameworkv3.5Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:TRACE /debug:pdbonly /filealign:512 /optimize+ /out:objReleaseDelphiNET.dll /target:library Class1.cs DllExportDllExportAttribute.cs PropertiesAssemblyInfo.cs Compile complete -- 0 errors,0 warnings DelphiNET -> C:DelphiNETbinReleaseDelphiNET.dll ILDasm: calling 'C:Program FilesMicrosoft SDKsWindowsv6.0ABinildasm.exe' with /quoteallnames /nobar "/out:C:Documents and SettingsLukasLocal SettingsTemptmp29FDelphiNET.il" "C:DelphiNETbinReleaseDelphiNET.dll" C:DelphiNETbinReleaseDelphiNET.dll : warning EXP0009: Platform is AnyCpu,generating creating binaries for each CPU platform in a separate folder... ILAsm: calling 'c:WINDOWSMicrosoft.NETFrameworkv2.0.50727ILAsm.exe' with /nologo "/out:C:DelphiNETbinReleasex86DelphiNET.dll" "C:Documents and SettingsLukasLocal SettingsTemptmp29FDelphiNET.x86.il" /DLL "/resource=C:Documents and SettingsLukasLocal SettingsTemptmp29FDelphiNET.res" /optimize C:DelphiNETDllExportRGiesecke.DllExport.targets(8,5): error : C:DelphiNETDllExportRGiesecke.DllExport.targets(8,5): error : Assembling 'C:Documents and SettingsLukasLocal SettingsTemptmp29FDelphiNET.x86.il' to DLL --> 'C:DelphiNETbinReleasex86DelphiNET.dll' C:DelphiNETDllExportRGiesecke.DllExport.targets(8,5): error : Source file is ANSI C:DelphiNETDllExportRGiesecke.DllExport.targets(8,5): error : Assembled method RGiesecke.DllExport.DllExportAttribute::.ctor C:DelphiNETDllExportRGiesecke.DllExport.targets(8,5): error : Assembled method RGiesecke.DllExport.DllExportAttribute::get_CallingConvention C:DelphiNETDllExportRGiesecke.DllExport.targets(8,5): error : Assembled method RGiesecke.DllExport.DllExportAttribute::set_CallingConvention C:DelphiNETDllExportRGiesecke.DllExport.targets(8,5): error : Assembled method RGiesecke.DllExport.DllExportAttribute::get_ExportName C:DelphiNETDllExportRGiesecke.DllExport.targets(8,5): error : Assembled method RGiesecke.DllExport.DllExportAttribute::set_ExportName C:DelphiNETDllExportRGiesecke.DllExport.targets(8,5): error : ***** FAILURE ***** C:DelphiNETDllExportRGiesecke.DllExport.targets(8,5): error : Done building project "DelphiNET.csproj" -- FAILED. ========== Build: 0 succeeded or up-to-date,1 failed,0 skipped ========== 操作系统:WinXPSP3,带有SP1的Microsoft Visual C#2008 Express Edition,.NET 3.5 SP1 知道什么是错的吗?谢谢. 编辑23:40: 我找到了这个bug.它是在函数的名称 – 添加和添加太相同.当你改变其中一个,它的工作原理. 解决方法
顺便说一下,我刚刚更新了档案.
当你拿走 this时,你甚至可以为你准备好这一切. 这是一个项目模板,可以设置一切,应该可以正常工作. 我确实在之前的版本中找到了一些要点,我做了一些并非总是如此的假设.我之前实现的一个潜在问题是/ optimize开关,它用于发布配置.在这种情况下,有时ILAsm会扼杀IL,我没有看到新版本. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |