Click here to Skip to main content
15,890,527 members
Home / Discussions / COM
   

COM

 
GeneralRe: COM Communication Pin
Mike Dimmick30-Mar-08 12:58
Mike Dimmick30-Mar-08 12:58 
GeneralRe: COM Communication Pin
HakunaMatada30-Mar-08 19:12
HakunaMatada30-Mar-08 19:12 
GeneralBSTR variable Pin
vc++_fragrance24-Mar-08 19:48
vc++_fragrance24-Mar-08 19:48 
GeneralRe: BSTR variable Pin
User 21559725-Mar-08 1:24
User 21559725-Mar-08 1:24 
GeneralRe: BSTR variable Pin
CPallini26-Mar-08 1:07
mveCPallini26-Mar-08 1:07 
GeneralC# class library Pin
pnpfriend24-Mar-08 9:24
pnpfriend24-Mar-08 9:24 
GeneralRe: C# class library Pin
Scott Dorman25-Mar-08 15:37
professionalScott Dorman25-Mar-08 15:37 
GeneralCalling .NET component from VB. [modified] Pin
SPanicker*23-Mar-08 21:38
SPanicker*23-Mar-08 21: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 20:13
Vi23-Apr-08 20:13 
QuestionHow to Rreference COM object(tlb file) in VC++ Pin
Jahnson K21-Mar-08 10:05
Jahnson K21-Mar-08 10:05 
AnswerRe: How to Rreference COM object(tlb file) in VC++ Pin
User 21559722-Mar-08 3:02
User 21559722-Mar-08 3:02 
GeneralRe: How to Rreference COM object(tlb file) in VC++ Pin
Jahnson K22-Mar-08 11:31
Jahnson K22-Mar-08 11:31 
GeneralRe: How to Rreference COM object(tlb file) in VC++ Pin
User 21559723-Mar-08 2:28
User 21559723-Mar-08 2:28 
AnswerRe: How to Rreference COM object(tlb file) in VC++ Pin
pnpfriend24-Mar-08 9:34
pnpfriend24-Mar-08 9:34 
GeneralRe: How to Rreference COM object(tlb file) in VC++ Pin
Jahnson K25-Mar-08 7:35
Jahnson K25-Mar-08 7:35 
GeneralRe: How to Rreference COM object(tlb file) in VC++ Pin
Jahnson K27-Mar-08 13:04
Jahnson K27-Mar-08 13:04 
GeneralRe: How to Rreference COM object(tlb file) in VC++ Pin
Vi23-Apr-08 20:19
Vi23-Apr-08 20:19 
GeneralRe: How to Rreference COM object(tlb file) in VC++ Pin
Jahnson K7-Apr-08 8:19
Jahnson K7-Apr-08 8:19 
AnswerRe: How to Rreference COM object(tlb file) in VC++ Pin
Member 38312474-Apr-08 3:21
Member 38312474-Apr-08 3:21 
GeneralTAPI related Question Pin
ritz123421-Mar-08 0:44
ritz123421-Mar-08 0:44 
GeneralGetting E_ACCESSDENIED when calling IPersistFile:Save Pin
TClarke20-Mar-08 6:08
TClarke20-Mar-08 6:08 
GeneralRe: Getting E_ACCESSDENIED when calling IPersistFile:Save Pin
Nathan Holt at EMOM20-Mar-08 8:43
Nathan Holt at EMOM20-Mar-08 8:43 
GeneralRe: Getting E_ACCESSDENIED when calling IPersistFile:Save Pin
Member 785300318-Apr-11 14:13
Member 785300318-Apr-11 14:13 
Questionwhere is the type library for IDataObject ? Pin
Vlasta_20-Mar-08 1:05
Vlasta_20-Mar-08 1:05 
GeneralRe: where is the type library for IDataObject ? Pin
Nathan Holt at EMOM20-Mar-08 9:42
Nathan Holt at EMOM20-Mar-08 9: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.