我以前尝试为VB.NET程序安装JSON.NET,可以导入.dll文件,但是Visual Studio无法识别它随附的.pdb文件。在寻找解决方案时,我也更改了一些调试设置,可能还更改了dll设置,但仍然无法使JSON.NET库正常工作。
我感到沮丧,并决定使用自己的方法来解析JSON文件。但是现在,以前对stackoverflow进行了一些奇怪的操作,原本有效的简单代码会引发错误,例如:
Dim strs() as String = {"dog", "cat"}
会扔
System.InvalidCastException: 'Conversion from string "dog" to type 'Integer' is not valid.'
程序执行之前,其日志为:
'BrokerNotifier.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Loading disabled by Include/Exclude setting.
'BrokerNotifier.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'E:\Repository\Visual Basic\BrokerNotifier\BrokerNotifier\bin\Release\BrokerNotifier.exe'. Symbols loaded.
'BrokerNotifier.exe' (CLR v4.0.30319: BrokerNotifier.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualBasic\v4.0_10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualBasic.dll'. Loading disabled by Include/Exclude setting.
'BrokerNotifier.exe' (CLR v4.0.30319: BrokerNotifier.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Loading disabled by Include/Exclude setting.
'BrokerNotifier.exe' (CLR v4.0.30319: BrokerNotifier.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Loading disabled by Include/Exclude setting.
'BrokerNotifier.exe' (CLR v4.0.30319: BrokerNotifier.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Loading disabled by Include/Exclude setting.
'BrokerNotifier.exe' (CLR v4.0.30319: BrokerNotifier.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Loading disabled by Include/Exclude setting.
'BrokerNotifier.exe' (CLR v4.0.30319: BrokerNotifier.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Loading disabled by Include/Exclude setting.
'BrokerNotifier.exe' (CLR v4.0.30319: BrokerNotifier.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Loading disabled by Include/Exclude setting.
'BrokerNotifier.exe' (CLR v4.0.30319: BrokerNotifier.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Remoting\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Remoting.dll'. Loading disabled by Include/Exclude setting.
Exception thrown: 'System.FormatException' in mscorlib.dll
Exception thrown: 'System.FormatException' in Microsoft.VisualBasic.dll
Exception thrown: 'System.InvalidCastException' in Microsoft.VisualBasic.dll
Exception thrown: 'System.FormatException' in mscorlib.dll
Exception thrown: 'System.FormatException' in Microsoft.VisualBasic.dll
Exception thrown: 'System.InvalidCastException' in Microsoft.VisualBasic.dll
An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
Conversion from string "dog" to type 'Integer' is not valid.
我需要怎么做才能解决这个问题?我对诸如.dll文件之类的Visual Basic没有深入的了解,也不了解.NET框架中代码如何协同工作。我最近刚来自Java和C ++背景,因此假设我对.NET框架一无所知。任何帮助将不胜感激。
答案 0 :(得分:0)
您不需要.pdb文件。它包含调试信息。如果库引发异常,则这将使该异常包含源行信息。
还使用数据包管理器,而不是手动引用DLL:
等等!这还具有软件包管理器向您显示更新的优点,并允许您通过单击安装它们。
如果您的解决方案已损坏:
创建一个新的解决方案,并将所有旧的源代码添加为现有项。小心表单和自定义或用户控件。一对一添加它们,仅添加* .vb文件,而不添加* .designer.vb,而不添加* .resx文件。后面的字段将由Visual Studio自动添加。
在Visual Studio本身损坏的情况下:
启动Visual Studio安装程序,然后选择“修复”选项。