I thought that in VS2005 you could have .cs and .vb files in the same project?
I just tried with an asp.net project and it doesn't work!
It says that the two files use a different language, which is not allowed.
-
-
You can mix C# and VB projects in the same solution, but I don't think you can mix them within a project.
-
You can't have C# and VB.Net files within the same project.
seb
http://sgomez.blogspot.com -
You can't have App_Code files with both VB and C#, but you can have one VB ASP.NET page and one C# ASP.NET page in the same project.
Thanks,
-Dan -
Dan: So it's not possible to add a normal C# class to a VB.NET web project? A page is a class as well, so that's kind of strange.
-
I think it's because ASPX pages are compiled on the fly, whereas executables and libraries are compiled by their corresponding compilers, csc.exe in C#'s case.
I guess technically someone could write a compiler that puts VB and C# together, but that'd defeat .NET's goal of being language independent, since that compiler would have to accomodate for every language out there.
There's more than 50 .NET languages out there right now, and ASPX supports only two of them.
It's just modularity on a different level, ASPX being arguably more practical but definitely less holistic. -
reinux: I was not talking about executables or libraries but a simple class file or webservice in a web project!
The files in your App_Code directory are compiled on the fly as well, just like the pages, so it must be an architectural limitation!
It seems that everything in App_Code is compiled together in one assembly???!!
Can someone from the team tell a bit more about the exact limitations / architecture and possible solutions? -
dotnetjunkie wrote:reinux: I was not talking about executables or libraries but a simple class file or webservice in a web project!
The files in your App_Code directory are compiled on the fly as well, just like the pages, so it must be an architectural limitation!
It seems that everything in App_Code is compiled together in one assembly???!!
Can someone from the team tell a bit more about the exact limitations / architecture and possible solutions?
Ahh sorry, I misread.
Weird... I always thought you could do it.
I can see it being a limitation of CodeDom's architecture though, since CodeDom can spit out assemblies but it can't spit out just raw objects.
There'd be ways to get around it, I'm sure, like ILMerge does, but I guess they figured it wouldn't be worth the trouble
-
Maybe compile one as a dll with a nice Interface(s) and use it in the other project through a reference?
-
dotnetjunkie wrote:It seems that everything in App_Code is compiled together in one assembly???!!
That is correct. This assembly is referenced when compiling the pages. -
Thanks, that explains why it can't be done.
I hope that people from the team are reading this, as I think this would be a nice improvement for vNext! -
Um... Yes you can use both VB.NET and C# within your App_Code folder!
On my blog I posted on how to do just that. It's really easy!
http://pietschsoft.com/Blog/Post.aspx?PostID=1287 -
I am having the same type problem, but with a non web project. I would like to not have to rewrite the C# code, but want to use it in my VB.net project. Any suggestions on if this is possible?
Kquad
-
why not just build a dll and use it??
simple to do, works everytime.
no magic, just build a class-lib project and then ref-the dll in another project. -
csc.exe /t:module and al.exe are your friends

-
you can have files in different languages in the same project, if you are using C++/CLI, at least in Beta 1, 2 you could.dotnetjunkie wrote:I thought that in VS2005 you could have .cs and .vb files in the same project? -
We can mix up both C# and VB.Net in App_Code. For that purpose we have to perform these two steps:
1. Create two subdirectories in App_Code folder one each for C# and VB.Net. Let suppose i have created directory named "VBCode" for VB.Net and "CSCode" for C#.
2. Modify the complition section of web.config file like this
<compilation>
<codeSubDirectories>
<add directoryName="VBCode"/>
<add directoryName="CSCode"/>
</codeSubDirectories>
</compilation>
-
You can also make a class lib project (compiles to dll) and put the respective code in their own projects in the bin directory of website. I highley recommend this approach. I am not sure I see the benifit of using app_code except in really trivial cases or pages like global.ASAX. I would avoid it. dlls make utility code more distributable. (of course I do not condone dll spam, making yet another dll)
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.