如何在VB Web应用程序中使用CS类 [英] How to use cs class in a VB web application

查看:165
本文介绍了如何在VB Web应用程序中使用CS类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个使用VB编写的Web应用程序,现在我想添加一些新页面,并且我正在使用C#.在App_code文件夹中添加我的CS类后,它不起作用.

谁能说出如何在VB Web应用程序中添加CS类?

There is a web application which is codded using VB, now i want to add some new pages and i am using C#; after adding my cs class in App_code folder it is not working.

Can anyone tell how to add cs class in VB web application?

推荐答案

您不能在一个项目中混合使用c#和vb.net.您可以做的是将c#代码添加到vb.net解决方案内部的自己的项目中.效果很好.
You can''t mix c# and vb.net in one project. What you can do is to add the c# code to its own project which is inside your vb.net solution. That works very well.


AFAIK,您不能.项目是VB.NET或C#.您可以使用以任何一种语言编写的汇编程序集,但不能仅混合使用代码.
如果您希望当前VB中的Web应用程序将其代码后面编译为与C#相同的程序集,那么我将必须对其进行转换.

更新:
很高兴知道这是完全可能的.将文件放置在App_Code中具有定义名称的不同文件夹中可以达到目的.
AFAIK, you can not. Projects are either VB.NET or C#. You can use compiled assemblies written in either language, but you can not just mix the code.
If you want the web application that is currently in VB to have it''s code behind compiled into the same assembly as the C#, then I you will have to convert them.

UPDATE:
Good to know that this is quite possible. Placing files in different folders with defined names in App_Code does the trick.


本质上,没有"C#"类之类的东西.有CLI类,仅此而已.您可以用一种语言编写一个程序集,然后以其他某种.NET语言引用它.如果使用Visual Studio,则每个程序集将是一个单独的项目,并且可以使用相同的解决方案从另一个项目中引用一个项目(强烈建议这样做,因为这还会自动解决版本,强名称和依赖项中的更改;在运行时,程序集相互引用,而不是项目).

因此,语言之间没有边界,程序集之间的边界是如此透明,开发过程不会给您带来任何麻烦,因此,多项目解决方案的开发与单一项目的开发完全相同整体工艺.

为了以防万一,我应该提到(即使这超出了问题),某些语言提供了附加功能,可能会稍微超出标准.NET功能.例如,C ++/CLI允许引用类型的值语义.

我必须指出,这个问题是基于对所需的大多数一般和基本平台主题的阅读不足而造成的.您当然需要阅读更多内容.请从此开始:
http://en.wikipedia.org/wiki/.NET_platform [ http://en.wikipedia.org/wiki/Common_Language_Infrastructure [ http://en.wikipedia.org/wiki/Clr [ http://en.wikipedia.org/wiki/Managed_code [ http://en.wikipedia.org/wiki/Garbage_collection_%28computer_science%29 [ ^ ].

您还需要阅读MSDN中的匹配主题.

这少于成功开发所需的最低要求,但这只会为您提供有关关键概念的想法.

祝你好运,
—SA
Essentially, there is no such thing as "C#" class. There are CLI classes, that''s it. You can write one assembly in one language, and then reference it in some other .NET language. If you use Visual Studio, each assembly would be a separate project, and you can reference one project from another withing the same solution (highly recommended, because this also automatically resolves changes in versions, strong names and the dependencies; during run time, the assemblies reference each other, not projects).

So, there is no boundaries between languages, and the boundaries between assemblies are so transparent, the the development process does not give you any hassles, so development of a multi-project solution is going in exact same way as in the case of a single monolithic process.

Just in case, I should mentioned (even though this is beyond the question), that some language provide additional feature which can go slightly beyond standard .NET feature. For example, C++/CLI allows for value semantic for reference types.

I must note that this question is based on insufficient reading on most general and basic platform topics you needed. You certainly need to read some more. Please start with this:
http://en.wikipedia.org/wiki/.NET_platform[^],
http://en.wikipedia.org/wiki/Common_Language_Infrastructure[^],
http://en.wikipedia.org/wiki/Clr[^],
http://en.wikipedia.org/wiki/Managed_code[^],
http://en.wikipedia.org/wiki/Garbage_collection_%28computer_science%29[^].

You also need to read on matching topic in MSDN.

This is less then the minimum required for successful development, but it will just give you the idea on key concepts.

Good luck,
—SA


这篇关于如何在VB Web应用程序中使用CS类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