Click here to Skip to main content
15,848,157 members
Home / Discussions / COM
   

COM

 
GeneralRe: COM Communication Pin
Mike Dimmick30-Mar-08 13:58
Mike Dimmick30-Mar-08 13:58 
GeneralRe: COM Communication Pin
HakunaMatada30-Mar-08 20:12
HakunaMatada30-Mar-08 20:12 
GeneralBSTR variable Pin
vc++_fragrance24-Mar-08 20:48
vc++_fragrance24-Mar-08 20:48 
GeneralRe: BSTR variable Pin
User 21559725-Mar-08 2:24
User 21559725-Mar-08 2:24 
GeneralRe: BSTR variable Pin
CPallini26-Mar-08 2:07
mveCPallini26-Mar-08 2:07 
GeneralC# class library Pin
pnpfriend24-Mar-08 10:24
pnpfriend24-Mar-08 10:24 
GeneralRe: C# class library Pin
Scott Dorman25-Mar-08 16:37
professionalScott Dorman25-Mar-08 16:37 
GeneralCalling .NET component from VB. [modified] Pin
SPanicker*23-Mar-08 22:38
SPanicker*23-Mar-08 22:38 
I am trying to work out a simple COM/.NET interop code. In my project in VB, I have created a simple windows application to add two numbers. The functionality of adding is done through the help of a .NET DLL written in C#. I am quite confused by trying various ideas sugggested by people. Can anyone clarify this simply in a step by step fashion?

This my VB code:

Private Declare Function method Lib "C:\Documents and Settings\CSfiles\interop\interop\bin\Debug\interop.dll" Alias "interopdll" (ByVal X As Integer, ByVal X As Integer)

Private Sub Command1_Click()

Dim a As Integer
Dim obj As Object

obj = New sample ' I get a compile-time error for undefined user type here.

a = obj.method(CInt(Text1.Text), CInt(Text2.Text))
Label1.Caption = CStr(a)

End Sub

My C#(.NET DLL) Code:

using System;
using System.Runtime.InteropServices;
using System.Reflection;

[assembly: ComVisible(true)]
namespace interop
{
/// <summary>
/// Summary description for Class1.
/// </summary>

[ClassInterface(ClassInterfaceType.AutoDual)]

[GuidAttribute("6CE9C732-CD90-4042-A5F0-CF71DFAC2598")]

class sample
{
public sample()
{
}
public int c;

public void method(int a, int b)
{
c = a+b;
//return c;
}
}
}

In this I have registerd the DLL with /codebase switch while using regasm.exe too.

Regards,
Lenus.

modified on Monday, March 24, 2008 3:49 AM

GeneralRe: Calling .NET component from VB. Pin
Vi23-Apr-08 21:13
Vi23-Apr-08 21:13 
QuestionHow to Rreference COM object(tlb file) in VC++ Pin
Jahnson K21-Mar-08 11:05
Jahnson K21-Mar-08 11:05 
AnswerRe: How to Rreference COM object(tlb file) in VC++ Pin
User 21559722-Mar-08 4:02
User 21559722-Mar-08 4:02 
GeneralRe: How to Rreference COM object(tlb file) in VC++ Pin
Jahnson K22-Mar-08 12:31
Jahnson K22-Mar-08 12:31 
GeneralRe: How to Rreference COM object(tlb file) in VC++ Pin
User 21559723-Mar-08 3:28
User 21559723-Mar-08 3:28 
AnswerRe: How to Rreference COM object(tlb file) in VC++ Pin
pnpfriend24-Mar-08 10:34
pnpfriend24-Mar-08 10:34 
GeneralRe: How to Rreference COM object(tlb file) in VC++ Pin
Jahnson K25-Mar-08 8:35
Jahnson K25-Mar-08 8:35 
GeneralRe: How to Rreference COM object(tlb file) in VC++ Pin
Jahnson K27-Mar-08 14:04
Jahnson K27-Mar-08 14:04 
GeneralRe: How to Rreference COM object(tlb file) in VC++ Pin
Vi23-Apr-08 21:19
Vi23-Apr-08 21:19 
GeneralRe: How to Rreference COM object(tlb file) in VC++ Pin
Jahnson K7-Apr-08 9:19
Jahnson K7-Apr-08 9:19 
AnswerRe: How to Rreference COM object(tlb file) in VC++ Pin
Member 38312474-Apr-08 4:21
Member 38312474-Apr-08 4:21 
GeneralTAPI related Question Pin
ritz123421-Mar-08 1:44
ritz123421-Mar-08 1:44 
GeneralGetting E_ACCESSDENIED when calling IPersistFile:Save Pin
TClarke20-Mar-08 7:08
TClarke20-Mar-08 7:08 
GeneralRe: Getting E_ACCESSDENIED when calling IPersistFile:Save Pin
Nathan Holt at EMOM20-Mar-08 9:43
Nathan Holt at EMOM20-Mar-08 9:43 
GeneralRe: Getting E_ACCESSDENIED when calling IPersistFile:Save Pin
Member 785300318-Apr-11 15:13
Member 785300318-Apr-11 15:13 
Questionwhere is the type library for IDataObject ? Pin
Vlasta_20-Mar-08 2:05
Vlasta_20-Mar-08 2:05 
GeneralRe: where is the type library for IDataObject ? Pin
Nathan Holt at EMOM20-Mar-08 10:42
Nathan Holt at EMOM20-Mar-08 10:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.