私は外部DLLのクラスを使用する.NET 3.5アプリケーション(WinForms)を作成していますが、アプリケーションが起動しようとするたびにSystem.TypeLoadException
を受信し続けます。ここ
が表示さVS例外です:TypeLoadExceptionに関するヘルプ
Friend NotInheritable Class App
<STAThread()> Shared Sub Main()
'set the exception handlers'
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException)
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledExceptionHandler
AddHandler Application.ThreadException, AddressOf ThreadExceptionHandler
'initialize the application'
App.Initialize()
'and then run the application'
Dim mainForm As New PolymorphHost
Application.Run(mainForm)
End Sub
Shared Function Initialize() As FunctionResult
If App.InitializeDataDirectory() = False Then
Return New FunctionResult(False, "the application's data directory")
End If
_settings = New PolyMorph.Common.Settings(AppDataDirectory & "\Settings.dat")
......code continues to load settings from the _settings variable
End Function
End Class
私を驚かせる何VS2010デバッガなしでラインApp.Initialize()
に停止していることである。ここでは
System.TypeLoadException was unhandled Message=Could not load type 'PolyMorph.Common.Settings' from assembly 'PolyMorph, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Source=PolyMorph TypeName=PolyMorph.Common.Settings StackTrace: at PolyMorphApp.App.Initialize() at PolyMorphApp.App.Main() at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:
は、私が実行しているコードがありますInitialize
機能に入ることさえできます。
ただし、Initialize
関数で外部DLLへのすべての参照をコメントアウトすると、アプリケーションが正しく初期化されます。
周りに読んだ後、私は(x64のDLLは、x86のアプリケーションから参照されているように)自分のプロジェクトに基づいています。このエラーを報告する人の数が異なる使用していたことに気づきました。したがって、私はDLLとアプリケーションが両方のx86でしたが、私はまだTypeLoadException
を持っているようにビルド設定を変更しました。
紛失しているものはありますか?
私はアプリケーションのマニフェストで間違ったdllの名前を持っていたときにこのエラーが発生しました。 – ZX9