Alias ​​Generic Type with ASP.Net Import Directive on VB.Net

I can’t import the generic type on the ASP.Net page set to "vb":

<%@ Page Language="vb" %> <%-- This works fine. --%> <%@ Import Namespace="MyString=System.String" %> <%-- This gives an error. --%> <%@ Import Namespace="MyList=System.Collections.Generic.List(Of System.String)" %> <%-- Error: "The 'namespace' attribute cannot contain spaces." --%> 

Please note that I am NOT interested in these alternatives (for boring reasons that you are not interested in):

  • Modify the web.config file.
  • Change the code.
  • Use the code instead of the page.
  • Using C # instead of VB.Net.
  • Googling (generic types are not mentioned on the MSDN page).
  • Modifying the app.config file.
  • Adding a namespace to "imported namespaces" through the "Links" tab in the project settings.
  • Workarounds (I already have workarounds, but I want to see if it can be done correctly)

Is it possible to use a generic type alias on an ASP.NET VB.Net page, or is this oversight by Microsoft?

+8
visual-studio
source share
1 answer

Yes, the bad news:

  • You cannot use a generic type everywhere in .NET (you may have recently changed, don't think so).
  • You cannot import a namespace with a space in it into ASP.NET. This is a parser for aspx that problem. Yes, Microsoft supervision. Since C # will be List<System.String> , this will not cause an error. They left VB again.
0
source share

All Articles