Avatar of Moonsaver
Moonsaver
 asked on

How do I call vB methods inside C# in App_Code folder, same project?

I have a project that was made in VB by another programmer, and I need to work on that project in C# (since I have no knowledge of VB).

The project is structured as follows :

- Admin
** Test.aspx
- App_Code
-- CS_Code
** Object1.cs
-- VB_Code
** Object2.vb

 When I am in "Object1.cs", how do I create the object "Object2" that is located in the App_Code/Vb_Code folder?

ie:
Object2 = new Object2();

It does not see the Object2 at all.
.NET ProgrammingEditors IDEs

Avatar of undefined
Last Comment
abel

8/22/2022 - Mon
abel

Place a "using" directive in the top of your Object1.cs. Code from different languages MUST reside in different assemblies. So, likely, your Namespace directives are different for the VB assembly.
Moonsaver

ASKER
I have tried the following :

In "App_Code/CS_Code/Class1.cs" :
namespace CS
{
    public class Class1
    {
        public Class1()
        {
        }
    }
}

In "App_Code/VB_Code/Class2.vb" :
Imports Microsoft.VisualBasic
Namespace VB
    Public Class Class2
    End Class
End Namespace


I can't access Class2 inside Class1. I tried "Using VB;" and it does not find the namespace.
abel

My apologies, I think I missed your point. You have different codeSubDirectories, right? With different languages. These cannot access one another, because there's officially no compiler dependency between the differen directories.

Not really an explanation, but still an answer, is here: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1666098&SiteID=1

I used to have these codeSubDirectories because some things are just easier in C#. Now I remember why I removed them one day and placed them in a separate project.

Sorry that I didn't have any better news for you ...

Cheers,
-- Abel --
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Moonsaver

ASKER
What do you suggest for me to do in the scenario that "Class1" requires "Class2" to work?
ASKER CERTIFIED SOLUTION
abel

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
abel

Note that if Class1 remains in the web application and Class2 goes into its own projects, that Class2 cannot access any members from Class1. However, Class1 *can* access as much members from Class2 as are public.

Circular dependencies are never allowed anyway (you'll need Java or Eiffel for that).
abel

Tx for the points, hope you get it working!
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.