0

I am trying to use a set of static classes/variables in a plugin I am using and I keep getting an error:

MyNamespace.Foo MyNamespace.Foos.get_ClampName(); not found (full error info below)

I have created a Nuget package (on my Azure DevOps Artifacts) that has the following class:

public struct Foo{
    // added implicit operators to convert from string to
    // string and vice-versa as well as storing the string
}

public static class Foos{
    public static Foo ClampName => "ClampNameAttribute";
}

The package is being applied in a .Net Framework (4.7.2) class library and is being used like this in the library:

public class Bar{
    public void DoStuff(){
        string l_strClampName = thing.Attribute[MyNamespace.Foo.ClampName] + "";
    }
}

The library is being loaded into another app via VBA, like this:

Dim oInterface as New Bar

Public Sub DoStuff()
    oInterface.DoStuff
End Sub

This will throw the error:

Run-time error -2146233069 (80131513)':
Method not found: 'MyNamespace.Foo MyNamespace.Foos.get_ClampName()'

Unfortunately, I can't change the process that I am using to load this, so I HAVE to go through VBA to get this working. Is there something that I am missing?

GSerg
  • 76,472
  • 17
  • 159
  • 346
Andrew Riebe
  • 411
  • 7
  • 17
  • I closed this as a duplicate of [Can I call a static method of a C# class from VBA via COM?](https://stackoverflow.com/q/24193183/11683), but it does not look like COM is your problem. As far as COM is concerned, it's only calling `DoStuff`, and that exists. – GSerg Jan 16 '20 at 14:37
  • What is *supposed* to go wrong is that the CLR cannot find the assembly that contains Foos. You did something about it, without telling us about it. Perhaps copied the DLL by hand. So it can now find the assembly, but it appears to be stale and doesn't have the ClampName member. Forgetting to copy again after changing the DLL, perhaps. Too much guessing required, but that would be a common mishap. – Hans Passant Jan 16 '20 at 15:41
  • Thanks for the comment. As I stated, I am pulling the libray in with a nuget package. I do copy the library to a new location during debug, using the Build Events, and I make sure to rebuild anytime that there are any changes to the package. – Andrew Riebe Feb 03 '20 at 15:40

0 Answers0