473,395 Members | 2,006 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,395 software developers and data experts.

COM interop

Hi all
I am trying to call my C# class library from COM. My C#
library works perfectly in the .NET environment. I have
registered my C# component using regasm and also placed it
in the GAC. But for some reason my VBScript COM component
can't interop with .NET. I am calling my .NET component as
follows.

Set GSF = CreateObject("CSAppName.ClassName")

Can you please tell me what I am missing? Thanks a lot for
your help.
Nov 15 '05 #1
4 1901
Placing your assembly in the GAC won't help a COM client to find the
assembly, COM has no idea what the GAC is.
What you should do instead is to register your assembly using the Codebase
option of regasm.

Willy.

"C# beginner" <an*******@discussions.microsoft.com> wrote in message
news:4c****************************@phx.gbl...
Hi all
I am trying to call my C# class library from COM. My C#
library works perfectly in the .NET environment. I have
registered my C# component using regasm and also placed it
in the GAC. But for some reason my VBScript COM component
can't interop with .NET. I am calling my .NET component as
follows.

Set GSF = CreateObject("CSAppName.ClassName")

Can you please tell me what I am missing? Thanks a lot for
your help.

Nov 15 '05 #2
Thanks Willy. As I mentioned in my previous posting, I
have registered my C# component using regasm and generated
a tlb file. Per your suggestion, I tried using
the /codebase option also. still doesn't work. Any help is
appreciated.
-----Original Message-----
Placing your assembly in the GAC won't help a COM client to find theassembly, COM has no idea what the GAC is.
What you should do instead is to register your assembly using the Codebaseoption of regasm.

Willy.

"C# beginner" <an*******@discussions.microsoft.com> wrote in messagenews:4c****************************@phx.gbl...
Hi all
I am trying to call my C# class library from COM. My C#
library works perfectly in the .NET environment. I have
registered my C# component using regasm and also placed it in the GAC. But for some reason my VBScript COM component can't interop with .NET. I am calling my .NET component as follows.

Set GSF = CreateObject("CSAppName.ClassName")

Can you please tell me what I am missing? Thanks a lot for your help.

.

Nov 15 '05 #3
What error do you get when calling Set o = CreateObject(....)
What attributes did you set on your methods, remember vbscript can only call
methods on objects implementing IDispatch (and dual) interfaces.

Here's a small sample that illustrates the attribute usage...

using System.Runtime.InteropServices;
using System;

// interface definition, dual to be script friendly
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("D3DF5658-3D3F-436b-B6A6-F10E77AE3F5F")] // Use guidgen to obtain
valid GUID's
public interface IDotNetInterface
{
int someMethod();
}

// class
[ClassInterface(ClassInterfaceType.None)]
[ProgId("Test.DotNetInterface")] // progid
public class DotNetInterface : IDotNetInterface
{
public int someMethod()
{
// Implemetation of someMethod, returning an int
return 0;
}
}
Check MSDN for details on InterfaceType and ClassInterface attributes.

The VBScript Client...

Set o = CreateObject("Test.DotNetInterface")
Dim var, ret
ret = o.someMethod()
WScript.Echo ret

Willy.

"C# beginner" <an*******@discussions.microsoft.com> wrote in message
news:52****************************@phx.gbl...
Thanks Willy. As I mentioned in my previous posting, I
have registered my C# component using regasm and generated
a tlb file. Per your suggestion, I tried using
the /codebase option also. still doesn't work. Any help is
appreciated.
-----Original Message-----
Placing your assembly in the GAC won't help a COM client

to find the
assembly, COM has no idea what the GAC is.
What you should do instead is to register your assembly

using the Codebase
option of regasm.

Willy.

"C# beginner" <an*******@discussions.microsoft.com> wrote

in message
news:4c****************************@phx.gbl...
Hi all
I am trying to call my C# class library from COM. My C#
library works perfectly in the .NET environment. I have
registered my C# component using regasm and also placed it in the GAC. But for some reason my VBScript COM component can't interop with .NET. I am calling my .NET component as follows.

Set GSF = CreateObject("CSAppName.ClassName")

Can you please tell me what I am missing? Thanks a lot for your help.

.

