473,408 Members | 2,734 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,408 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 17 '05 #1
1 1513

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 17 '05 #2

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

Similar topics

2
by: Peter Schmitz | last post by:
Hi, I just created a solution that is based on unmanaged C++ code. Now, the .net framework consists of some cool functions and classes - there is especially one namespace I'd like to use....
1
by: Fender Mussel | last post by:
Hi, We are in a situation where we have a Win32 application which is currently deployed to about 15000 desktop machines and want to rewrite the back end (business logic) in a modern language. At...
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);
3
by: Ray | last post by:
I am trying to add calls to managed C++ class from unmanaged C in the same DLL (I saw somewhere while trying to solve something else, that if you have them both in the same DLL that you could...
4
by: JoeZ | last post by:
Hi, Can some one point some samples of calling managed code from unmanaged code. Here is basically what I need: I have an MFC application with several MFC dlls, and I have a new .net...
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...
6
by: William F. Kinsley | last post by:
I am thinking of porting an existing MFC application to MC++ and I have created a simple MFC application to test the environment. My sample MFC application is compilied with the /clr switch. I...
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...
9
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for...
1
by: Arne Adams | last post by:
Hi, I try to use a C# Dialog in a legacy MFC application. The problem seems to boil down to the following: from an unmanaged console application I can call any function of the managed bridge - if...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.