DLL Entry point [modified]
-
This is the header of my only function in my dll file and it compiles just fine
public static string SaveName(string strName)
and on the other hand in my class that implements the dll I have this:
\[DllImport("MyBloodyDLL.dll", EntryPoint = "SaveName")\] public static extern string SaveName(string strName);
and when calling the SaveName("string") function later, I get this beautiful exception:
Unable to find an entry point named 'SaveName' in DLL 'MyBloodyDLL.dllPlease help :sigh: ps. I HATE DLLs!!
All generalizations are wrong, including this one! (\ /) (O.o) (><)
modified on Wednesday, April 16, 2008 4:49 PM
-
This is the header of my only function in my dll file and it compiles just fine
public static string SaveName(string strName)
and on the other hand in my class that implements the dll I have this:
\[DllImport("MyBloodyDLL.dll", EntryPoint = "SaveName")\] public static extern string SaveName(string strName);
and when calling the SaveName("string") function later, I get this beautiful exception:
Unable to find an entry point named 'SaveName' in DLL 'MyBloodyDLL.dllPlease help :sigh: ps. I HATE DLLs!!
All generalizations are wrong, including this one! (\ /) (O.o) (><)
modified on Wednesday, April 16, 2008 4:49 PM
strName!=SaveName :confused:
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
strName!=SaveName :confused:
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
Luc Pattyn wrote:
strName!=SaveName
Sorry Luc, I just made a mistake while pasting it, any idea what the problem is?? Thanks for helping mate!
All generalizations are wrong, including this one! (\ /) (O.o) (><)
modified on Wednesday, April 16, 2008 4:54 PM
-
Luc Pattyn wrote:
strName!=SaveName
Sorry Luc, I just made a mistake while pasting it, any idea what the problem is?? Thanks for helping mate!
All generalizations are wrong, including this one! (\ /) (O.o) (><)
modified on Wednesday, April 16, 2008 4:54 PM
Hi Muammar, if your target file is unmanaged C++ (as opposed to C) then the function names would be mangled somehow. You could either try and find out what the rules are, or use good old DUMPBIN to look at the exports of the DLL. BTW: maybe just omitting the EntryPoint stuff solves it (just a guess). :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
This is the header of my only function in my dll file and it compiles just fine
public static string SaveName(string strName)
and on the other hand in my class that implements the dll I have this:
\[DllImport("MyBloodyDLL.dll", EntryPoint = "SaveName")\] public static extern string SaveName(string strName);
and when calling the SaveName("string") function later, I get this beautiful exception:
Unable to find an entry point named 'SaveName' in DLL 'MyBloodyDLL.dllPlease help :sigh: ps. I HATE DLLs!!
All generalizations are wrong, including this one! (\ /) (O.o) (><)
modified on Wednesday, April 16, 2008 4:49 PM
Hi Muammar©, As you mentioned, it seems like the DLL you have is written in C# or .Net somehow, because as much as I know, working with string types is not as easy as C# in C and C++ and the Entry Point you mentioned makes me feel like the library you have is written in C# and in that case: It you want to access the library at design time (coding time) you just need to add it to your project as a reference and use it by adding it's main namespace to your code, using the "using" keyword and then you can easily access the method you like. But if you want to access it at runtime (directly from your compiled code) you need to know about the System.Reflection namespace and much more to use the classes inside it. You can find what you need on MSDN and google. ;) Good luck and have fun.
Sojaner!
-
Hi Muammar, if your target file is unmanaged C++ (as opposed to C) then the function names would be mangled somehow. You could either try and find out what the rules are, or use good old DUMPBIN to look at the exports of the DLL. BTW: maybe just omitting the EntryPoint stuff solves it (just a guess). :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
Hey Luc, Well, both files are written in C# "guess that's why i'm posting this in the C# forum:)"
Luc Pattyn wrote:
maybe just omitting the EntryPoint stuff solves it
While I though adding it would solve the problem :laugh: .. I just added it after the problem has occurred! Anyways, thanks for helping Luc!
All generalizations are wrong, including this one! (\ /) (O.o) (><)
-
Hey Luc, Well, both files are written in C# "guess that's why i'm posting this in the C# forum:)"
Luc Pattyn wrote:
maybe just omitting the EntryPoint stuff solves it
While I though adding it would solve the problem :laugh: .. I just added it after the problem has occurred! Anyways, thanks for helping Luc!
All generalizations are wrong, including this one! (\ /) (O.o) (><)
Hi Muammar, if you have a managed EXE/DLL calling unmanaged code in a DLL, then and only then you need the DllImport and the static external stuff (on the managed side), and you must worry about name mangling if the unmanaged code is C++. if both parts are managed, you don't use DllImport, you don't use external. You just use the type(s) from the DLL as if they are part of your EXE. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.