Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Why doesn't the .dll works?

I use the following code to call it:
C#
using XauSHello;

HelloWorld hello = new HelloWorld();


When I write "hello." it doesn't give me my functions "Talk" and "Speak". Why?

This is the Class Library cs file:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SpeechLib;
using System.Windows.Forms;

namespace XauSHello
{
    public class HelloWorld
    {
        public static void Talk(string p)
        {
            MessageBox.Show(p);
        }

        public static void Speak(string speak)
        {
            SpVoice Voice = new SpVoice();

            Voice.Rate = 1;
            Voice.Volume = 100;
            Voice.Speak(speak);
        }
    }
}
Posted

1 solution

Because Talk and Speak are static methods, so you can't call them on an instance. In order to "see" them, you have to use HelloWorld.Talk() or HelloWorld.Speak, not hello.Talk or hello.Speak.
 
Share this answer
 
Comments
XauS_ 1-Aug-13 19:34pm    
Thank you very much!
Ron Beyer 1-Aug-13 19:37pm    
By the way, if you only have static methods in a class, you should declare the class as static, that way you can't create instances like you did, it would throw a compiler error and would be a lot clearer on how to fix it.
XauS_ 1-Aug-13 19:39pm    
Thanks again! You're awsome!
Sergey Alexandrovich Kryukov 1-Aug-13 19:49pm    
Exactly, a 5.
—SA
Sergey Alexandrovich Kryukov 1-Aug-13 19:59pm    
By the way, the issue has nothing to do with the fact that it's a DLL or not. If OP wants to work inside one assembly, interanal would work, instead of public.
For .NET there is no essential differences between "EXE", "DLL" or anything else, there are only assemblies and modules.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900