471,616 Members | 1,849 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,616 software developers and data experts.

Dll - Export Function - EntryPointNotFoundException

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 ) {...}
Aug 5 '08 #1
6 3396
On Aug 5, 3:59 pm, Jeffrey Walton <noloa...@gmail.comwrote:
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

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 ) {...}
Aug 5 '08 #2
On Aug 5, 11:59*pm, Jeffrey Walton <noloa...@gmail.comwrote:
Hi All,

Sorry about dropping thish on M.P.D.L.CSharp. There is no M.P.D.L.VC.
There is, microsoft.public.dotnet.languages.vc:

http://groups.google.com/group/micro...ages.vc/topics
How does one export a function (not a class) in a managed Dll?
You can't.
Aug 6 '08 #3
Hi Pavel,
There is, microsoft.public.dotnet.languages.vc:
Thanks. When I looked yesterday, Google did not return it. Odd???
You can't.
Is that a 'you can't' because Microsoft tools do not do it?

Jeff

On Aug 6, 6:38*am, Pavel Minaev <int...@gmail.comwrote:
On Aug 5, 11:59*pm, Jeffrey Walton <noloa...@gmail.comwrote:
Hi All,
Sorry about dropping thish on M.P.D.L.CSharp. There is no M.P.D.L.VC.

There is, microsoft.public.dotnet.languages.vc:

http://groups.google.com/group/micro...languages.vc/t...
How does one export a function (not a class) in a managed Dll?

You can't.
Aug 6 '08 #4
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

On Aug 5, 4:43*pm, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac...@gmail.comwrote:
On Aug 5, 3:59 pm, Jeffrey Walton <noloa...@gmail.comwrote:
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
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 ) {...}- Hide quoted text -

- Show quoted text -
Aug 6 '08 #5
On Aug 6, 6:26*pm, Jeffrey Walton <noloa...@gmail.comwrote:
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.
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.
Aug 11 '08 #6
Hi Pavel,

On Aug 11, 5:22*am, Pavel Minaev <int...@gmail.comwrote:
On Aug 6, 6:26*pm, Jeffrey Walton <noloa...@gmail.comwrote:
{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
Aug 11 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Shawn Mehaffie | last post: by
205 posts views Thread by Jeremy Siek | last post: by
1 post views Thread by Thomas Johansen | last post: by
reply views Thread by Shawn Mehaffie | last post: by
1 post views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.