473,385 Members | 1,645 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,385 software developers and data experts.

Create a COM Object with C#?

This article describes a way to create a COM object with VB.Net:

http://www.codeguru.com/vb/gen/vb_ge...cle.php/c8269/

I used the instructions under Solution 1 as a guide for creating a component
with C# that could be accessed as a COM object from VB or C++ code developed
under Visual Studio 6.0. After building the project I used regasm to
register the DLL (.Net assembly). Sure enough, that enabled me to add a
reference to the component in VB60. But in the VB Object Browser I cannot
see the Concat method/interface that the object implements. In fact, I
cannot see any methods or properties. What am I missing here? I really
need to be able to write some C# code that is accessible from code that is
purely .Net ignorant. I'm assuming a COM interface is my best option for
accomplishing this but am open to other/better suggestions.

--
Craig
Nov 16 '05 #1
5 7923
In fact, I cannot see any methods or properties. What am I missing here?


See if this helps: http://www.dotnetinterop.com/faq/?q=ClassInterface

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2
Thanks, that definitely got me going in the right direction. I am trying to
build the "COM Interop Part 2 Sample" from:

http://msdn.microsoft.com/library/en...ertutorial.asp

Actually, building it and registering it with regasm works fine. I can add
a reference to this COM server in the VB 6.0 IDE. From the VB Object
Browser I can see the PrintHi() method in the IManagedInterface class. But
this line of VB 6.0 code:

Set myObj = New CSharpServer.InterfaceImplementation

gets this error message during the VB compile:

"Run-time error 80070002. File or assembly name CSharpServer, or one of
its dependencies was not found."

Surely I am almost there. What's the last step?

Craig

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
In fact, I cannot see any methods or properties. What am I missing here?


See if this helps: http://www.dotnetinterop.com/faq/?q=ClassInterface

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 16 '05 #3
>gets this error message during the VB compile:

"Run-time error 80070002. File or assembly name CSharpServer, or one of
its dependencies was not found."

Surely I am almost there. What's the last step?


The assembly must be located in a place where the runtime can find it.
In practice this means either install it into the GAC, in the native
application directory (the VB directory while running in the VB6 IDE)
or be registered with Regasm's /codebase switch.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #4
Ok, I have this working well enough now that I can invoke my C#-sourced COM
object from VB 6.0. Now, I want to be able to do CoCreateInstance() and
QueryInterface() from VS 6.0 C++. Is there a tool that will produce C++
source code that maps the interface so I can instantiate the object, get a
pointer to the interface (which will soon be just one of several exposed by
the object) and invoke methods from VS 6.0 C++? I'm pretty lame when it
comes to COM and .Net but I think I'm asking how to accomplish early binding
in my VS 6.0 C++ code.

Craig

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
gets this error message during the VB compile:

"Run-time error 80070002. File or assembly name CSharpServer, or one ofits dependencies was not found."

Surely I am almost there. What's the last step?


The assembly must be located in a place where the runtime can find it.
In practice this means either install it into the GAC, in the native
application directory (the VB directory while running in the VB6 IDE)
or be registered with Regasm's /codebase switch.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 16 '05 #5
Is there a tool that will produce C++
source code that maps the interface so I can instantiate the object, get a
pointer to the interface (which will soon be just one of several exposed by
the object) and invoke methods from VS 6.0 C++? I'm pretty lame when it
comes to COM and .Net but I think I'm asking how to accomplish early binding
in my VS 6.0 C++ code.


Tlbexp.exe (or Regasm.exe with its /tlb switch) can produce a type
library, which you then can use with the C++ #import preprocessor
directive.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #6

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

Similar topics

2
by: brazilnut52 | last post by:
I am going to outline the steps I go through to produce the problem. Hopefully this will help you understand the problem better I have created a simple COM DLL in .NET by using the COM class...
9
by: jon wayne | last post by:
OK! I had this nagging doubt Consider (without worrying abt access specifiers) class Kid : public Parent{...}; Parent::someFunc() { Kid k; }
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
2
by: Just D. | last post by:
All, Do we have a simple way to Create an object on the fly knowing just an object type? The usual design-time way is to write a code something like this: CObjectType obj = new CObjectType();...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
27
by: max | last post by:
Hello, I am a newbye, and I'm trying to write a simple application. I have five tables with three columns; all tables are identical; I need to change some data in the first table and let VB...
2
by: Big Charles | last post by:
Hello, I would like to create an array-class to be able to call like: Dim oMyCar as New MyCar ' After initializing oMyCar, the object has to be like: oMyCar(0).Brand...
10
by: SM | last post by:
Hello I'm trying to create a multi dimensional array in JavaScript, but after some reading i still can't figure out how to apply it to my model. Here it is: I have a list A and for each item...
1
by: Dave | last post by:
I have multiple forms that will create an object. Basically a energy efficiency measure object. The measure object will have a couple of required properties set but after that it can have 10-20...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.