0

I tried to bring a previously done webform made in vb.net to an IronPython asp.net website with no luck. After seeing it didnt work, I tried to write the simplest codebehind vb.net webform to see if there was a problem with vb.net in an IronPython website and I got the following usual error

"be sure that the defined class in this file matchs with the one in the attribute inherits and that it extends the right base page (page or control)" (sorry if the translation isnt the most accurate I get that message in spanish)

but if I create a vb.net webform in the same website, with the sourcecode in the same file (with the vb.net code between script runat="server" tags in the same page) I get no problem.

Do I have to configure something for both kind of sourcecode languages to run in such way in the same IronPython website, like configuring something in the webconfig file or is there some compatibility issue for doing that which can't be resolved?

2 Answers 2

1

The code between <script /> tags is compiled dynamically when the page is first run. This enables you to mix languages. However, the classes in your code-behind files are statically compiled into an assembly by VS.NET ... and a VS.NET project can only support one language at a time.

One solution is to put your VB.NET code-behinds in a separate assembly. For example:

  • Add a new VB Class Library project to your existing solution
    • Add a reference to System.Web
    • Create your VB.NET code-behinds. They should be normal classes inheriting from System.Web.UI.Page.
  • In your ASP.NET website project, add a reference to the new project
  • Edit the @ Page directives in your *.aspx files to inherit the classes in the new project
    • e.g. <%@ Page Inherits="YourNewVBClassLibraryProject.MyVBCodeBehinds" ... /> where the Inherits attribute contains the relevant namespace-qualified class name
Sign up to request clarification or add additional context in comments.

Comments

0

Thanks for the reply Serilla. Your information was interesting but I simply solved it by creating the app_folder and adding the vb files there. Do you think I could have some future problem for doing so?

The problem with the vb files was when these lines in the web.config were enabled for Ironpython to work

<pages compilationMode="Auto" pageParserFilterType="Microsoft.Web.Scripting.UI.NoCompileCodePageParserFilter" pageBaseType="Microsoft.Web.Scripting.UI.ScriptPage" userControlBaseType="Microsoft.Web.Scripting.UI.ScriptUserControl">
            <controls>
                <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            </controls>
</pages>

when I removed them, vb code behind files worked but ironpython didnt. When the lines were there, Ironpython code behind files worked but vb ones didnt

1 Comment

Thanks for the update. I'm more used to working with ASP.NET Web Application projects that don't use the App_Code folder, but I don't see any problems with your solution. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.