cimg (ネイティブ C++ ヘッダー ライブラリ) をドット ネットにラップしてテストしたところ、c++ CLR で正常に動作し、使用した数学は次のようになります。cimg はヘッダー ファイルにすぎないため、win32 静的ライブラリ プロジェクトを作成してビルドし、CLR c++ でヘッダーを使用して、win32 静的ライブラリを追加のライブラリに追加しました (これの理由は、リンカー エラーから逃れるためです)。それは正常に動作し、最終的にCLRからDLLを作成して、C# GUIプロジェクトで使用できるようにしようとしたので、CLR c++プロジェクトの出力をDLLに変更し、次にc# winform App内で参照しました実行しようとすると、このエラーメッセージが表示されます。
System.BadImageFormatException was unhandled
HResult=-2147024885
Message=Could not load file or assembly 'cpp tester, Version=1.0.4775.2046, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source=WindowsFormsApplication1
FileName=cpp tester, Version=1.0.4775.2046, Culture=neutral, PublicKeyToken=null
FusionLog==== Pre-bind state information ===
LOG: User = serak-PC\serak
LOG: DisplayName = cpp tester, Version=1.0.4775.2046, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Users/serak/Desktop/Cimg Wrapper/WindowsFormsApplication1/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : WindowsFormsApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/serak/Desktop/Cimg Wrapper/WindowsFormsApplication1/bin/Debug/cpp tester.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
StackTrace:
at WindowsFormsApplication1.Form1.button2_Click(Object sender, EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at WindowsFormsApplication1.Program.Main() in c:\Users\serak\Desktop\Cimg Wrapper\WindowsFormsApplication1\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: