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

using C# DLL in VB6

Hi,

I am creating a DLL in c# and then trying to use it in VB6
and its failing.

Steps i did are :

1. code
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace MyCalculator
{
public interface Calc
{
int addnum(int aa, int bb);
}

public class CalculatorCLS : Calc
{
public CalculatorCLS()
{
}

public int addnum(int aa, int bb)
{
return aa+bb;
}
}
}

2. compiled with Register with COm interop property as
true.

3. got TLB File.

4. In VB added reference to MyCalculator.tlb file.

5. Dim aa As MyCalculator.Calc
Dim cc As Integer
aa = New MyCalculator.CalculatorCLS
cc = aa.addnum(34, 45)

I get error

"File or Assembly Name MyCalculator, or one of its
dependencies, was not found."

Where I am doing wrong?

Thanks
Sutapa
Nov 15 '05 #1
3 16266

"Sutapa" <s_******@yahoo.com> wrote in message
news:16****************************@phx.gbl...
Hi,

I am creating a DLL in c# and then trying to use it in VB6
and its failing.

Steps i did are :

1. code
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace MyCalculator
{
public interface Calc
{
int addnum(int aa, int bb);
}

public class CalculatorCLS : Calc
{
public CalculatorCLS()
{
}

public int addnum(int aa, int bb)
{
return aa+bb;
}
}
}

2. compiled with Register with COm interop property as
true.

3. got TLB File.

4. In VB added reference to MyCalculator.tlb file.

5. Dim aa As MyCalculator.Calc
Dim cc As Integer
aa = New MyCalculator.CalculatorCLS
cc = aa.addnum(34, 45)

I get error

"File or Assembly Name MyCalculator, or one of its
dependencies, was not found."


MyCalculator.dll needs to be in the current directory, the GAC or registered
with the /codebase option.

David
Nov 15 '05 #2

"Sutapa" <s_******@yahoo.com> wrote in message
news:17****************************@phx.gbl...
when using gac utility i am getting error

"failure adding assembly to cache: attempt to install the
assembly without strong name"


Only strong-named assemblies can go in the GAC.

See the online help for instructions on strong-naming your dll.
http://msdn.microsoft.com/library/de...strongname.asp
David
Nov 15 '05 #3
If you do not have good reason for placing it in the GAC, I will rather not
do it.
try to register your assembly with:
regasm /tlb:MyCalculator.tlb /codebase Mycalculator.dll

By the way, there is a tool (in the SDK) that allow you to see from where
dll are loaded (or failed to load):
fuslogvw (look in MSDN for more details)

José
"Sutapa" <s_******@yahoo.com> wrote in message
news:16****************************@phx.gbl...
Hi,

I am creating a DLL in c# and then trying to use it in VB6
and its failing.

Steps i did are :

1. code
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace MyCalculator
{
public interface Calc
{
int addnum(int aa, int bb);
}

public class CalculatorCLS : Calc
{
public CalculatorCLS()
{
}

public int addnum(int aa, int bb)
{
return aa+bb;
}
}
}

2. compiled with Register with COm interop property as
true.

3. got TLB File.

4. In VB added reference to MyCalculator.tlb file.

5. Dim aa As MyCalculator.Calc
Dim cc As Integer
aa = New MyCalculator.CalculatorCLS
cc = aa.addnum(34, 45)

I get error

"File or Assembly Name MyCalculator, or one of its
dependencies, was not found."

Where I am doing wrong?

Thanks
Sutapa

Nov 15 '05 #4

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

Similar topics

5
by: Enos Meroka | last post by:
Hallo, I am a student doing my project in the university.. I have been trying to compile the program using HP -UX aCC compiler, however I keep on getting the following errors. ...
3
by: Mike L | last post by:
Should the command call "using" be before or after my namespace? **AFTER** namespace DataGridBrowser { using System; using System.Drawing; using System.Drawing.Drawing2D; using...
3
by: xzzy | last post by:
I was wondering why we have to have using System.Data using System.Configuration using etc.... why are they not all lumped into one 'using'? In other words, is there a best way to use...
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
8
by: acb | last post by:
Hi, I wrote a DLL Component (using Visual Studio 2005) and managed to include it into a C# Console application. I am now trying to include this component into a Web project. I copy the DLL...
0
by: Metal2You | last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that accesses a Sybase database back end. We're using Sybase SQL Anywhere 9.0.2.3228. I have installed and registered the Sybase...
10
by: mg | last post by:
I'm migrating from VB6 and have a question about using 'Using' and the best way to use it. Here is a example of a small bit of code: dbConx("open") Using CN Dim CMD As New OleDbCommand(sSQL,...
0
by: Eugene Anthony | last post by:
The problem with my coding is that despite removing the records stored in the array list, the rptPages repeater control is still visible. The rptPages repeater control displayes the navigation...
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
6
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.