visual-studio ASP.NET 是否支持 C++?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1615215/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does ASP.NET support C++?
提问by Sergey
When I go to New -> Web site, in the drop-down menu "Language" there are only 2 languages: Visual C# and Visual Basic. No Visual C++. Maybe, I'm using wrong version of Visual Studio? (mine is 9.0.21022)
I tried to google this problem. I found a topicwhich tells that using C++ in ASP.NET is impossible. But it was posted in 2002 and I hope that something has changed since that year.
Is it possible to write ASP.NET applications using C++? If it does, can I use visual designer with this language?
当我转到新建 -> 网站时,在“语言”下拉菜单中只有 2 种语言:Visual C# 和 Visual Basic。没有 Visual C++。也许,我使用了错误版本的 Visual Studio?(我的是 9.0.21022)
我试图用谷歌搜索这个问题。我发现了一个主题,它告诉我们在 ASP.NET 中使用 C++ 是不可能的。但它是在 2002 年发布的,我希望自那年以来有所改变。是否可以使用 C++ 编写 ASP.NET 应用程序?如果可以,我可以使用这种语言的视觉设计器吗?
回答by John K
Visual Studio generates C# and VB code and that's why it provides you only those options, because the visual designers from which code is generated don't understand C++. There's nothing preventing you from creating a C++ project that uses the managed .NET codebase like the System, System.Web.* namespaces, etc. You won't have the designers or code generators working for you, which means comparatively more coding for you; however arguably a C++ programmer is accustomed to not having a lot of visual design support.
Visual Studio 生成 C# 和 VB 代码,这就是它只为您提供这些选项的原因,因为生成代码的可视化设计人员不了解 C++。没有什么可以阻止您创建使用托管 .NET 代码库(如 System、System.Web.* 命名空间等)的 C++ 项目。您不会有设计器或代码生成器为您工作,这意味着您需要进行更多的编码; 然而可以说,C++ 程序员习惯于没有很多视觉设计支持。
Microsoft provides information about ways of programming .NET using C++.
Microsoft 提供了有关使用 C++ 编程 .NET 的方法的信息。
The caveat is you might not be able to use the version of Visual Studio you wanted to use. Worst case scenario is you use a text editor and invoke the compiler from the command-line.
需要注意的是,您可能无法使用想要使用的 Visual Studio 版本。最坏的情况是您使用文本编辑器并从命令行调用编译器。
回答by meklarian
It is possible to use Managed C++ to create classes for ASP.NET pages, but at this time (through VS2008) there isn't explicit support for coupled source files or design-time integration. Only VB.NET and C# have full support.
可以使用托管 C++ 为 ASP.NET 页面创建类,但目前(通过 VS2008)没有对耦合源文件或设计时集成的明确支持。只有 VB.NET 和 C# 有完整的支持。
If you're interested in building applications that only use handlers, you can write your handler classes in a separate library project or assembly and then just import them into an empty ASP.NET project. Any language that may be used to produce a .NET assembly will work in this case.
如果您对构建仅使用处理程序的应用程序感兴趣,您可以在单独的库项目或程序集中编写处理程序类,然后将它们导入到空的 ASP.NET 项目中。在这种情况下,任何可用于生成 .NET 程序集的语言都可以使用。
The following links can get you started if you wish to give it a shot. The only real restriction for using any language with ASP.NET is whether the code is available as a .NET assembly.
如果您想试一试,以下链接可以帮助您入门。在 ASP.NET 中使用任何语言的唯一真正限制是代码是否可用作 .NET 程序集。
ASP.NET with Managed C++ @ CodeProject
The ASP Column: Code-behind in ASPX Files @ MSDN
ASP.NET with Managed C++ @ CodeProject
ASP 专栏:ASPX 文件中的代码隐藏@ MSDN

