1

リモートサーバーに接続してデータなどを読み取るOPCクライアントを作成しています.advosolのBGServerクラスを使用しています。問題は、Visual Studio でプログラムを実行すると、グループの追加時に次のエラーが発生することです。

「HRESULT からの例外: 0x80040202」

私の問題は (http://stackoverflow.com/questions/5978721/opc-server-access-remotely-using-opcda-net-tools) に似ていますが、DCom 設定が正しく構成されていることはわかっています。 .exe をダブルクリックして同じコードに接続し、問題なくグループを追加できます。

したがって、ビジュアルスタジオが奇妙なユーザー/グループの下で実行されており、dcom 権限を台無しにしていると推測しています (主にコールバックを使用)。

編集:コード

BGServer server;
    private void Form1_Load(object sender, EventArgs e)
    {
        server = new BGServer(this);
        server.Connect(new OPC.Common.Host() { HostName = "xp-devbox2", UserName = "OPCUser", Password = "OPCUser" }, "FactoryTalk Gateway", null, ServerConnected); 
    }
    void ServerConnected(BGException ex, object tag)
    {
        if (ex != null)
        {
            label1.Text = ex.Message;
        }
        else
        {
            //we've connected to the server.  let's start subscribing to stuff!
            server.AddGroup("Tuner DataGroup", true, 1000, 0, null, null, new OnBGSrvAddGroup(GroupAdded));
        }
    }
    private BGGroup dGroup;
    void GroupAdded(BGException ex, BGGroup group, object tag)
    {

        if (ex != null)
        {
            label1.Text = ex.Message;
        }
        else label1.Text = "Group Added";
    }
4

1 に答える 1

0

OPC との通信に reg-free COM を使用していますか? "Visual Studio Hosting Process" を使用する場合、do reg-free COM を作成する外部 ".exe.manifest" ファイルは、vshost.exe プロセスのマニフェストに取り込まれません。

于 2011-08-17T21:28:35.100 に答える