Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi..

I am currently working with one of the asp.net website(4.0 framework) where am using crytal reports,which is working fine only in localhost not on server after hosting.

Can anyone please let me know wat might be the issue??
Posted
Updated 6-Oct-20 18:20pm
Comments
Sandeep Mewara 7-Jul-12 14:19pm    
You need to elaborate more on: "working fine only in localhost not on server after hosting"
bhagyap 9-Jul-12 4:14am    
My website is working locally but not on remote server,it gives me following exception:-

Error System.TypeInitializationException: The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception. ---> System.TypeInitializationException: The type initializer for 'CrystalDecisions.Shared.SharedUtils' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) at CrystalDecisions.Shared.SharedUtils..cctor() --- End of inner exception stack trace --- at CrystalDecisions.Shared.SharedUtils.GetClientCulture() at CrystalDecisions.CrystalReports.Engine.CREngineRes.GetString(String name) at CrystalDecisions.CrystalReports.Engine.ReportDocument.CheckForCrystalReportsRuntime() at CrystalDecisions.CrystalReports.Engine.ReportDocument..cctor() --- End of inner exception stack trace --- at CrystalDecisions.CrystalReports.Engine.ReportDocument..ctor()

can you please help me?

See Below Link You may get some idea
http://www.manjuke.com/2009/07/type-initializer-for-threw-exception.html[^]

and about the exception

First things to check are:

1) Architecture (x86, x64)
2)Crystal Runtime Version



C#
TypeInitializationException occurs when a static constructor has an error. It is thrown from static constructors. It actually wraps the errors from static constructors. It cannot be trapped outside of the static constructor reliably.
The Below Program Shows How this error will come

using System;

class Program
{
    static Program()
    {
	//
	// Static constructor for the program class.
	// ... Also called a type initializer.
	// ... It throws an exception in runtime.
	//
	int number = 100;
	int denominator = int.Parse("0");
	int result = number / denominator;
	Console.WriteLine(result);
    }

    static void Main()
    {
	// Entry point.
    }
}

Output

Unhandled Exception: System.TypeInitializationException: The type initializer for
'Program' threw an exception. --->
System.DivideByZeroException: Attempted to divide by zero.
   at Program..cctor() in....
   --- End of inner exception stack trace ---
   at Program.Main()
 
Share this answer
 
v2
System.IO.FileLoadException: Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference
Above error simply means: You are using Log4Net to log errors which is missing on the server.

Make sure that the log4Net.dll is present on server. Version of assembly should be same as referenced in your project. Even assembly version mismatch will raise error here.
Either install it or put the dll in bin folder of your application.
 
Share this answer
 
Comments
bhagyap 9-Jul-12 5:07am    
thanks for ur reply.. the dll is already present on server and still my reports aren't working.
I had the same issue. Installing both 32 and 64 bits versions of CR runtime solved the problem.

My project was a desktop application.
 
Share this answer
 
Comments
kosportel 14-Nov-16 8:24am    
I have the same problem with a Desktop Application. In my case, i wouldn't like to make any installation in client computers, that's why i distribute the Crystal Report DLLs. However the problem is appeared. Do you think that i can distribute just the DLLs or an installation is required?
I had to recompile my dll changing target cpu from 'any' to 'x86', and that fixed it.
 
Share this answer
 
v2
Comments
Member 7757427 12-Jan-18 14:25pm    
Thank you - your solution worked for me!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900