dll from VB for C#

  • Thread starter Thread starter mamin
  • Start date Start date
M

mamin

Hi
How can I use VB libraries in C# code? I have library.dll file and after
adding it to references in C# i can see only 4 methods, while after adding
it to VB's references i can see 15 methods.
 
VB or VB.NET? If this is classic VB, try this. Break binary compatibility and
compile to a new DLL. Then examine in C# and see if you still cannot see the
methods. If so, it has to do with COM interfaces. I am not sure what the
solution is, but that is where I would start to look.


---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
It's VB.NET unfortunately :(
Moreover I don't have source of this dll.


U¿ytkownik "Cowboy (Gregory A. Beamer) - MVP"
 
mamin,

Is it possible that the methods you see in VB are static? In C#, you
won't see them on instances, rather, you will see them only when scoped
correctly (VB is more lax about this).

Hope this helps.
 
Well, but what can I do to use them in C#? Is there sth like for
createObject method? I mean sth like
Microsoft.VisualBasic.Interaction.CreateObject()?.

U¿ytkownik "Nicholas Paldino [.NET/C# MVP]"
mamin,

Is it possible that the methods you see in VB are static? In C#, you
won't see them on instances, rather, you will see them only when scoped
correctly (VB is more lax about this).

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

mamin said:
It's VB.NET unfortunately :(
Moreover I don't have source of this dll.


U¿ytkownik "Cowboy (Gregory A. Beamer) - MVP"
compatibility
and see
the
 
mamin,

What is sth?

Also, if you want to create an object in C# dynamically, use the static
CreateInstance class on the Activator class.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

mamin said:
Well, but what can I do to use them in C#? Is there sth like for
createObject method? I mean sth like
Microsoft.VisualBasic.Interaction.CreateObject()?.

U¿ytkownik "Nicholas Paldino [.NET/C# MVP]"
mamin,

Is it possible that the methods you see in VB are static? In C#, you
won't see them on instances, rather, you will see them only when scoped
correctly (VB is more lax about this).

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

mamin said:
It's VB.NET unfortunately :(
Moreover I don't have source of this dll.


U¿ytkownik "Cowboy (Gregory A. Beamer) - MVP"
<[email protected]> napisa³ w wiadomo¶ci
VB or VB.NET? If this is classic VB, try this. Break binary compatibility
and
compile to a new DLL. Then examine in C# and see if you still cannot see
the
methods. If so, it has to do with COM interfaces. I am not sure what the
solution is, but that is where I would start to look.


---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

:

Hi
How can I use VB libraries in C# code? I have library.dll file and
after
adding it to references in C# i can see only 4 methods, while after
adding
it to VB's references i can see 15 methods.
 
"sth" means "something";)

What do You mean to "use the static
CreateInstance class on the Activator class"?



U¿ytkownik "Nicholas Paldino [.NET/C# MVP]"
mamin,

What is sth?

Also, if you want to create an object in C# dynamically, use the static
CreateInstance class on the Activator class.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

mamin said:
Well, but what can I do to use them in C#? Is there sth like for
createObject method? I mean sth like
Microsoft.VisualBasic.Interaction.CreateObject()?.

U¿ytkownik "Nicholas Paldino [.NET/C# MVP]"
mamin,

Is it possible that the methods you see in VB are static? In C#, you
won't see them on instances, rather, you will see them only when scoped
correctly (VB is more lax about this).

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

It's VB.NET unfortunately :(
Moreover I don't have source of this dll.


U¿ytkownik "Cowboy (Gregory A. Beamer) - MVP"
<[email protected]> napisa³ w wiadomo¶ci
VB or VB.NET? If this is classic VB, try this. Break binary compatibility
and
compile to a new DLL. Then examine in C# and see if you still cannot see
the
methods. If so, it has to do with COM interfaces. I am not sure what the
solution is, but that is where I would start to look.


---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

:

Hi
How can I use VB libraries in C# code? I have library.dll file and
after
adding it to references in C# i can see only 4 methods, while after
adding
it to VB's references i can see 15 methods.
 
mamin said:
"sth" means "something";)

What do You mean to "use the static
CreateInstance class on the Activator class"?


He meant:

Activator.CreateInstance(Type type);


I remember i used to create <type> by type name, which you actually
need, but i don't have that source handy now. Anyway, it sould be like:

Type myType = <This stupid function>("Your_type_name");
Object myObject = Activator.CrateInstance(myType);

Something like this... i've used it last time about a year ago, so i
might mix some details, but the idea should be correct.

Hope it helps!
Andrey aka MuZZy

mamin,

What is sth?

Also, if you want to create an object in C# dynamically, use the
static

CreateInstance class on the Activator class.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Well, but what can I do to use them in C#? Is there sth like for
createObject method? I mean sth like
Microsoft.VisualBasic.Interaction.CreateObject()?.

U¿ytkownik "Nicholas Paldino [.NET/C# MVP]"
<[email protected]> napisa³ w wiadomo¶ci

mamin,

Is it possible that the methods you see in VB are static? In C#,
you
won't see them on instances, rather, you will see them only when scoped
correctly (VB is more lax about this).

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


It's VB.NET unfortunately :(
Moreover I don't have source of this dll.


U¿ytkownik "Cowboy (Gregory A. Beamer) - MVP"
<[email protected]> napisa³ w wiadomo¶ci

VB or VB.NET? If this is classic VB, try this. Break binary

compatibility

and

compile to a new DLL. Then examine in C# and see if you still cannot

see

the

methods. If so, it has to do with COM interfaces. I am not sure what

the

solution is, but that is where I would start to look.


---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

:


Hi
How can I use VB libraries in C# code? I have library.dll file and
after
adding it to references in C# i can see only 4 methods, while
after
adding

it to VB's references i can see 15 methods.
 
Why wouldn't you do this:

// First, load your dll into an Assembly instance:
1. Assembly myAsm = Assembly.LoadFrom("Your_DLL_Name");

// Second, load all types contained in the dll
2. Type[] alltypes = myAsm.getTypes();

// Just print those types on console to make sure they are reacheable:
3. foreach (Type temp in alltypes)
Console.WriteLine("Fount Type:" + temp.Name);

This way you will see which types(classes) of the dll you can access
from c#.

Type yourType = alltypes[<typeindex>]

Oops, i have to go home now, you can google about how to create an
instance of class by type

Or maybe someone else would help?

Hope it helped a bit

Andrey
 
Back
Top