Andrei Tornea
Andrei Tornea

Reputation: 122

How to solve library error calling the method c#?

I've made a library and I've imported it adding a reference in the project and put using the namespace of my library, but when I'm trying to use a method it shows me an error. "The type or namespace name 'UploadFiles' does not exist in the namespace 'MyGoogleUDS'(are you missing an assembly reference?)"

Project:

using MyGoogleUDS;

error on this call:

MyGoogleUDS.UploadFiles("..\\" + asset.Name);

My library:

namespace MyGoogleUDS
{
    public class MyGoogleUDS
    {
        public static void UploadFiles(string path)
        {
            ...
        }
        ...
    }
    ...
}

Upvotes: 1

Views: 87

Answers (2)

Prasad Telkikar
Prasad Telkikar

Reputation: 16049

Your class name and namespace name is same, so you need to use namespace aliasing or you need to add namespace before class name

something like

MyGoogleUDS.MyGoogleUDS.UploadFiles("..\\" + asset.Name);

Namespace aliasing,

using namespaceName = MyGoogleUDS;

namespaceName.MyGoogleUDS.UploadFiles("..\\" + asset.Name);

As @JonSkeet suggested, I recommend you to update either namespace name or class name to avoid this issue.

Upvotes: 5

J.B. Schubert
J.B. Schubert

Reputation: 31

You need to call it like this

MyGoogleUDS.MyGoogleUDS.UploadFiles("..\\" + asset.Name);

Another problem could be that you forgot to add a reference to your .dll in the project

Upvotes: 0

Related Questions