views:

981

answers:

5

I am getting a "Method not found: 'Boolean MyCompany.LibraryAssembly.SomeFunction(System.String)'" exception/error when running a VB.NET console application.

The method is part of an external assembly and it is definitely in the assembly. The error only occurs at runtime when I go to enter the function that calls the method.
I have the assembly referenced by my project and I am not copying it locally. Intellisense shows no errors, and neither does the compiler. I am loading the assembly statically not dynamically.

I reference the from a local folder (not the GAC) although the same version is also available from the GAC.

Any suggestions as to what I might check?

A: 

Which .NET version is this?

From your method name, it looks like the method is defined in a Module?
I've found a few (older) references on the net that module functions are not accessible outside your assembly. When I tested this with my VS2008 however, it worked fine.

Modules compile to NotInheritable classes with Shared methods. Try referring to the method including the module / class name and see if it makes a difference?

If you use a strong assembly name, loading from the GAC takes precedence. If possible, remove the assembly from the GAC for now, just to make sure you're not using an older version.

Thorarin
A: 

Try removing the reference & adding it again. While doing so, just see the .NET Version info of the object. Then compare it with your app's version.

(I think GAC has presedence over local folder..Not usre about this. Please also check version of the GAC Dl.)

Also check if the function is accessible(it may be protected or internal function)

Ganesh R.
If the function were inaccessible, there would definitely be a compiler error.
Thorarin
Agreed.but just throwing some ideas.
Ganesh R.
A: 

Clean and Rebuild usualy solve the method not found exceptions for me.

chrissie1
A: 

I think bin of your running application contain old assembly. copy the new assembly in your applicaion bin.

Nakul Chaudhary
+2  A: 

I found the solution was to update the GAC again with the same version of the local assembly. I did this by dragging and dropping the assembly file into the C:\Windows\Assembly folder. After doing this & then rebuilding my console application the problem went away. Strange because the assembly in the GAC was already showing the same version number as the one locally.

Anthony K