473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Calling C# COM Dll from Managed C

Can you lend a hand?
Newbie here ....trying to call a C# COM object (error is below):

****** C# DLL ********

namespace ECSLink
{
public class ECSInvoke
{
public void PrintString(string strName)
{
System.Console.WriteLine("Hello from COM");
}
}
}

Built via:

csc /target:library /out:ECSLink.dll ECSLink.cs
tlbexp ECSLink.dll /verbose

****** C Code *******

#import "ECSLink.tlb"

int main(int argc, char* argv[])
{
CoInitialize(NULL);
ECSInvokePtr ob;
ob->CreateInstance(__uuidof(ECSInvoke));
ob->PrintString();
return 0;
}

ERROR return from: cl client.cpp.....

client.cpp
client.cpp(6) : error C2065: 'ECSInvokePtr' : undeclared identifier
client.cpp(6) : error C2146: syntax error : missing ';' before identifier
'ob'
client.cpp(6) : error C2065: 'ob' : undeclared identifier
client.cpp(7) : error C2227: left of '->CreateInstance' must point to
class/struct/union
type is ''unknown-type''
client.cpp(7) : error C3861: 'ob': identifier not found, even with
argument-dependent lookup
client.cpp(8) : error C2227: left of '->PrintString' must point to
class/struct/union
type is ''unknown-type''
client.cpp(8) : error C3861: 'ob': identifier not found, even with
argument-dependent lookup


Nov 16 '05 #1
1 1536

On 18 Jun 2004 20:33, "Tim Nelson" wrote:
****** C# DLL ********
<bits snipped for clarity>

public void PrintString(string strName)
****** C Code *******

#import "ECSLink.tlb"
ob->PrintString();
client.cpp
client.cpp(6) : error C2065: 'ECSInvokePtr' : undeclared identifier
client.cpp(6) : error C2146: syntax error : missing ';' before identifier
'ob'
client.cpp(6) : error C2065: 'ob' : undeclared identifier
client.cpp(7) : error C2227: left of '->CreateInstance' must point to
class/struct/union
type is ''unknown-type''
client.cpp(7) : error C3861: 'ob': identifier not found, even with
argument-dependent lookup
client.cpp(8) : error C2227: left of '->PrintString' must point to
class/struct/union
type is ''unknown-type''
client.cpp(8) : error C3861: 'ob': identifier not found, even with
argument-dependent lookup


I'm no C programmer, but you're calling PrintString with no parameters
and it's defined with a string parameter. That makes sense of some of the
error messages?
Simon Smith
simon dot s at ghytred dot com
www.ghytred.com/NewsLook - NNTP Client for Outlook
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: b.bardugo | last post by:
Hi all, I have a C# user control (a little app I made to display video). In this code I am using a third party .dll, which is written in C++ (un-managed). I am tring to put this control on a web...
15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
2
by: Andre | last post by:
Hi, I have a problem with calling a managed C++ function from C#. The function in C++ looks like Class::Func(char* Text) this function is compiled to an DLL and this DLL is referenced in my...
4
by: zlatko | last post by:
Hello. I am new to .net . I have a managed C++ library. It looks like this. // header file namespace cppnetdll { public __gc class Class1 { public: static int foo_int(void);
5
by: Virajitha Sarma | last post by:
Hi, Can u plz help me out with how to call a C# DLL from C... I tried to find out by searching in net..but i couldnot find anything on it.... Thanku Virajitha *** Sent via Developersdex...
1
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code...
1
by: H.B. | last post by:
Hi, I need to make a function that can display data on my Managed C++ app and be called by an unmanaged C++ DLL. Something like : void Form1::Form1_Load(System::Object * sender,...
1
by: MC-Advantica | last post by:
Does anyone have a simple "Hello World" like application that demonstrates unmanaged C++ calling managed C++ developed in VS2005? I'm confused by many posts as they discuss managed extensions from...
3
by: Klaus | last post by:
Hi, I have an existing VC 6 MFC application which communicates asynchronly with a VC 2005 managed code dll. I use an unmanaged base class with virtual functions to access methods in the MFC...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.