Dll - Export Function - EntryPointNotFoundException

J

Jeffrey Walton

Hi All,

Sorry about dropping thish on M.P.D.L.CSharp. There is no M.P.D.L.VC.
So I hope someone has come across the issue...

How does one export a function (not a class) in a managed Dll?

I'm catching a System.EntryPointNotFoundException. dumpbin confirms
that the Dll is not exporting the function.

Does not work:
* declaring method as public: error C2059: syntax error : 'public'
* __declspec( dllexport ): incompatible with /clr and /clr:pur
* .def file: fatal link error LNK1310: Exports not supported for pure
MSIL image

Thanks,
Jeff

////////////////////////
// Test Header
bool Test( array<byte>^ );

////////////////////////
// Test Implementation
bool Test( array<byte>^ a ) {...}
 
I

Ignacio Machin ( .NET/ C# MVP )

Hi All,

Sorry about dropping thish on M.P.D.L.CSharp. There is no M.P.D.L.VC.
So I hope someone has come across the issue...

How does one export a function (not a class) in a managed Dll?

You cannot do it AFAIK
A managed dll export only types.
You can create a wrap and then you get a CCW (COM Callable Wrapper).
but even that is a COM DLL, not a win32 one.
The only solution I see is for you to create your .NET dll, export it
as CCW and then create a native dll that instantiate the COM and allow
a call to the method you need as a function
 
J

Jeffrey Walton

Hi Ignacio,
You cannot do it AFAIK
Is that a 'you cannot' because Microsoft tools don't do it?

I asked Pavel the same. The reason I ask is that I have an
experimental linker. While developing it, I picked up a lot of PE
format knowledge. So it may be a question of finding the right tool
for the job. Naively, I'm going to say that adding a Export directory
to the PE and a thunk in the .text section is quite doable.

Jeff
 
P

Pavel Minaev

Hi Ignacio,


Is that a 'you cannot' because Microsoft tools don't do it?

I asked Pavel the same. The reason I ask is that I have an
experimental linker. While developing it, I picked up a lot of PE
format knowledge. So it may be a question of finding the right tool
for the job. Naively, I'm going to say that adding a Export directory
to the PE and a thunk in the .text section is quite doable.

You can probably do it, but that wouldn't be a pure managed assembly
anymore (similarly to what C++/CLR produces). At any rate, it wouldn't
be any different from just having a separate unmanaged assembly
redirecting calls to a managed one.
 
J

Jeffrey Walton

Hi Pavel,

{SNIP]
The reason I ask is that I have an
experimental linker. While developing it, I picked up a lot of PE
format knowledge. So it may be a question of finding the right tool
for the job. Naively, I'm going to say that adding a Export directory
to the PE and a thunk in the .text section is quite doable.

You can probably do it, but that wouldn't be a pure managed assembly
anymore (similarly to what C++/CLR produces). At any rate, it wouldn't
be any different from just having a separate unmanaged assembly
redirecting calls to a managed one.
I think in the end that though possible, I believe it will create more
problems then it solves. My need was to keep a consistent interface
(from an unmanaged Dll) when wrapping an AES crpyo engine. When I ran
the managed AES benchmarks, AesCryptoServiceProvider performed like a
turd.

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top