woo*_*ods 4 c# visual-studio-2010 unhandled-exception crystal-reports-xi
我正在研究一个项目并遇到了一个问题.当我运行我的代码时,我收到此错误消息:
The type initializer for 'CrystalDecisions.Shared.SharedUtils' threw an exception
Run Code Online (Sandbox Code Playgroud)
消息的标题是"TypeInitializerException未处理".
我在这行代码中收到此错误:
this.crystalReportViewer = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
Run Code Online (Sandbox Code Playgroud)
我一直在寻找解决这个问题的方法,但我一直在遇到另一个问题.我发现的关于如何解决这个问题的一切都说平台目标应该改为x86.遵循该建议的所有评论总是积极的,因为它似乎适用于每个人,但它不适合我.我还尝试将平台目标作为x64.当我这样做时,我没有收到先前声明的错误,但我收到的新错误如下:
The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
Run Code Online (Sandbox Code Playgroud)
此消息的标题是"InvalidOperationException未处理".错误就在这条线上:
db.Open();
Run Code Online (Sandbox Code Playgroud)
db,当然,被设置为新的OleDbConnection(连接).connection =一个Access数据库.
当平台目标是x86时,为什么我收到第一个错误而不是第二个错误,如果平台目标是x64,反之亦然?
堆栈跟踪:
System.TypeInitializationException was unhandled
Message=The type initializer for 'CrystalDecisions.Shared.SharedUtils' threw an exception.
Source=CrystalDecisions.Shared
TypeName=CrystalDecisions.Shared.SharedUtils
StackTrace:
at CrystalDecisions.Shared.SharedUtils.get_CurrentControl()
at CrystalDecisions.Shared.SharedUtils.GetEffectiveCulture()
at CrystalDecisions.Shared.LocaleManager..ctor()
at CrystalDecisions.Windows.Forms.CrystalReportViewer.InitReportViewer()
at CrystalDecisions.Windows.Forms.CrystalReportViewer..ctor()
at Client_Manager.ReportViewer.InitializeComponent() in C:\Users\Will\Desktop\Client_Manager\SyndicateII\ReportViewer.Designer.cs:line 31
at Client_Manager.ReportViewer..ctor() in C:\Users\Will\Desktop\Client_Manager\SyndicateII\ReportViewer.cs:line 27
at Client_Manager.Form1..ctor() in C:\Users\Will\Desktop\Client_Manager\SyndicateII\Form1.cs:line 174
at Client_Manager.Program.Main() in C:\Users\Will\Desktop\Client_Manager\SyndicateII\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.BadImageFormatException
Message=Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source=CrystalDecisions.Shared
FileName=log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304
FusionLog==== Pre-bind state information ===
LOG: User = Will-PC\Will
LOG: DisplayName = log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304
(Fully-specified)
LOG: Appbase = file:///C:/Users/Will/Desktop/Client_Manager/SyndicateII/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Will\Desktop\Client_Manager\SyndicateII\bin\Debug\Client_Manager.vshost.exe.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304
LOG: Attempting download of new URL file:///C:/Users/Will/Desktop/Client_Manager/SyndicateII/bin/Debug/log4net.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
StackTrace:
at CrystalDecisions.Shared.SharedUtils..cctor()
InnerException:
Run Code Online (Sandbox Code Playgroud)
这看起来像是原始问题:
InnerException: System.BadImageFormatException
Message=Could not load file or assembly 'log4net, Version=1.2.10.0,
Culture=neutral, PublicKeyToken=692fbea5521e1304'
or one of its dependencies. An attempt was made to load a program
with an incorrect format.
Run Code Online (Sandbox Code Playgroud)
所以看起来你要么使用错误版本的log4net,如果它有不同架构的多个版本,或者你刚刚错误地复制了程序集.这部分日志似乎也很相关:
LOG: Attempting download of new URL
file:///C:/Users/Will/Desktop/Client_Manager/SyndicateII/bin/Debug/log4net.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
Run Code Online (Sandbox Code Playgroud)
看起来这是检查正确性所需的文件.
它可能对某人有用:如果您可以选择这样做,请转到 IIS 并将应用程序池设置为仅 32 位应用程序。
这对我来说是个窍门。
(当然,您的应用程序可以只在 64 位上运行。在这种情况下,我认为安装 CrystalReports 的 64 位可再发行组件应该可以解决问题)
| 归档时间: |
|
| 查看次数: |
47231 次 |
| 最近记录: |