473,657 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(str ing strName)
{
System.Console. WriteLine("Hell o from COM");
}
}
}

Built via:

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

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

#import "ECSLink.tl b"

int main(int argc, char* argv[])
{
CoInitialize(NU LL);
ECSInvokePtr ob;
ob->CreateInstance (__uuidof(ECSIn voke));
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 1539

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

public void PrintString(str ing strName)
****** C Code *******

#import "ECSLink.tl b"
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
408
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 page and somehow the managed code is working OK but when it arrives the part of the code where it is calling the un-managed .dll it gets an exception (it can't find the dll). Is it a security problem? if it is what do I do to solve it? Is it a...
15
11760
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 performs the query is contained in a delegate function that I execute via a second thread. On 1 or 2 of the 600+ servers the query hangs. I've tried to use Thread.Join() coupled with a Thread.Abort() but this does not kill the thread. Based on...
2
1756
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 C# project and I can see that I could call this function like Func(sbyte* ).
4
4353
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
1772
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 http://www.developersdex.com ***
1
2899
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 written in C#. When the app calls my unmanaged functions, they work fine. But as soon as my unmanaged functions call managed functions (in the same source file!), the app reports an "unknown exception" error.
1
2597
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, System::EventArgs * e) { MyDLLInit(MyAppDisplayFunction); }
1
3434
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 VS2003, and related techniques. I have found managed to unmanaged technique very easy in VS2005, but have not been able to build anything with unmanaged to managed calls. I have legacy (unmanaged C++) that would like to leverage the .NET...
3
4702
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 application. Furthermore, I use a pointer to an unmanaged function to jump back into the managed dll. The managed part is basically a remoting enhancement which asynchronly
7
2677
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 name based on the name of the VB6 application. A second choice would be a file name based on the # COM interface assembly. I have tried calling Assembly.GetCallingAssembly() but this fails when I use the VB6 client. Is there a way to get this...
0
8413
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8740
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7352
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.