I'm trying to compile This Example for unmanaged export in XE but I getting (PE9) Unknown identifier "UnmanagedExport" error when build.
- Under Compatibility select "Allow unsafe code"
- Under Build, find the General Section and change CPU Type to "x86"
- Right Click on the "ClassLibraryX" tab that was created and select "Save selected Items"
namespace exptest; interface uses System.Runtime.InteropServices; type clstest = public static class private protected public [UnmanagedExport('xmsg',CallingConvention.StdCall)] function xmsg(amsg : String):String; end; implementation function clstest.xmsg(amsg: String):String; Begin Result := amsg + ' mesajı için geri dönüş'; end; end.
Any idea?
@David:Thanks for answer. I've tried your tip
public
[UnmanagedExport('xmsg',CallingConvention.StdCall)]
class method xmsg(amsg : String):String;
end;
implementation
class method clstest.xmsg(amsg: String):String;
Begin
Result := amsg + ' mesajı için geri dönüş';
end;
but same error is continues.
@David 2 :):
I've changed code in this way:
namespace exptest;
interface
uses
RemObjects.Oxygene.System;
type
clstest = public class
private
protected
public
[UnmanagedExport('xmsg',CallingConvention.StdCall)]
class method xmsg(amsg : String):String;
end;
implementation
class method clstest.xmsg(amsg: String):String;
Begin
Result := amsg + ' mesajı için geri dönüş';
end;
end.
Same error :)
@david 3
namespace exptest;
interface
uses
RemObjects.Oxygene.System,System.Runtime.InteropServices;
type
clstest = public class
private
protected
public
[UnmanagedExport('xmsg',CallingConvention.StdCall)]
class method xmsg(amsg : String):String;
end;
implementation
class method clstest.xmsg(amsg: String):String;
Begin
Result := 'a return value for '+amsg ;
end;
end.
still same error. :,( Can you try on your prism ide my sample project for me please? Thanks for answers.
C:\Program Files\Embarcadero\Delphi Prism\bin>oxygene -version
RemObjects Oxygene for .NET - Version 4.0.25.791
Copyright RemObjects Software 2003-2009. All rights reserved.
Exclusively licensed for Delphi Prism.
Configuration Release not found
my oxygene version 4.0.25.791 I suppose.
..............................
@David: I tried compile on command line too. here is results
C:\Documents and Settings\XPMUser\Desktop\exptest\exptest>oxygene /allowunsafe:y
es /type:library /cputype:x86 clstest.pas
RemObjects Oxygene for .NET - Version 4.0.25.791
Copyright RemObjects Software 2003-2009. All rights reserved.
Exclusively licensed for Delphi Prism.
Preparing resources...
Compiling...
C:\Documents and Settings\XPMUser\Desktop\exptest\exptest\clstest.pas(14,22) :
Error : (PE9) Unknown identifier "UnmanagedExport"
Exiting with 1.
C:\Documents and Settings\XPMUser\Desktop\exptest\exptest>
probably your right. maybe something wrong with my compiler. But i didnt see any error during install Delphi prism.
@Rudy: I was tried VS2010 ide before this. As I Said. Maybe i reinstall delphi prism or try different machine. I'll write results if solve.