using vb control

  • Thread starter Thread starter Mike Oliszewski
  • Start date Start date
M

Mike Oliszewski

I have been given a tiny little vb control that I would like to use in my c#
application. I don't want to make an independant .dll out of it because
it's so small. Can anyone tell me how I can include it in my visual studio
..net project and have it properly compiled as VB ?
 
Hi Mike,

Based on my understanding, you want to use your VB control in .Net project.

I think your Vb control is an Active X control, which is also a COM
component. In .Net, you can use COM through COM interop.

In VS.net, you can just use "Add Reference" to browse to the VB control and
add it into. Then VS.net will automatically add a .Net class wrapper for
your COM component.

Then you can use it like .Net class. For more detail information and class
information about your wrapped VB control, you can see its reference in
"Object Browser"

==================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
I guess I didn't describe my problem very well. I have been given two
files, one that is is a .vb file which implements user control, written in
VB.NET and the other is the complementory .resx file. I would like to
compile these into my c# project, but within that project the compiler
doesn't seem to recognize VB. How can I successfully add these files into
my otherwise c# project and get the compiler to know what to do. I'm rather
suprized it's not completely automatic.
 
Hi Mike,

Thanks very much for your feedback.

Oh, based on your feedback, I see that what you have is a VB.net
usercontrol's source file. You want to use it in a C# project.

For a C# project, it will use csc.exe compiler to compile it and generate
assembly. It can not recognize VB.net code.

You should add a new VB.net windows control project into your entire
Solution, then add the VB.net usercontrol source code into this project.
Then, you can compile this project, an assembly will generate for this
VB.net usercontrol source code.

At last, you may add this usercontrol assembly into C# project through Add
Reference or through Tool Box

===================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
I guess what I'm hearing is that with .NET it is not possible to mix c# code
with vb code in a single .dll.
 
Mike Oliszewski said:
I guess what I'm hearing is that with .NET it is not possible to mix c# code
with vb code in a single .dll.

Yes it is - just not from VS.NET. From the command line, you can
compile to .netmodule files, and then use the assembly linker to link
those together into a single assembly.

It's rarely worth the hassle though.
 
Allright Jon! Is there any way you could give us the
exact method of actually doing this? I have tried so
many different ways to do this, it isn't even funny
anymore. Someone else told me this was possible,
but I suspect he had not actually tried it. Please, if
it can really be done, post an example of the series
of commands so that I can really do it for myself.

I have resorted to decompiling to IL, then merging
the resulting code from the VB and C# into one IL
file, then compiling that with ILASM to make one
assembly. Please, PLEASE do not just quote the docs
on this, I want to know that someone has done it
and that everything works as it is supposed to.

I'll be watching...

Thanks.
 
Allright Jon! Is there any way you could give us the
exact method of actually doing this? I have tried so
many different ways to do this, it isn't even funny
anymore. Someone else told me this was possible,
but I suspect he had not actually tried it. Please, if
it can really be done, post an example of the series
of commands so that I can really do it for myself.

I have resorted to decompiling to IL, then merging
the resulting code from the VB and C# into one IL
file, then compiling that with ILASM to make one
assembly. Please, PLEASE do not just quote the docs
on this, I want to know that someone has done it
and that everything works as it is supposed to.

I'm serious, I am now wondering if this is really
possible. I'm talking about making ONE executable
assembly, not just linking to an existing netmodule.
For the life of me, I cannot get this to work.
One assembly that does NOT require any other files
or modules or assemblies to be present. Can it be
done?

Thanks.
 
Allright Jon! Is there any way you could give us the
exact method of actually doing this? I have tried so
many different ways to do this, it isn't even funny
anymore. Someone else told me this was possible,
but I suspect he had not actually tried it. Please, if
it can really be done, post an example of the series
of commands so that I can really do it for myself.

I have resorted to decompiling to IL, then merging
the resulting code from the VB and C# into one IL
file, then compiling that with ILASM to make one
assembly. Please, PLEASE do not just quote the docs
on this, I want to know that someone has done it
and that everything works as it is supposed to.

