Question

This code compiles, and runs successfully locally, but not on another server. Both machines are 64-bit operating systems.

This is the call:

retItem = (DataCollectionSetValueHeader)new DataCollectionSetValueHeaderLogic().GetItem(Id);  // Id is an int.

And this is the method signature that's being called:

public DataCollectionSetValueHeader GetItem(long entityID)  // This one is obviously a long

This compiles, so I'm assuming that it's okay to pass an int to a method that expects a long. The question, though, is why would this work locally, but fail with "MissingMethodException" on another machine?

We're struggling with where to begin troubleshooting this. Could a different version of the .NET framework cause this? Something else?

Was it helpful?

Solution

This compiles, so I'm assuming that it's okay to pass an int to a method that expects a long.

No, it's not - not at the binary level. It's okay at the source code level, because the compiler turns your code into:

GetItem((long) Id)

But once you've compiled code which uses a method as if it's got an int parameter, you can't change the parameter type, recompile just the assembly containing the method itself and then expect the old binary to work. You'll need to recompile the calling code as well.

If you believe you're using the same binary (as the target of the call) in both places, then it must be something else.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top