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

Accessing from C# to an vb dll

Hi,

I've a vb dll with a function that i want to access from C#. I'm using
the following:

public class library
{
[DllImport("myDll.dll", CharSet = CharSet.Auto, EntryPoint =
"clsLibrary")]
public static extern void create();
}

and:

library.create();

but i'm getting Sytem.DllNotFoundException. Nothing helped to add the
library to the references of my C# project.

I don't know what can i be doing wrong. I don't know if i have to make
the call in another way, or maybe i've to compile my vb library in a
particular way. Can anybody help me?

Thank you very much for your time!

Jan 15 '07 #1
5 1364
At runtime, where is myDll.dll located relative to the C# .exe?

--
Adam Clauss

<ja******@gmail.comwrote in message
news:11*********************@q2g2000cwa.googlegrou ps.com...
Hi,

I've a vb dll with a function that i want to access from C#. I'm using
the following:

public class library
{
[DllImport("myDll.dll", CharSet = CharSet.Auto, EntryPoint =
"clsLibrary")]
public static extern void create();
}

and:

library.create();

but i'm getting Sytem.DllNotFoundException. Nothing helped to add the
library to the references of my C# project.

I don't know what can i be doing wrong. I don't know if i have to make
the call in another way, or maybe i've to compile my vb library in a
particular way. Can anybody help me?

Thank you very much for your time!

Jan 15 '07 #2
Hi,

<ja******@gmail.comwrote in message
news:11*********************@q2g2000cwa.googlegrou ps.com...
| Hi,
|
| I've a vb dll with a function that i want to access from C#. I'm using
| the following:
|
| public class library
| {
| [DllImport("myDll.dll", CharSet = CharSet.Auto, EntryPoint =
| "clsLibrary")]
| public static extern void create();
| }

IIRC VB never generated native win32 dll, but COM dlls, if that is so all
you have to do to include your dll is select Add a Reference, go to COM and
look for it. This will create a wrapper to your dll that you can use
directly in your code as any other .NET namespace.
--
Ignacio Machin
machin AT laceupsolutions com
Jan 15 '07 #3
First of all, thanks for the answers!

At runtime, my library is not in the same folder even the same disk
than the code i'm executing, but the dll is registered in the system,m
i thought it should be enough. Where i should to place the library,
according the code?

Anyway, i added my library to the reference list (i don't know whether
as a COM object or not), but i'm still unable to us it as a .net
code...

Thanks!

JAUME

Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,

<ja******@gmail.comwrote in message
news:11*********************@q2g2000cwa.googlegrou ps.com...
| Hi,
|
| I've a vb dll with a function that i want to access from C#. I'm using
| the following:
|
| public class library
| {
| [DllImport("myDll.dll", CharSet = CharSet.Auto, EntryPoint =
| "clsLibrary")]
| public static extern void create();
| }

IIRC VB never generated native win32 dll, but COM dlls, if that is so all
you have to do to include your dll is select Add a Reference, go to COM and
look for it. This will create a wrapper to your dll that you can use
directly in your code as any other .NET namespace.
--
Ignacio Machin
machin AT laceupsolutions com
Jan 16 '07 #4
Finally i achieved that to work as a .net code... but there's still a
problem: at runtime, when i try to access to the library method, get an
'object required' exception
(system.runtime.InteropServices.COMException).

how can i solve that? have i to place my library in any special path?

thanks to all!

JAUME

ja******@gmail.com wrote:
First of all, thanks for the answers!

At runtime, my library is not in the same folder even the same disk
than the code i'm executing, but the dll is registered in the system,m
i thought it should be enough. Where i should to place the library,
according the code?

Anyway, i added my library to the reference list (i don't know whether
as a COM object or not), but i'm still unable to us it as a .net
code...

Thanks!

JAUME

Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,

<ja******@gmail.comwrote in message
news:11*********************@q2g2000cwa.googlegrou ps.com...
| Hi,
|
| I've a vb dll with a function that i want to access from C#. I'm using
| the following:
|
| public class library
| {
| [DllImport("myDll.dll", CharSet = CharSet.Auto, EntryPoint =
| "clsLibrary")]
| public static extern void create();
| }

IIRC VB never generated native win32 dll, but COM dlls, if that is so all
you have to do to include your dll is select Add a Reference, go to COM and
look for it. This will create a wrapper to your dll that you can use
directly in your code as any other .NET namespace.
--
Ignacio Machin
machin AT laceupsolutions com
Jan 16 '07 #5
Hi,

<ja******@gmail.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
| First of all, thanks for the answers!
|
| At runtime, my library is not in the same folder even the same disk
| than the code i'm executing, but the dll is registered in the system,m
| i thought it should be enough. Where i should to place the library,
| according the code?

It does not matter, as long as the dll is registered in the system you are
ok.

| Anyway, i added my library to the reference list (i don't know whether
| as a COM object or not), but i'm still unable to us it as a .net
| code...

are you including the using directive?
like using Interop.MyDLL


--
Ignacio Machin
machin AT laceupsolutions com

Jan 16 '07 #6

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

Similar topics

1
by: Amy Tseng | last post by:
Hi, I am having a problem accessing SQL Server 2000 via UNIX. I am accessing SQL Server 2000 from Solaris using Sybase Open Client (CT-Lib). Here is the error message: CT-LIBRARY error:...
5
by: Sandeep | last post by:
Hi, In the following code, I wonder how a private member of the class is being accessed. The code compiles well in Visual Studio 6.0. class Sample { private: int x; public:
6
by: Chris Styles | last post by:
Dear All, I've been using some code to verify form data quite happily, but i've recently changed the way my form is structured, and I can't get it to work now. Originally : The form is...
3
by: prodirect | last post by:
Hi all, I hope someone can help me. I've recently created a database and wanted to put it up on an ftp sight so that multiple people could access the same tables at the same time from different...
47
by: fb | last post by:
Hi Everyone. Thanks for the help with the qudratic equation problem...I didn't think about actually doing the math...whoops. Anyway... I'm having some trouble getting the following program to...
3
by: AdamM | last post by:
Hi all, When I run my VbScript, I get the error: "ActiveX component can't create object: 'getobject'. Error 800A01AD". Any ideas what I did wrong? Here's my VBScript: dim o set...
1
by: Eirik Brattbakk | last post by:
Hi I have some problems accessing a soap service made in c# using an ATL/MFC client over SSL. I have tried both CSoapMSXMLInetClient and CSoapWininetClient as template arguments with my stub...
1
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created...
3
by: niju | last post by:
Hi there, I have three web pages (A,B,C). I need to prevent users accessing page B and C without accessing A. What would be the best way to achieve this rule? Many Thanks Niju
5
by: Daniel Corbett | last post by:
I am trying to save a file dynamically created in a webpage. I get the following headers, but cannot figure out how to save the attachment. I am basically trying to replicate what internet...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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.