开发者

Can't see methods in DLL... why?

Can't see methods in DLL... why?

I developed a DLL in C#

When I am trying to call it I get:

System.EntryPointNotFoundException: Unable to find an entry point named:

It means that DLL doens't export any methods visible from DLL. Dumpbin doesn't show any methods either:

dumpbin.exe -exports ActiveXTest.dll Dump of file ActiveXTest.dll File Type: DLL Summary 2000 .reloc 2000 .rsrc 2000 .text

What's wrong????

The DLL looks ok.. according to documentation:

namespace Kosmala.Michal.ActiveXTest
        public static void setHooks()
        {
        ....
        }

Here is how I call it:

namespace IWFHotkeyStarter开发者_开发知识库
{
    class Program
    {
        [DllImport("D:\\work\\iwf\\_ctrl-tab-modless_dlg_testing\\activex\\VSProjects\\AcriveXSourceCode\\bin\\Debug\\ActiveXTest.dll")]
        public extern static void setHooks();
        static void Main(string[] args)
        {
            Program p = new Program();
            p.run();
        }
        private void run(){
            Console.WriteLine("run<<");
            setHooks();
            Console.WriteLine("run>>");    
        }
    }
}

Please help


Your DLL is managed code (written in C#). Classic DLLs like containers of ActiveX controls are unmanaged code and organized in another way.

To use a managed DLL in a managed project, add a reference to it or load it at runtime.


As Mario states, .Net assemblies expose libraries and classes in a different way and so tools like DumpBin won't show anything - if you want to peek inside your assembly then give Reflector a try.

As for how to call your managed assembly, the method you have shown (DllImport) is used for interops / calling unmanaged code. To call a method in another managed assembly all you need to do is add an assembly reference and you should be able to see the method just fine.

Another thing to note that in C# all methods must belong to a class, so your example will probably look more like this:

namespace Kosmala.Michal.ActiveXTest
public class Hooks
{
    public static void setHooks()
    {
    }
}

Using the method:

using namespace Kosmala.Michal.ActiveXTest;
namespace IWFHotkeyStarter
{
    class Program
    {
        // ...
        private void run()
        {
            Hooks.setHooks();
        }
    }
}


If you have an Interface then the setHooks() method you are trying to call make sure it is declared in the interface.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