Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MethodNotFoundException in net8 #96268

Closed
heckl opened this issue Dec 22, 2023 · 5 comments · Fixed by #98249
Closed

MethodNotFoundException in net8 #96268

heckl opened this issue Dec 22, 2023 · 5 comments · Fixed by #98249

Comments

@heckl
Copy link

heckl commented Dec 22, 2023

Description

public static List<int> Test1No(Worksheet sourceSheet) 
{
    return new List<int>();
}
public static int Test2Yes(Worksheet sourceSheet) 
{
    return 3;
}
public static List<int> Test3Yes() 
{
    return new List<int>();
} 

MethodNotFoundException occurs if there is a Worksheet (office.interop) parameter and a List return value. So version 2 and 3 works but not version 1. These methods are called from sperate project but both projects were .net 8. My workaround was going back to .net7.

Reproduction Steps

https://www.dropbox.com/scl/fi/mf20wxeqju9ghhm34z4td/TestSolution.zip?rlkey=8et27m0vgb6v2kpjg3j7ach84&dl=0

I created a solution to demonstrate the problem. You can build the solution but you will get the exception in runtime.

Expected behavior

There should be no exception at runtime.

Actual behavior

There is a MethodNotFoundException in runtime.

Regression?

If you go back to .net7 it works fine.

Known Workarounds

Go back .net7

Configuration

.net8
Windows 10
x64

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Dec 22, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Dec 22, 2023
@vcsjones vcsjones removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Dec 22, 2023
@AaronRobinsonMSFT AaronRobinsonMSFT added this to the 9.0.0 milestone Jan 2, 2024
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jan 2, 2024
@heckl
Copy link
Author

heckl commented Jan 3, 2024

Hi, I see the issue is added to the 9.0.0 milestone. Do you know a workaround so on .net 8?

@AaronRobinsonMSFT
Copy link
Member

@heckl This hasn't been investigated yet so there isn't any action at present. The description indicates that we need to look into it and once we have an understanding we will be able to define next steps.

@ivanch
Copy link

ivanch commented Jan 3, 2024

