PC Review


Reply
Thread Tools Rate Thread

Accessing from C# to an vb dll

 
 
jaume.pf@gmail.com
Guest
Posts: n/a
 
      15th Jan 2007
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!

 
Reply With Quote
 
 
 
 
Adam Clauss
Guest
Posts: n/a
 
      15th Jan 2007
At runtime, where is myDll.dll located relative to the C# .exe?

--
Adam Clauss

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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!
>



 
Reply With Quote
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      15th Jan 2007
Hi,

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
| 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


 
Reply With Quote
 
jaume.pf@gmail.com
Guest
Posts: n/a
 
      16th Jan 2007
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,
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> | 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


 
Reply With Quote
 
jaume.pf@gmail.com
Guest
Posts: n/a
 
      16th Jan 2007
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

(E-Mail Removed) 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,
> >
> > <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > | 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


 
Reply With Quote
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      16th Jan 2007
Hi,

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
| 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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(IFS filter driver) Accessing user buffer from kernel thread or accessing handles within user context RA Windows XP Drivers 4 21st Dec 2005 11:40 AM
IE slow accessing IIS6 versus being fast accessing IIS4 =?Utf-8?B?dmFkaW0=?= Windows XP Internet Explorer 0 20th Oct 2004 08:51 PM
IE slow when accessing IIS6 versus fast accessing IIS4 =?Utf-8?B?dmFkaW0=?= Windows XP Internet Explorer 0 20th Oct 2004 08:49 PM
Problem accessing Internet Explorer 6 when initially accessing internet inowcu2 \(removethis\) @yahoo.com Windows XP Internet Explorer 0 10th Dec 2003 04:40 AM
Re: accessing a C-DLL Qiu Zhang Microsoft C# .NET 1 31st Jul 2003 05:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:14 PM.