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

System.TypeInitializationException: The type initializer for '<Module>' threw an exception. #464

Open
kelilive opened this issue May 8, 2024 · 1 comment

Comments

@kelilive
Copy link

kelilive commented May 8, 2024

Describe the bug and how to reproduce

Application does not support just-in-time (JIT)
debugging. See the end of this message for details.

************** Exception Text **************
System.TypeInitializationException: The type initializer for '' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Vanara.PInvoke.User32, Version=4.0.0.0, Culture=neutral, PublicKeyToken=c37e4080322237fa' or one of its dependencies. The system cannot find the file specified.
at System.ModuleHandle.ResolveMethod(RuntimeModule module, Int32 methodToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount)
at System.ModuleHandle.ResolveMethodHandleInternalCore(RuntimeModule module, Int32 methodToken, IntPtr[] typeInstantiationContext, Int32 typeInstCount, IntPtr[] methodInstantiationContext, Int32 methodInstCount)
at System.ModuleHandle.ResolveMethodHandleInternal(RuntimeModule module, Int32 methodToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.Reflection.RuntimeModule.ResolveMethod(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
--- End of inner exception stack trace ---
at 1BE442B8.6C8F42B5(Exception 75941B80)
at 1BE442B8.44455E8D(Object[] 4F450FCC, Int32 15625F0E)
at .cctor()
--- End of inner exception stack trace ---
at DrawingMaster.BlockManage.BlockManageCommand.Bm()
at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.PerDocumentCommandClass.Invoke(MethodInfo mi, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()

************** JIT Debugging **************
Application does not support Windows Forms just-in-time (JIT)
debugging. Contact the application author for more
information.

What code is involved

User32.SetFocus(doc.Window.Handle);

Expected behavior

When I tried to use the user32 API to activate focus on the current document window of AutoCAD, I reported an error. I will try not to use the encapsulated assembly later, because it prompts loading problems.

Screenshots

2024-05-08_151746

@kelilive
Copy link
Author

kelilive commented May 8, 2024

I originally wanted to write one myself for testing, but I changed my mind and wanted to verify that Dapplo.Windows.User32 can run very well using other assembly tests. Therefore, there is little point in rewriting it yourself. The problem has basically been analyzed, and the assembly compatibility and reliability should be optimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant