I have some rather largish classes that I wrote in C# that I want to include in a Visual Basic project. How would I do that (aside from transcription)?
Thanks,
Jerome
Printable View
I have some rather largish classes that I wrote in C# that I want to include in a Visual Basic project. How would I do that (aside from transcription)?
Thanks,
Jerome
I don't think you can do that except if you make a dll file and than reference it from your VB project.
That's what I thought. And so that is what I'm wondering how to do. I haven't made any dll's yet. Is it hard?
Thanks,
Jerome
Like VBDT said, create a separate class library C# project and put all your C# classes in it. Compile it to a dll and use the dll in your VB project.
On a side note, I kind of wonder why, since it all gets compiled to the same IL code anyway, why we can't include any .NET Language files we want in a project?
I really like the refactoring capabilities of C#. And a few other things. What I really wish is that I could mark each method as either C# or Visual Basic and have a default for unmarked methods. Am I missing something, or would that be cool? Except, I suppose, for readability of code...
-jerome
Ok, so I went in and created a Class Library project. But now, some of my imports don't register. It says I may not have included all the assemblies. But if I change the project's output type to Windows Application then everything is fine. The specific imports are:
using System.Data.linq;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration.provider;
Anybody know what's going on?
Thanks,
Jerome
Well I think the reason is that the compilers are not the same for VB and C#. VB compilers don’t understand C# code, as simple as it is :)Quote:
Originally Posted by Psychlotron
you need to reference the namespaces in your class library by adding references from Add reference when you right click the solution or go to solution properties and add them from there.
Okay, I'm just playing with concepts here, but would it be possible, using Visual Studio, to write a compiler and Attributes that would allow each method to be compiled by its appropriate language? I don't know much of anything about compilers, obviously, I'm just a beginner to this whole thing, but it would be cool, I think, if it were possible.
-jerome
I know that I've read that you can write compilers. I just wonder, from someone who knows about such things, if it would be possible to write a compiler such as I am speaking of.
-Jerome
Hmm, if you are going to write a compiler, than I think you should learn Assembly language (low level language) since obviously you can’t write a compiler in VB for VB projects. And what is troubling you using dll files. After all the dll files are exactly for that reason so you can use any language and create the dll files and use it in different projects. That is the accepted way of doing things in .Net and the only way i know.
Do a search for each of those namespaces on MSDN, each MSDN page will tell you the DLL that you need to import to have those namespaces made available to you. In most, but not all, cases, the assembly (DLL name) is the same as the namespace.Quote:
Originally Posted by Psychlotron
So you should start by right clicking the project, (class library project), add reference... and look for the DLLs.
Ahh, thank you Mendhak. I was slightly confused as to the difference between an Assembly and a Namespace.
-Jerome
VBDT, nothing is bothering me using dll's, especially since I got that whole Assembly thing figured out. Rather, I'm just curious by nature, and it seemed kinda cool to write a compiler such that you could intermix .NET languages in the same codefile.
But I understand it wouldn't be quite as cool as I'd like, since in the case of C# and VB.NET the IDE is actually different. But I wonder if that could be bridged too. Anyway, I'm just imagining cool things, or what are cool things to me.
-Jerome