简体   繁体   English

如何使用.Net Core 从 Elipse 服务器检索数据? 我是否受限于 .NET 框架以使用 DLL?

[英]How to retrieve data from Elipse server with .Net Core? Am I restrained to .NET Framework for using a DLL?

I have an Elipse E3 Studio (build 5.0.434) server with a bunch of tags (running on a x64 windows) and I want to read then from a.NetCore (3.0) console application (same machine).我有一个带有一堆标签的 Elipse E3 Studio(构建 5.0.434)服务器(在 x64 窗口上运行),然后我想从.NetCore(3.0)控制台应用程序(同一台机器)中读取。 The thing is Elipse works with COM (as far as I know) and.NetCore can 't natively handle it.问题是 Elipse 可与 COM (据我所知)一起使用,而.NetCore 本身无法处理它。 Gotta use some Interoperability Library or something.必须使用一些互操作性库或其他东西。 .netCore3.0 Release Notes at Windows Native Interop Windows Native Interop 上的 .netCore3.0 发行说明

To make the Elipse server work I used a hardkey so the server was running locally.为了使 Elipse 服务器正常工作,我使用了硬键,因此服务器在本地运行。 I have named my tag "A1" and set the value inside Elipse.我已将标签命名为“A1”并在 Elipse 中设置值。 To make the access I made a C# program using e3DataAccessLib and referenced it on the.csprj.为了进行访问,我使用 e3DataAccessLib 制作了一个 C# 程序,并在.csprj 上引用了它。 The Program.cs is as follows: Program.cs 如下:

using System;
using E3DATAACCESSLib; 


namespace ElipseNetCore{
    class Program{
        static void Main(string[] args){
            try{
                E3DataAccessManager e3DA = new E3DataAccessManager();
                e3DA.Server = "localhost"; //kinda pointless but still
                object Value = new object();
                object Timestamp = new object();
                object Quality = new object();
                e3DA.ReadValue("A1.Value", ref Timestamp, ref Quality, ref Value); //ReadValue is a Elipse Server method that takes in a "tag" and place the result in the ref's
                Console.WriteLine($"Value:  {Value}, Timestamp: {Timestamp} and Quality: {Quality}");
            }//end try
            catch(Exception ex){
                Console.WriteLine("the mother funking error now is :" +ex.ToString());
//regsvr32 C:\Users\lucas.battistella\Documents\Desenvolvimento\ElipseNetCore\ElipseNetCore\obj\Release\netcoreapp2.2\win-x64\ElipseNetCore.dll
            }//end catch try
        }//end Main
    }//end Program
}//end namespace

The Error I get is the following:我得到的错误如下:

System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {80327130-FFDB-4506-B160-B9F8DB32DFB2} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {80327130-FFDB-4506-B160-B9F8DB32DFB2} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG ))。

Other answers point to a x32 on a x64 or vice-versa issue.其他答案指向 x64 上的 x32,反之亦然。 However I've already tried making sure everything is running on x64.但是我已经尝试过确保一切都在 x64 上运行。 Then I tried everything on x32/x86.然后我在 x32/x86 上尝试了一切。 Also tried manually registering the.dll with regsvr32 (as show in the commented out line in the first code block and also the E3DATAACESSLib.dll), got and error popup saying "the said dll was loaded but the entry point DllRegisterServer was not located. Verify if the said dll is a DLL or OCX file"还尝试使用 regsvr32 手动注册.dll(如第一个代码块中的注释行以及 E3DATAACESSLib.dll 中所示),得到并弹出错误消息“所述 dll 已加载,但未找到入口点 DllRegisterServer。验证上述 dll 是 DLL 还是 OCX 文件”

I've been entangled with this problem for a few days now and since I'm new to all this I don't even know if I'm tumbling in the right direction.我已经纠结这个问题好几天了,因为我对这一切都很陌生,所以我什至不知道我是否朝着正确的方向翻滚。 I would really appreciate any explanation and please excuse my typos.我真的很感激任何解释,请原谅我的错别字。

How do I retrieve data from an Elipse server?如何从 Elipse 服务器检索数据? Have I missed something?我错过了什么吗?

UPDATE: I have tried that exact same code on Visual Studio running on.Net Framework 4.7.2 and it worked.更新:我已经在.Net Framework 4.7.2 上运行的 Visual Studio 上尝试了完全相同的代码并且它有效。 Also tried (still on Visual Studio) on.NetCore and got the aforementioned error.还在.NetCore 上尝试过(仍在 Visual Studio 上)并得到上述错误。

Work Around: Forget about NetCore and migrate to NetFramework 4.8.解决方法:忘记 NetCore 并迁移到 NetFramework 4.8。 Forget about VSCode and keep rolling with VS.忘记 VSCode,继续使用 VS。 Every time I look back at this problem it intrigues me.每当我回顾这个问题时,它都会引起我的兴趣。 The E3DATAACCESSLib was build against x32 and for NetFramework (which mean Windows necessarily). E3DATAACCESSLib 是针对 x32 和 NetFramework 构建的(这意味着 Windows 必然)。 The weird bit is that it ran on my machine targeting x86 (VS and NetFramework 4.8) but not on VSCode and NetCore.奇怪的是它在我的机器上运行,目标是 x86(VS 和 NetFramework 4.8),但不在 VSCode 和 NetCore 上。 I read conflicting information on libraries built for NetFramework working (or not) on Core.我阅读了有关为 NetFramework 在 Core 上工作(或不工作)构建的库的冲突信息。 Today I tried running the built working code on a different machine (virtual and remote) and it showed me the exact same error message.今天我尝试在另一台机器(虚拟机和远程)上运行构建的工作代码,它向我显示了完全相同的错误消息。 And I fixed it by installing the E3 program and restarting the machine, simple as that.我通过安装 E3 程序并重新启动机器来修复它,就这么简单。 If that ring any bell to you please share the light.如果那敲响了你的钟声,请分享光。

暂无
暂无

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

相关问题 如何使用.NET Framework将数据添加到SQL Server中另一个表的列中? - How do I add data to column from another table in a SQL Server using .NET Framework? 使用来自 .net 框架的外部依赖项引用 .net 核心 dll - Referencing .net Core dll with external dependencies from .net Framework 在 .NET core 2.0 中引用 .NET framework 4 dll - referencing .NET framework 4 dll in .NET core 2.0 如何使用 .NET Core ZDB974238714CA8DE6434A7CE1DZ08A 调用从 .net 核心控制台应用程序创建的 dll - How to call a dll created from .net core console app using .NET Core API 如何在与Entity Framework连接并使用dapper的asp.net mvc中插入和检索地理数据? - How do I insert and retrieve geography data in asp.net mvc connected with Entity Framework and using dapper? 如何使用.net-core和Entity Framework Core和Identity从thenInclude中获取特定列? - How do i get specific columns from a thenInclude using .net-core and Entity Framework Core and Identity? 使用 .net core Entity Framework 从 JSON 创建嵌套数据 - Create nested data from JSON using .net core Entity Framework 如何在 .Net Core 中使用 Grpc 检索流结果? - How do I retrieve streaming results using Grpc in .Net Core? 我可以从 .NET 6 项目中添加对 .NET 框架 DLL 的引用吗? - Can I add a reference to a .NET Framework DLL from a .NET 6 project? 如何使用 Entity Framework .NET Core 将数据插入到我的数据库中? - How do I insert data into my database using Entity Framework .NET Core?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM