|
-
Feb 4th, 2009, 01:43 PM
#1
Thread Starter
Hyperactive Member
[2008] Using C# and VB code files in same project
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
-
Feb 4th, 2009, 01:45 PM
#2
Re: [2008] Using C# and VB code files in same project
I don't think you can do that except if you make a dll file and than reference it from your VB project.
-
Feb 4th, 2009, 01:51 PM
#3
Thread Starter
Hyperactive Member
Re: [2008] Using C# and VB code files in same 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
-
Feb 4th, 2009, 01:51 PM
#4
Re: [2008] Using C# and VB code files in same project
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.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Feb 4th, 2009, 01:54 PM
#5
Thread Starter
Hyperactive Member
Re: [2008] Using C# and VB code files in same 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
-
Feb 4th, 2009, 02:08 PM
#6
Thread Starter
Hyperactive Member
Re: [2008] Using C# and VB code files in same project
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
-
Feb 4th, 2009, 02:09 PM
#7
Re: [2008] Using C# and VB code files in same project
 Originally Posted by Psychlotron
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?
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
-
Feb 4th, 2009, 02:14 PM
#8
Re: [2008] Using C# and VB code files in same project
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.
-
Feb 4th, 2009, 02:15 PM
#9
Thread Starter
Hyperactive Member
Re: [2008] Using C# and VB code files in same project
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
-
Feb 4th, 2009, 02:17 PM
#10
Thread Starter
Hyperactive Member
Re: [2008] Using C# and VB code files in same project
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
-
Feb 4th, 2009, 02:34 PM
#11
Re: [2008] Using C# and VB code files in same project
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.
-
Feb 4th, 2009, 02:49 PM
#12
Re: [2008] Using C# and VB code files in same project
 Originally Posted by Psychlotron
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
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.
So you should start by right clicking the project, (class library project), add reference... and look for the DLLs.
-
Feb 4th, 2009, 03:24 PM
#13
Thread Starter
Hyperactive Member
Re: [2008] Using C# and VB code files in same project
Ahh, thank you Mendhak. I was slightly confused as to the difference between an Assembly and a Namespace.
-Jerome
-
Feb 4th, 2009, 03:30 PM
#14
Thread Starter
Hyperactive Member
Re: [2008] Using C# and VB code files in same project
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|