DLL似乎并没有被读取,为什么呢?并没有、什么呢、DLL

2023-09-06 17:02:09 作者:Tomfaryiu_

我创建一个应用程序的形式来查看/从一个叫的InTouch软件更改标签。

我添加的DLL作为参考,我想使用读(字符串标记名)FCT的IOM.InTouchDataAccess。 VS没有看到FCT时,请阅读我写的 InTouchWrapper TagType =新的read()。它只能看到InTouchWrapper正如我在code这给我的错误 IOM.InTouchDataAccess.InTouchWrapper'不包含一个构造函数0的论点写

我不明白为什么会这样。我运行InTouch软件编码的同时,也许有与软件的访问冲突。

我的code

 使用系统;
使用System.Collections.Generic;
使用System.ComponentModel;
使用System.Data这;
使用System.Drawing中;
使用System.Linq的;
使用System.Text;
使用System.Windows.Forms的;
使用IOM.InTouchDataAccess;

命名空间TagBrowser
{
    公共部分类TagBrowser:表
    {
        公共TagBrowser()
        {
            的InitializeComponent();
        }

        私人无效TagBrowser_Load(对象发件人,EventArgs的)
        {
        }

        私人无效TagBox_TextChanged(对象发件人,EventArgs的)
        {
        }

        私人无效TypeBox_SelectedIndexChanged(对象发件人,EventArgs的)
        {
            InTouchWrapper TagType =新InTouchWrapper();
        }
 

的DLL

 使用系统;
使用System.Collections.Generic;
使用System.Text;
使用NDde.Client;

命名空间IOM.InTouchDataAccess
{
    公共类InTouchDdeWrapper:IDisposable的
    {
        私人诠释DDE_TIMEOUT = 60000;

        私人DdeClient _ddeClient;

        公共InTouchDdeWrapper()
        {
            _ddeClient =新DdeClient(查看,标记名);
        }

        〜InTouchDdeWrapper()
        {
            的Dispose();
        }

        公共无效初始化()
        {
            _ddeClient.Connect();
        }

        公共字符串读(字符串标记名)
        {
            返回_ddeClient.Request(标记名DDE_TIMEOUT).Replace(\ 0,);
        }
 
0x102e14cf msvcr100d.dll 处有未经处理的异常 0xC0000005 读取位置 0x00000061 时发生访问冲突

解决方案

我在这里把这个情况下别人会得到同样的问题:的

  

您确定这是你引用正确的DLL?尝试打开   确切的被引用的DLL的反编译器( JustDecompile 的免费的,   反射或的 dotPeek 的免费的),看看它是code您   期待的。

I am creating a application form to view/change a tag from a software called InTouch.

I added the dll as a reference and I would like to use the Read(string tagName) fct in the IOM.InTouchDataAccess. VS does not see the fct Read when I write InTouchWrapper TagType = new read(). It only sees InTouchWrapper as I wrote in the code which gives me the error IOM.InTouchDataAccess.InTouchWrapper' does not contain a constructor that takes 0 arguments

I don't understand why is this happening. I am running the InTouch software while coding, maybe there is an access conflict with the software.

MyCode

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using IOM.InTouchDataAccess;

namespace TagBrowser
{
    public partial class TagBrowser : Form
    {
        public TagBrowser()
        {
            InitializeComponent();
        }

        private void TagBrowser_Load(object sender, EventArgs e)
        {
        }

        private void TagBox_TextChanged(object sender, EventArgs e)
        {
        }

        private void TypeBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            InTouchWrapper TagType = new InTouchWrapper();
        }

The dll

using System;
using System.Collections.Generic;
using System.Text;
using NDde.Client;

namespace IOM.InTouchDataAccess
{
    public class InTouchDdeWrapper : IDisposable
    {
        private int DDE_TIMEOUT = 60000;

        private DdeClient _ddeClient;

        public InTouchDdeWrapper()
        {
            _ddeClient = new DdeClient("View", "Tagname");
        }

        ~InTouchDdeWrapper()
        {
            Dispose();
        }

        public void Initialize()
        {
            _ddeClient.Connect();
        }

        public string Read(string tagName)
        {
            return _ddeClient.Request(tagName, DDE_TIMEOUT).Replace("\0", "");
        }

解决方案

I'm putting this here in case somebody else would get the same problem:

Are you sure it's the correct dll you referenced? Try to open the exact referenced dll in a decompiler (JustDecompile free, Reflector or dotPeek free) and see if it's the code you expect.