问题
I have an ASP .NET web application which has references to assemblies from the 32-bit Crystal Reports runtime. (Installed from CRRedist2008_x86.msi) The server on which it has been deployed has a 64-bit Crystal Reports runtime. The form containing the CrystalReportViewer throws the following exception:
System.TypeInitializationException: The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception. ---> System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {5FF57840-5172-4482-9CA3-541C7878AE0F} failed due to the following error: 80070005. at CrystalDecisions.CrystalReports.Engine.ReportDocument..cctor() --- End of inner exception stack trace --- at CrystalDecisions.CrystalReports.Engine.ReportDocument..ctor() at [qualifiedFormName]_Load(Object sender, EventArgs e)
While I realize that making the dev environment identical to the runtime environment would the ideal solution, I was hoping there were some way to resolve this without having to upgrade the development environment.
Would updating the references to Crystal Reports assemblies in web.config on the server work?
回答1:
- Open windows registry (Regedit.exe)
- Search for 5FF57840-5172-4482-9CA3-541C7878AE0F
- You should find a key, expand it and go to each child nodes until you find the installation path.
- Go to that path (usually C:\Program ...\Business Objects...\bin...)
Grant full permission for ASP .NET, IIS worker process, Anonymous Web User process accounts
You should be good to go.
来源:https://stackoverflow.com/questions/24320247/typeinitializerexception-thrown-by-reportdocument-constructor