简体   繁体   English

C#P /调用嵌入式VB6 DLL资源:ActiveXObject“无法在DLL'DLLName'中找到名为'FunctionName'的入口点。”

[英]C# P/Invoke embedded VB6 DLL resource: ActiveXObject “Unable to find an entry point named 'FunctionName' in DLL 'DLLName'.”

I'm trying to create a C# wrapper DLL for a VB6 DLL, then use that wrapper in a web page as an ActiveXObject, but I'm getting this error when calling ClassTesting(): 我正在尝试为VB6 DLL创建C#包装DLL,然后在网页中将该包装用作ActiveXObject,但是在调用ClassTesting()时遇到此错误:

Unable to find an entry point named 'ClassTest' in DLL 'VB6DLL'. 在DLL“ VB6DLL”中找不到名为“ ClassTest”的入口点。

The application exports the DLL to a temp directory, then loads it into memory. 应用程序将DLL导出到临时目录,然后将其加载到内存中。 The structure of the DLL can be described as: DLL的结构可以描述为:

VB6DLL.dll -> public class "VB6.cls" -> public function "ClassTest()". VB6DLL.dll->公共类“ VB6.cls”->公共函数“ ClassTest()”。

The C# code is as follows: C#代码如下:

namespace SystemDeviceDriver
{
    [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    public interface IDeviceDriver
    {
        [DispId(1)]
        string ClassTesting();
    }

    [Guid("655EE123-0996-4c70-B6BD-7CA8849799C7")]
    [ComSourceInterfaces(typeof(IDeviceDriver))]
    public class DeviceDriver : IDeviceDriver
    {

        [DllImport("kernel32", CharSet = CharSet.Unicode)]
        static extern IntPtr LoadLibrary(string lpFileName);

        [DllImport("VB6DLL", CharSet = CharSet.Unicode)]
        static extern string ClassTest();

        public DeviceDriver()
        {
            //Write the VB6DLL to a temp directory
            string dirName = Path.Combine(Path.GetTempPath(), "SystemDeviceDriver." + Assembly.GetExecutingAssembly().GetName().Version.ToString());
            if (!Directory.Exists(dirName))
            {
                Directory.CreateDirectory(dirName);
            }
            string dllPath = Path.Combine(dirName, "VB6DLL.dll");
            File.WriteAllBytes(dllPath, SystemDeviceDriver.Properties.Resources.VB6DLL);

            //Load the library into memory
            IntPtr h = LoadLibrary(dllPath);
            Debug.Assert(h != IntPtr.Zero, "Unable to load library " + dllPath);
        }

        public string ClassTesting()
        {
            return ClassTest();
        }
    }
}

DllImport / P/Invoke functions are for including "old C style" dll files, so plain simple functions which are exported from a library DllImport / P / Invoke函数用于包含“旧C样式” dll文件,因此可以从库中导出简单的简单函数

here are the calling methods listed, for which function types that is possible: http://msdn.microsoft.com/de-de/library/system.runtime.interopservices.callingconvention.aspx 这是列出的调用方法,可能的功能类型为: http : //msdn.microsoft.com/de-de/library/system.runtime.interopservices.callingconvention.aspx

COM is completely different, see: http://en.wikipedia.org/wiki/Component_Object_Model COM完全不同,请参见: http : //en.wikipedia.org/wiki/Component_Object_Model

the only functions a COM dll typically export are DllRegisterServer, DllUnregisterServer you could first use the P/Invoke functions to call that function. COM dll通常导出的唯一功能是DllRegisterServer,DllUnregisterServer,您可以首先使用P / Invoke函数来调用该函数。 the COM dll file registers itself in the registry. COM dll文件将自己注册到注册表中。 then it should be possible to create a COM object. 那么应该可以创建一个COM对象。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C#P \\ Invoke DLL是否没有C ++的入口点? - C# P\Invoke DLL no entry point into C++? C#EntryPointNotFoundException无法在DLL'kernel32.dll'中找到名为'SetDllDirectory'的入口点 - C# EntryPointNotFoundException Unable to find an entry point named 'SetDllDirectory' in DLL 'kernel32.dll' 在混合 C++ DLL 和 WPF ZD7EFA19FBE24D3972FD745ADB6 项目中找不到名为 xxx 的入口点 - Unable to find an entry point named xxx in mixed C++ DLL and WPF C# project 在DLL'cvextern'中找不到名为''的入口点 - Unable to find an entry point named '' in DLL 'cvextern' “无法在dll中找到名为[function]的入口点”(c++到c#类型转换) - "Unable to find an entry point named [function] in dll" (c++ to c# type conversion) 在DLL'mfplat.dll'中找不到名为'MFCreateMFByteStreamOnStreamEx'的入口点 - Unable to find an entry point named 'MFCreateMFByteStreamOnStreamEx' in DLL 'mfplat.dll' 在DLL'uxtheme.dll'中找不到名为'IsTjemePartDefined'的入口点 - Unable to find an entry point named 'IsTjemePartDefined' in DLL 'uxtheme.dll' 在DLL'WsmSvc.dll'中找不到名为'WSManInitialize'的入口点 - Unable to find an entry point named 'WSManInitialize' in DLL 'WsmSvc.dll' C#中的Fortran dll导致无法找到入口点错误 - Fortran dll in C# gives Unable to find an entry point error '在DLL'OraOps12.dll'中找不到名为'OpsConIsDRCPEnabled'的入口点-Oracle 12c - 'Unable to find an entry point named 'OpsConIsDRCPEnabled' in DLL 'OraOps12.dll' - Oracle 12c
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM