IpcbCOMVisibleLibraryPtr

IpcbCOMVisibleLibraryPtr

本文介绍了C ++帮助.接口指针.错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码

I have the following code

#include "stdafx.h"
#include "tchar.h"
#include <cstdio>
// Import the type library.
#import "C:\Users\sl9400\Documents\Visual Studio 2010\Projects\ProgramCommunicationBridge\CnsServiceLibrary\bin\Debug\CnsServiceLibrary.tlb" raw_interfaces_only
using namespace CnsServiceLibrary;
int _tmain(int argc, _TCHAR* argv[])
{
    // Initialize COM.
    HRESULT hr = CoInitialize(NULL);
    IpcbCOMVisibleLibraryPtr pITest(__uuidof(pcbCOMVisibleLibrary));
	bool lResult = false;
	pITest->Post("testingC", "testingC", lResult);
	wprintf(L"The result is %d\n", lResult);
    // Uninitialize COM.
    CoUninitialize();
	std::getchar();
    return 0;
}


由于某些原因,IpcbCOMVisibleLibraryPtr表示未定义.

这是我在C#中的界面


for some reason IpcbCOMVisibleLibraryPtr says it is undefined.

Here is my interface in C#

namespace CnsServiceLibrary
{
    [ComVisible(true)]
    interface IpcbCOMVisibleLibrary
    {
        Boolean Post(string name, string message);
        string Read(string name);
        void Initialize(string name);
        void ResetAllInfo();
    }
}


这是我上课的实现.


Here is my implementation of my class.

[ComVisible(true)]
public class pcbCOMVisibleLibrary : IpcbCOMVisibleLibrary
 {
     public string URL
     {
         get
         {
             return cnsSvc.Url;
         }
         set
         {
             cnsSvc.Url = value;
         }
     }
     public CnsService.Service1 cnsSvc = new CnsService.Service1();

     //Default Constructor;
     public pcbCOMVisibleLibrary()
     {
         this.URL = Properties.Settings.Default.CnsServiceLibrary_CnsService_Service1;
     }

     public Boolean Post(string name, string message)
     {
         return cnsSvc.Post(name, message);
     }

     public string Read(string name)
     {
         return cnsSvc.Read(name);
     }
     public void Initialize(string name)
     {
         cnsSvc.Initialize(name);
     }
     public void ResetAllInfo()
     {
         cnsSvc.ResetAllInfo();
     }
 }

推荐答案


这篇关于C ++帮助.接口指针.错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 21:36