Nov 15 '05 #4
Thanks Willy. I think I got it to work. My understanding
is the project references were messed up. Thanks a lot for
your help.
-----Original Message-----
What error do you get when calling Set o = CreateObject (....)What attributes did you set on your methods, remember vbscript can only callmethods on objects implementing IDispatch (and dual) interfaces.
Here's a small sample that illustrates the attribute usage...
using System.Runtime.InteropServices;
using System;

// interface definition, dual to be script friendly
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("D3DF5658-3D3F-436b-B6A6-F10E77AE3F5F")] // Use guidgen to obtainvalid GUID's
public interface IDotNetInterface
{
int someMethod();
}

// class
[ClassInterface(ClassInterfaceType.None)]
[ProgId("Test.DotNetInterface")] // progid
public class DotNetInterface : IDotNetInterface
{
public int someMethod()
{
// Implemetation of someMethod, returning an int
return 0;
}
}
Check MSDN for details on InterfaceType and ClassInterface attributes.
The VBScript Client...

Set o = CreateObject("Test.DotNetInterface")
Dim var, ret
ret = o.someMethod()
WScript.Echo ret

Willy.

"C# beginner" <an*******@discussions.microsoft.com> wrote in messagenews:52****************************@phx.gbl...
Thanks Willy. As I mentioned in my previous posting, I
have registered my C# component using regasm and generated a tlb file. Per your suggestion, I tried using
the /codebase option also. still doesn't work. Any help is appreciated.
-----Original Message-----
Placing your assembly in the GAC won't help a COM client

to find the
assembly, COM has no idea what the GAC is.
What you should do instead is to register your assembly

using the Codebase
option of regasm.

Willy.

"C# beginner" <an*******@discussions.microsoft.com> wrote
in message
news:4c****************************@phx.gbl.. .
Hi all
I am trying to call my C# class library from COM. My
C# library works perfectly in the .NET environment. I have registered my C# component using regasm and also

placed it
in the GAC. But for some reason my VBScript COM

component
can't interop with .NET. I am calling my .NET
component as
follows.

Set GSF = CreateObject("CSAppName.ClassName")

Can you please tell me what I am missing? Thanks a lot

for
your help.
.

.

Nov 15 '05 #5

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

Similar topics

0
by: roy | last post by:
I try to call com written in VB 6.0. When I use VS.net Studio to do the debuging, some time it works fine, some time I got the following message: Server Error in '/GISOnlineReservation'...
0
by: roy | last post by:
I try to call com written in VB 6.0., some time it works fine, some time I got the following message: Server Error in '/GISOnlineReservation' Application....
0
by: keefah | last post by:
Hi, I'm writing a C# web app that uses Outlook to send email. I use a reference to the Microsoft Outlook 11.0 Object Library, but it's giving me problems. I tracked down some stuff on the Net...
0
by: lacour | last post by:
I can't seem to figure out the difference between adding a COM dll reference in VS2003 and by using TLBIMP. I have a COM dll that references another COM dll, and I want the syntax of my...
1
by: Nadav | last post by:
Hi, Introduction *************** I have a system build of a collection of 'Native COM objects' and '.NET COM interop' objects, all of the COM objects are managed through a 'Native COM' layer,...
8
by: Rob Edwards | last post by:
When trying to add the Microsoft CDO for Exchange Management Library (aka CDOEXM.dll) I receive the following message: "A reference to 'Microsoft CDO for Exchange Management Library' could not be...
7
by: R Reyes | last post by:
Can someone please explain to me why I can't get the MS Word Interop assembly to work in my VS2005 project? I'm trying to manipulate MS Word from my Web Form application and I can't get passed...
2
by: JC | last post by:
Anybody knows what problem has this code? I think, in the Garbage Collector? You know the Solution? The program in the test's case, whit 350 contacts, run OK before number 86. The error is a...
1
by: allbelonging | last post by:
C#.Net Outlook 2003 automation (programmatically) with Office.Interop.Outlook Problem: I have my outlook 2003 configured with multiple mailbox on my local machine. I want to specify the mailbox...
0
by: Tina | last post by:
I've gotten this before where it says there is a problem with Interop.MSDASC but I can't remember what causes this. This is a 1.1 app I'm trying to debug in vs2005. It was running yesterday just...
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...
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
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,...
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
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...

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.