Hello guys!
I did take a look at this but I wasn't able to get as far to a solution, but I did find a few things:

  • This also happens when using other classes from System.Collections.Generic namespace, e.g. Queue<T>, HashSet<T>, LinkedList<T>, SortedSet<T> and Stack<T>. More importantly, I did find that it also happens if you declare a new class, say TestT<T> internally and use it to return the value;
  • This doesn't happen when using an interface as the return type, so if you put IList<T> as return type and do return new List<T> it works perfectly. Same thing with the internal class I mentioned above, if we declare an interface ITestT<T> and use it, it doesn't crash;
  • This only occurs when dealing with an external library, like when having multiple projects as the issue states, and not if the method is internal to the binary;
  • This does not occur if you use reflection to call the method, the following also works as expected: typeof(TestClass).GetMethod("Test1No", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Invoke(null, new object[] { null });.

I also was able to find this stack trace with Windbg:

[0x0]   KERNELBASE!RaiseException+0x69   0x738517bc30   0x7ffaaf5ca3f7   
[0x1]   coreclr!RaiseTheExceptionInternalOnly+0x26b(Object * throwable = 0x738517db70, int rethrow = 167772185, fForStackOverflow = <unavailable>)   0x738517bd10   0x7ffaaf5f2d20   
[0x2]   coreclr!UnwindAndContinueRethrowHelperAfterCatch+0x38(Exception * pException = 0x1c1ff05fc20, pEntryFrame = <unavailable>)   0x738517be20   0x7ffaaf65fb85   
[0x3]   coreclr!CEEInfo::resolveToken+0x175ee5(CORINFO_RESOLVED_TOKEN * pResolvedToken = 0x738517c270)   0x738517be60   0x7ffaae3305bc   
[0x4]   clrjit!Compiler::impImportBlockCode+0x2cc(BasicBlock * block = 0x1c1ff04c118 : BB2; BBJ_RETURN)   0x738517c170   0x7ffaae32f562   
[0x5]   clrjit!Compiler::impImportBlock+0x62(BasicBlock * block = 0x1c1ff04c118 : BB2; BBJ_RETURN)   0x738517c960   0x7ffaae32f245   
[0x6]   clrjit!Compiler::impImport+0x485()   0x738517ca70   0x7ffaae3d1f6e   
[0x7]   clrjit!Compiler::fgImport+0xe()   0x738517cb00   0x7ffaae3c4a92   
[0x8]   clrjit!Phase::Run+0x1b()   0x738517cb30   0x7ffaae32daeb   
[0x9]   clrjit!DoPhase+0x49()   0x738517cb30   0x7ffaae32daeb   
[0xa]   clrjit!Compiler::compCompile+0x182(void * * methodCodePtr = 0x738517d740, unsigned int * methodCodeSize = 0x738517d7f8 : 0x1, JitFlags * compileFlags = 0x738517d760)   0x738517cb30   0x7ffaae32daeb   
[0xb]   clrjit!Compiler::compCompileHelper+0x34b(classPtr = <unavailable>, ICorJitInfo * compHnd = 0x738517db70, CORINFO_METHOD_INFO * methodInfo = 0x738517da60, void * * methodCodePtr = 0x738517d740, unsigned int * methodCodeSize = 0x738517d7f8 : 0x1, JitFlags * compileFlags = 0x738517d760, JitFlags * compileFlags = 0x738517d760)   0x738517d380   0x7ffaae32cede   
[0xc]   clrjit!Compiler::compCompile+0x24e(CORINFO_MODULE_STRUCT_ * classPtr = 0x7ffa4fb2e0a0, CORINFO_MODULE_STRUCT_ * classPtr = 0x738517da60, void * * methodCodePtr = 0x738517d740, void * * methodCodePtr = 0x738517da60, unsigned int * methodCodeSize = 0x738517d7f8 : 0x1, unsigned int * methodCodeSize = 0x7ffa4fb58da8 : 0x60400, JitFlags * compileFlags = 0x738517d760)   0x738517d460   0x7ffaae385f45   
[0xd]   clrjit!jitNativeCode+0x265(CORINFO_METHOD_STRUCT_ * methodHnd = 0x7ffa4fb500c0, CORINFO_MODULE_STRUCT_ * classPtr = 0x7ffa4fb2e0a0, ICorJitInfo * compHnd = 0x738517db70, ICorJitInfo * compHnd = 0x738517db70, CORINFO_METHOD_INFO * methodInfo = 0x738517da60, CORINFO_METHOD_INFO * methodInfo = 0x738517da60, void * * methodCodePtr = 0x738517d740, unsigned int * methodCodeSize = 0x738517d7f8 : 0x1, JitFlags * compileFlags = 0x738517d760, inlineInfoPtr = <unavailable>)   0x738517d560   0x7ffaae3d6f76   
[0xe]   clrjit!CILJit::compileMethod+0xa6(ICorJitInfo * compHnd = 0x738517db70, CORINFO_METHOD_INFO * methodInfo = 0x738517da60, unsigned int flags = 0x80000004, unsigned char * * entryAddress = 0x738517d808, unsigned char * * entryAddress = 0x738517d808, unsigned int * nativeSizeOfCode = 0x738517d7f8 : 0x1, unsigned int * nativeSizeOfCode = 0x738517d7f8 : 0x1)   0x738517d700   0x7ffaaf529ed6   

Hope this helps a little.

@tombycz
Copy link

tombycz commented Jan 31, 2024

Hello,
this is probably caused by any use of generics in the output, I encountered the same issue with the method

int? GetNumber(Worksheet sheet, string rangeName)

@ghost ghost added in-pr There is an active PR which will close this issue when it is merged and removed in-pr There is an active PR which will close this issue when it is merged labels Feb 9, 2024
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Feb 9, 2024
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Feb 12, 2024
@elinor-fung
Copy link
Member

The fix for this is in the 8.0.3 release (and main). Thanks all for the report, repro, and investigation!

@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
7 participants