I'm serious, I am now wondering if this is really
possible. I'm talking about making ONE executable
assembly, not just linking to an existing netmodule.
For the life of me, I cannot get this to work.
One assembly that does NOT require any other files
or modules or assemblies to be present. Can it be
done?

Thanks.
 
Allright Jon! Is there any way you could give us the
exact method of actually doing this? I have tried so
many different ways to do this, it isn't even funny
anymore. Someone else told me this was possible,
but I suspect he had not actually tried it. Please, if
it can really be done, post an example of the series
of commands so that I can really do it for myself.

I have resorted to decompiling to IL, then merging
the resulting code from the VB and C# into one IL
file, then compiling that with ILASM to make one
assembly. Please, PLEASE do not just quote the docs
on this, I want to know that someone has done it
and that everything works as it is supposed to.

I'm serious, I am now wondering if this is really
possible. I'm talking about making ONE executable
assembly, not just linking to an existing netmodule.
For the life of me, I cannot get this to work.
One assembly that does NOT require any other files
or modules or assemblies to be present. Can it be
done?

Thanks.
 
Gary Morris said:
I'm serious, I am now wondering if this is really
possible. I'm talking about making ONE executable
assembly, not just linking to an existing netmodule.
For the life of me, I cannot get this to work.
One assembly that does NOT require any other files
or modules or assemblies to be present. Can it be
done?

Ah, an assembly in a single file - no, I don't think *that's* possible
with the standard tools.

Using .netmodule files *is* creating a single assembly, but it's an
assembly spread out over multiple files.

It should be theoretically possible to merge a bunch of .netmodules
into a single file, but I don't know of any tools to do it...

<sfx: tappety tappety>

Now I do. If you go to

http://www.gotdotnet.com/Community/UserSamples/

and search for illink, you should find what you're after. I haven't
tried it, so can't vouch for it working or anything.
 
Thanks. I'll check it out. From the post it sounded like you
had actually done this. Sorry about the multiple posts, my
server was acting strange and telling me that it could not
send the post, so I kept trying. Obviously it was lying to
me!
 
Gary Morris said:
Thanks. I'll check it out. From the post it sounded like you
had actually done this. Sorry about the multiple posts, my
server was acting strange and telling me that it could not
send the post, so I kept trying. Obviously it was lying to
me!

Well, I've done it to the extent of checking that I could indeed create
an assembly from modules created by compilers of different languages.
That's not the same as creating an assembly which is all contained
within one file.
 
Hi Mike,

How is everything going on your side?

As Jon Skeet mentioned, we can compile source file to .netmodule and then
integrate them to an assembly file. However, it can't be done in VS.NET
IDE. The suggestion that Jeffery provided is how to do that in VS.NET IDE.
That should be much more convenient.

If there is any unclear, please feel free to post here and we are glad to
be of assistance.

Thanks very much.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Well, I'm a little dissappointed because it is a very common thing to need a
few lines of VB to do things that aren't available or no one knows how to do
in c# that are build into VB... like BEEP for example, so it rather stinks
to not have an easy way to include VB snippets in a c# .dll, but it
certainly isn't a huge deal to just leave it as a completely seperately
compiled .dll.

I'm just surprised, given all the hype about multi-language support in .NET.
 
Mike Oliszewski said:
Well, I'm a little dissappointed because it is a very common thing to need a
few lines of VB to do things that aren't available or no one knows how to do
in c# that are build into VB... like BEEP for example, so it rather stinks
to not have an easy way to include VB snippets in a c# .dll, but it
certainly isn't a huge deal to just leave it as a completely seperately
compiled .dll.

Anything you can do in VB.NET you can do in C#, if you know where to
look in the Microsoft.VisualBasic namespace. For Beep, for example, you
can call Microsoft.VisualBasic.Interaction.Beep().
I'm just surprised, given all the hype about multi-language support in .NET.

I don't think so - multi-language support measn that I can work in C#
with a library written in VB.NET, etc. That in itself is far more
important, IMO, than being able to include snippets of both in the same
assembly.
 
Hi Mike,

I think Jon has explained to you that C# can do everything VB.net can do.
Also, just as him pointed out, we usually do the multi-language work
through library way, and it is for code re-use.

Does this make sense to you? Do you still have concern on this issue?

Please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top