-1

When I am trying to call a method of another project class file, I am getting the following error enter image description here

  • 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 :)

Lelouch
  • 37
  • 4
  • 2
    Please show error messages which are inherently textual as *text* rather than as images... and please tell us more about the projects. You've talked about two library projects, but you can't *run* a library project, so presumably there's an application project somewhere. What dependencies does that have? Is it an "old" style of project or a new SDK-style project? Can you provide a [mcve]? – Jon Skeet Aug 16 '21 at 14:34
  • It is a Bootstrapper project. Bootstrapper projects have a run method which is abstract and needs to be overidden. Another Bundle project is also there which generates exe file which invokes the run method. Since the program was abruptly ending, I used try catch block to show the exception in messageBox. Image is cropped version of messageBox. I will try to edit question to include the minimal reproducible example but I simply created 2 separate projects and 1 class each and tried to call a method from one class to other. – Lelouch Aug 16 '21 at 14:44
  • Given how out-of-the-ordinary your program sounds, it would have been a *really* good idea to include all that information to start with. – Jon Skeet Aug 16 '21 at 14:56
  • 1
    [How to log assembly binding failures](https://stackoverflow.com/questions/17681432/how-can-i-enable-assembly-binding-logging) – John Wu Aug 16 '21 at 15:04

2 Answers2

0

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
}
0

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