Avatar of dkim18
 asked on

can't access class library functions?


I have this vb.net application which I turned it into a class library.
I am trying to access this from the c# page.
I added the reference to it.
From my class, I added using my classlib name.
Then I tried to create an object but can't seem to create one.
Using Myclasslib;

Myclasslib.Mysubclass test = new Myclasslib.Mysubclass();

when I tried to use the method by test.Mymethod(), nothing shows up after test., any idea?
.NET ProgrammingC#

Avatar of undefined
Last Comment

8/22/2022 - Mon

Is MyMethod defined as Public?

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question


When  I create a function and instantiated it inside the function, it showed.
Can you guess why it would do that?

using Myclasslib;
public class Form1
      private void Form1_Load(object sender, System.EventArgs e)
            public Myclasslib.Mysubclass test = new Myclasslib.Mysubclass();

Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

For completeness, I suppose I should back pedal on what I mentioned previously. The statement, "just know that any method calls you perform must occur in some other method," is not entirely accurate. If you have a method that is marked as static, then you could call that method outside of a function. For example, the following method call is valid:

public class Form1
    public static string test = GetString();

    public static string GetString()
        return "Hello World!";

Open in new window

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.