Mixed Language Development

Discussion in 'ASP .Net' started by AG, Feb 3, 2007.

  1. AG

    AG Guest

    I am working on a web app using both C# and VB. Yes, there is a reason for
    it.

    All the code behind is C#.
    In the web.config I have the following

    <compilation debug="true">
    <codeSubDirectories>
    <add directoryName="VB_Code"/>
    <add directoryName="Csharp_Code"/>
    </codeSubDirectories>
    </compilation>
    There are public classes in the appropriate folders of each language type.
    I can reference any class from the pages' code behind.
    I can reference VB classes from the C# classes in the App_Code\Csharp_Code
    folder.
    I can reference VB classes from other VB classes.
    I cna reference C# classes from other C# classed.

    However I can't reference any C# classes from the VB classes in the
    AppCode\VB_Code.
    The error indicates that the class is not defined.

    Can anyone explain this and possibly tell me how to reference the C# classes
    from the VB classes?

    TIA
    --

    AG
    Email: discuss at adhdata dot com
    AG, Feb 3, 2007
    #1
    1. Advertising

  2. Which version of Visual Studio. I have a mixed language web-site under
    development (VB, C#, and a little JScript) and I reference all three
    languages with no problem. Note, your VB projects need to be DLL projects.

    Mike Ober.

    "AG" <> wrote in message
    news:...
    >I am working on a web app using both C# and VB. Yes, there is a reason for
    >it.
    >
    > All the code behind is C#.
    > In the web.config I have the following
    >
    > <compilation debug="true">
    > <codeSubDirectories>
    > <add directoryName="VB_Code"/>
    > <add directoryName="Csharp_Code"/>
    > </codeSubDirectories>
    > </compilation>
    > There are public classes in the appropriate folders of each language type.
    > I can reference any class from the pages' code behind.
    > I can reference VB classes from the C# classes in the App_Code\Csharp_Code
    > folder.
    > I can reference VB classes from other VB classes.
    > I cna reference C# classes from other C# classed.
    >
    > However I can't reference any C# classes from the VB classes in the
    > AppCode\VB_Code.
    > The error indicates that the class is not defined.
    >
    > Can anyone explain this and possibly tell me how to reference the C#
    > classes from the VB classes?
    >
    > TIA
    > --
    >
    > AG
    > Email: discuss at adhdata dot com
    >
    >
    >
    >
    >
    Michael D. Ober, Feb 4, 2007
    #2
    1. Advertising

  3. AG

    AG Guest

    Thanks for the reply Mike.
    I am using VS 2005.
    I am referring to mixed language development within the same project.
    VS 2003 did not support that.

    According to this article
    http://msdn2.microsoft.com/en-us/library/ms366714.aspx
    it should work.

    --

    AG
    Email: discuss at adhdata dot com



    "Michael D. Ober" <obermd.@.alum.mit.edu.no.spam> wrote in message
    news:xIdxh.20472$...
    > Which version of Visual Studio. I have a mixed language web-site under
    > development (VB, C#, and a little JScript) and I reference all three
    > languages with no problem. Note, your VB projects need to be DLL
    > projects.
    >
    > Mike Ober.
    >
    > "AG" <> wrote in message
    > news:...
    >>I am working on a web app using both C# and VB. Yes, there is a reason for
    >>it.
    >>
    >> All the code behind is C#.
    >> In the web.config I have the following
    >>
    >> <compilation debug="true">
    >> <codeSubDirectories>
    >> <add directoryName="VB_Code"/>
    >> <add directoryName="Csharp_Code"/>
    >> </codeSubDirectories>
    >> </compilation>
    >> There are public classes in the appropriate folders of each language
    >> type.
    >> I can reference any class from the pages' code behind.
    >> I can reference VB classes from the C# classes in the
    >> App_Code\Csharp_Code folder.
    >> I can reference VB classes from other VB classes.
    >> I cna reference C# classes from other C# classed.
    >>
    >> However I can't reference any C# classes from the VB classes in the
    >> AppCode\VB_Code.
    >> The error indicates that the class is not defined.
    >>
    >> Can anyone explain this and possibly tell me how to reference the C#
    >> classes from the VB classes?
    >>
    >> TIA
    >> --
    >>
    >> AG
    >> Email: discuss at adhdata dot com
    >>
    >>
    >>
    >>
    >>

    >
    >
    >
    AG, Feb 4, 2007
    #3
  4. Even with these changes, each assembly is still limited to a single language
    and I think that's what you're running into. The site I'm developing
    doesn't make the language specific support in the MSDN article - the site
    itself is in C# and I have C# and VB assemblies behind it.

    Mike.

    "AG" <> wrote in message
    news:...
    > Thanks for the reply Mike.
    > I am using VS 2005.
    > I am referring to mixed language development within the same project.
    > VS 2003 did not support that.
    >
    > According to this article
    > http://msdn2.microsoft.com/en-us/library/ms366714.aspx
    > it should work.
    >
    > --
    >
    > AG
    > Email: discuss at adhdata dot com
    >
    >
    >
    > "Michael D. Ober" <obermd.@.alum.mit.edu.no.spam> wrote in message
    > news:xIdxh.20472$...
    >> Which version of Visual Studio. I have a mixed language web-site under
    >> development (VB, C#, and a little JScript) and I reference all three
    >> languages with no problem. Note, your VB projects need to be DLL
    >> projects.
    >>
    >> Mike Ober.
    >>
    >> "AG" <> wrote in message
    >> news:...
    >>>I am working on a web app using both C# and VB. Yes, there is a reason
    >>>for it.
    >>>
    >>> All the code behind is C#.
    >>> In the web.config I have the following
    >>>
    >>> <compilation debug="true">
    >>> <codeSubDirectories>
    >>> <add directoryName="VB_Code"/>
    >>> <add directoryName="Csharp_Code"/>
    >>> </codeSubDirectories>
    >>> </compilation>
    >>> There are public classes in the appropriate folders of each language
    >>> type.
    >>> I can reference any class from the pages' code behind.
    >>> I can reference VB classes from the C# classes in the
    >>> App_Code\Csharp_Code folder.
    >>> I can reference VB classes from other VB classes.
    >>> I cna reference C# classes from other C# classed.
    >>>
    >>> However I can't reference any C# classes from the VB classes in the
    >>> AppCode\VB_Code.
    >>> The error indicates that the class is not defined.
    >>>
    >>> Can anyone explain this and possibly tell me how to reference the C#
    >>> classes from the VB classes?
    >>>
    >>> TIA
    >>> --
    >>>
    >>> AG
    >>> Email: discuss at adhdata dot com
    >>>
    >>>
    >>>
    >>>
    >>>

    >>
    >>
    >>

    >
    >
    >
    Michael D. Ober, Feb 4, 2007
    #4
  5. Hello AG,

    As for the mixed language problem you mentioned, it is actually due to the
    natural limitation of .net framework's assembly referencing. In .net
    framework, when you have two assemblies(suppose they're A and B), then
    there are only two possible referencing topology. They are:

    A reference B(B is referenced by A)

    or

    B reference A(A is referenced by B)

    Two assembly can not reference each other at the same time(cross reference
    is not allowed).

    For your scenario, you use mixed languages to create custom class in
    ASP.NET 2.0's App_code folder(by separate them into own sub directories),
    though ASP.NET 2.0 support this pattern, it will actually compile those
    classes(of different programming languges and in different sub folders)
    into separate assemblies. As the same as above, only one assembly can
    reference the other one. Here your CS classes(in cs_subdir) will be
    compiled into a dynamic assembly(suppose is named dynamic_cs.dll), your VB
    classes will be compiled into another assembly(named dynamic_vb.dll), so
    the only supported referecing cases are:

    dynamic_vb.dll reference dynamic_cs.dll(VB classes can use CS classes)

    dynamic_cs.dll reference dynamic_vb.dll(CS classes can use VB classes)

    I haven't got any more detailed info about how the runtime will compile the
    sub directories(under App_Code), and make the reference relation ship, but
    only one of the above condtions will be allowed.

    Also, based on my understanding, the "App_Code" directory help to provide a
    "dynamic class library" functionarlity, so each class in App_Code should be
    treated as a class library, we should not rely on they can see the
    other(unless they are of the same language and can be compiled into the
    same assembly). The ASP.NET 2.0 application will always ensure all the page
    and usercontrol can correctly reference those classes in App_Code folder.

    If you do need to have full control over the reference relationship, I
    would suggest you consider move some of the classes into a class library
    project so that they can be precompiled into an assembly and be referenced
    by the ASP.NET project. How do you think?

    Hope this helps some.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    ==================================================

    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.



    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.

    ==================================================



    This posting is provided "AS IS" with no warranties, and confers no rights.
    Steven Cheng[MSFT], Feb 5, 2007
    #5
  6. AG

    AG Guest

    Thanks Steven.
    At least I know what is going on. The article
    http://msdn2.microsoft.com/en-us/library/ms366714.aspx is misleading.

    Since most of my classes will be VB, I will probably convert the C# classes
    to VB.

    --

    AG
    Email: discuss at adhdata dot com



    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hello AG,
    >
    > As for the mixed language problem you mentioned, it is actually due to the
    > natural limitation of .net framework's assembly referencing. In .net
    > framework, when you have two assemblies(suppose they're A and B), then
    > there are only two possible referencing topology. They are:
    >
    > A reference B(B is referenced by A)
    >
    > or
    >
    > B reference A(A is referenced by B)
    >
    > Two assembly can not reference each other at the same time(cross reference
    > is not allowed).
    >
    > For your scenario, you use mixed languages to create custom class in
    > ASP.NET 2.0's App_code folder(by separate them into own sub directories),
    > though ASP.NET 2.0 support this pattern, it will actually compile those
    > classes(of different programming languges and in different sub folders)
    > into separate assemblies. As the same as above, only one assembly can
    > reference the other one. Here your CS classes(in cs_subdir) will be
    > compiled into a dynamic assembly(suppose is named dynamic_cs.dll), your VB
    > classes will be compiled into another assembly(named dynamic_vb.dll), so
    > the only supported referecing cases are:
    >
    > dynamic_vb.dll reference dynamic_cs.dll(VB classes can use CS classes)
    >
    > dynamic_cs.dll reference dynamic_vb.dll(CS classes can use VB classes)
    >
    > I haven't got any more detailed info about how the runtime will compile
    > the
    > sub directories(under App_Code), and make the reference relation ship, but
    > only one of the above condtions will be allowed.
    >
    > Also, based on my understanding, the "App_Code" directory help to provide
    > a
    > "dynamic class library" functionarlity, so each class in App_Code should
    > be
    > treated as a class library, we should not rely on they can see the
    > other(unless they are of the same language and can be compiled into the
    > same assembly). The ASP.NET 2.0 application will always ensure all the
    > page
    > and usercontrol can correctly reference those classes in App_Code folder.
    >
    > If you do need to have full control over the reference relationship, I
    > would suggest you consider move some of the classes into a class library
    > project so that they can be precompiled into an assembly and be referenced
    > by the ASP.NET project. How do you think?
    >
    > Hope this helps some.
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    >
    > ==================================================
    >
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    > ications.
    >
    >
    >
    > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community or a Microsoft Support
    > Engineer within 1 business day is acceptable. Please note that each follow
    > up response may take approximately 2 business days as the support
    > professional working with you may need further investigation to reach the
    > most efficient resolution. The offering is not appropriate for situations
    > that require urgent, real-time or phone-based interactions or complex
    > project analysis and dump analysis issues. Issues of this nature are best
    > handled working with a dedicated Microsoft Support Engineer by contacting
    > Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/subscriptions/support/default.aspx.
    >
    > ==================================================
    >
    >
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
    >
    >
    AG, Feb 5, 2007
    #6
  7. Thanks for your reply AG,

    yes, the MSDN article you referenced mainly talk about referencing
    multi-language code (in App_Code) from ASPX page's code, and hasn't
    detailedly explain the underlying compilation structure and process.

    Also, I really recommend that you submit the feedback for the document. You
    can post feedback for the document through two means:

    ** In the document page, you can find the a bar of stars on the right top
    corner, hover the mouse over it and you can submit optional feedback on
    this.

    ** You can also directly submit feedback or request to the MSDN product
    feedback center:

    http://connect.microsoft.com/feedback/default.aspx?SiteID=210

    Any of your comments are really appreciated.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Steven Cheng[MSFT], Feb 6, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Liles
    Replies:
    2
    Views:
    1,736
  2. =?Utf-8?B?QXJuZSBHYXJ2YW5kZXI=?=

    Mixed language programming

    =?Utf-8?B?QXJuZSBHYXJ2YW5kZXI=?=, Mar 29, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,681
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    Mar 29, 2006
  3. =?Utf-8?B?QXJuZSBHYXJ2YW5kZXI=?=

    Mixed language development

    =?Utf-8?B?QXJuZSBHYXJ2YW5kZXI=?=, Apr 3, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    341
    =?Utf-8?B?QXJuZSBHYXJ2YW5kZXI=?=
    Apr 3, 2006
  4. Danny
    Replies:
    3
    Views:
    445
    Stephen Howe
    Sep 2, 2003
  5. AG
    Replies:
    6
    Views:
    411
Loading...

Share This Page