Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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;
}

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();
     }
 }
Posted
Updated 20-Jul-11 8:29am
v2
Comments
Richard MacCutchan 20-Jul-11 13:47pm    
I don't see a definition of IpcbCOMVisibleLibraryPtr anywhere in the above.
Member 8015046 20-Jul-11 13:53pm    
Well I was trying to follow this tutorial
http://support.microsoft.com/kb/828736
Richard MacCutchan 20-Jul-11 14:02pm    
I don't see that definition there either. I think you will have to be more specific with your question if you want to solve this issue. Most people here do not have the time to go and work through obscure tutorials in order to understand posted questions.

1 solution

Your interface class implementation should probably be contained within your namespace.
 
Share this answer
 
v2
Comments
Member 8015046 20-Jul-11 14:30pm    
my interface wasn't public >.< hahahah
Albert Holguin 20-Jul-11 14:31pm    
oh yeah... private interfaces are hard to get to... :D
Espen Harlinn 20-Jul-11 14:42pm    
It got OP thinking along the right lines, my 5
Albert Holguin 20-Jul-11 15:07pm    
not really.. but I'll take it... lol... I haven't mixed code too much myself like this, so it was a bit of a shot in the dark... although soon I may start to do so...
Espen Harlinn 20-Jul-11 15:21pm    
Well, he marked your reply as the answer - so I guessed he was grateful for something, I couldn't come up with any other explanation ... so I made guess :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900