简体   繁体   中英

How to call a method from another C# library project in Visual Studio?

When I am trying to call a method of another project class file, I am getting the following error在此处输入图像描述

  • I have 2 C# library projects inside same solution file.

  • Inside each project I have a class file.

  • I have added reference of one project inside other.

There are NO compile time or build errors. During runtime, it is throwing the following exception (Image attached above)

My question is, how does one able to call a class method of one project from another method?

Thanks in advance:)

Is your current project class file exist in the actual directory? The physical file might not be on the disk itself so it has this error message.

Simply put if your physical file exist in your directory, and if you wanna call that method in, be sure to put the namespace at the top and import that reference from your solution explorer.

Also, Do remember to include your method class as public.

Example Below:

public class GetUserDetails
{
//methods
}

First check the target framework and verify that the two C# library projects have the same framework.

Did you miss deploying or referencing any assembly (DatabaseUtil.dll) in the old version?

Check to make sure that the referenced assembly exists in your bin folder. If it does exist, check if it is 32-bit or 64-bit.

Go to References in Solution Explorer in Visual Studio. Select the assembly which is getting complained. Set its Copy Local to true in its Properties page. And I suggest you try the suggestions in this thread .

If the above methods are not successful, please provide the relevant code to reproduce the problem.

Daniel Zhang

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM