cancel
Showing results for 
Search instead for 
Did you mean: 

C# Windows forms shows The type initializer for 'CrystalDecisions.ReportSource.ReportSourceFactory' threw an exception.

Former Member
0 Kudos

Hello

Previously i was having an issue with Crystal report that was showing exception

Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information. in Visual studio and crystal report 2012

then i fixed it with some help at MSDN as discussed here https://social.msdn.microsoft.com/Forums/vstudio/en-US/8321793d-b6c7-4d31-a634-d44b77920287/mixed-mo...

Now it is giving exception The type initializer for 'CrystalDecisions.ReportSource.ReportSourceFactory' threw an exception.

Please tell me who can i fix this

I am using windows 8, VS2012 with Dot net framework 4.0

i also tried .net framework 4.5 but still showing the same issue.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

See Reference Link: 

I hope download latest update of crystal report for visual studio 2010 from sap. it will remove the error.

Thanks,

DJ

Former Member
0 Kudos

Hello

thanks for your reply. Please read my full post. I am using Visual Studio 2012. i am not using Visual Studio 2010.

and i have also download latest update for VS 2012 from and installed version v.13.0.12.1494 and i have also tried both exe and Msi installers.

I have also checked both 32 but and 64 bit versions as well.

waiting for your reply

Thanks

Sajid.

former_member183750
Active Contributor
0 Kudos

Hi Sajid

In this case, VS 2010 or VS 2012 or VS 2013 is of no consequence. So, do have a look at the link sent by DJ.

Also:

What CR assemblies are you referencing in your app?

Is this a new app or are you upgrading and older app?

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

Former Member
0 Kudos

Hello thanks for your reply

But i think you have not read whole discussion and just answered to my last question

I have already tried installing/Re-installing 32 bit and 64 bit version. Tried by changing Projects debug and build to x86, x64 and Any CPU but no luck

Also tried adding lines in config files. (see Link provided in my questions),

Please tell me what should i do to solve this.

I was thinking that setting eclipse. ADT etc was the most difficult but now i know setting Crystal Reports is more difficult and tricky then any other product.

Please help me and reply with proper answers after reading my question.

Thanks

Sajid

former_member183750
Active Contributor
0 Kudos

I don't understand why you accuse people of not reading your responses?

Did I say anything about reinstalling? Did you read the answer in the link DJ posted?

I actually wonder if you read my post, noting that you did not post a reply to my questions:


What CR assemblies are you referencing in your app?

Is this a new app or are you upgrading and older app?

- Ludek

former_member292966
Active Contributor
0 Kudos

Hi Sajid,

In the project's properties, is the Target Framework set to .NET Framework 4.5?  Visual Studio used to default to the .NET Framework 4.0 Client or 4.5 Client.  This prevented the Crystal references to be loaded until I changed it to the proper framework.

I know you mentioned updating the framework and editing the config file but does Visual Studio know about the change.

Hope this helps,

Brian

Former Member
0 Kudos

i have read the link that DJ has posted which says to change debug mode to Any CPU

Further i have not added any assembly manually.

I have just created a new blank Crystal report and a new windows form with a Crystal report viewer. and then i am loading my Crystal report in windows form using code.

ReportDocument rd = new ReportDocument();

            //rd.Load(@"~\CrystalReports\CrystalReport1.rpt");

            rd.Load(@"C:\Users\Raja Sajid\documents\visual studio 2012\Projects\WareHouseInventory\WareHouseInventory\CrystalReports\CrystalReport1.rpt");

            rd.SetDataSource(ds.Tables[0]);

            CrystalReport1.ReportSource = rd;  

See below images for my project configurations.

former_member183750
Active Contributor
0 Kudos

Well, reading the link that DJ posted I see:


It was the Target CPU!!! The dropdown for Platform CPU just has "Active (Any CPU)" in it, but I changed the Target CPU to x86, and it worked!

Which is exactly opposite of what you were reading(??).

And great info, but I still do not have the answer to my questions:

What CR assemblies are you referencing in your app?

Is this a new app or are you upgrading and older app?

Unless I get those in the next reply, I will just abandon this thread...

- Ludek

Former Member
0 Kudos

Hello,
Please see below images for my current configurations.

After setting these configuration i got this error.

So I changed settings to x64

and again i got same error as below

And Answers to your questions

What CR assemblies are you referencing in your app?

Is this a new app or are you upgrading and older app?

I have not added any CR assembly manually.

I have downloaded and install SAP crystal reports version 13.0.12.1494

then i created a new project with blank report and added a new windows form with crystal report viewer and then i binded crystal report with that viewer as discussed above.

Also i have not added any CR assembly manually to project so i dont know which Assembly is referenced or added. for details please see my project directory structure.

HOPE THIS WILL SATISFY YOU.

And please tell me solution now,

former_member292966
Active Contributor
0 Kudos

Hi Sajid,

Can you verify if the Target Framework in the project's property is set to 4.5 or 4.0 and not client? 

Former Member
0 Kudos

Thanks for your reply.

I have tried

4.0

4.0 Client Profile

4.5  and

4.5 Client Profile but all frameworks are showing errors.

currently it is set to 4.0 As you can see in image.

former_member292966
Active Contributor
0 Kudos

Hi Sajid,

The client Profiles is what usually causes this error.  The target framework should always be either 4 or 4.5.  Seeing as you used both, I'm wondering if the problem is with the .NET Framework itself.

You upgraded from .NET 4 to 4.5.  If there was a problem with .NET 4 originally then the update may not have addressed it.  I've had to repair the framework before and the best way to do it is uninstall all the .NET framework components and then download and install the full 4.5 or 4.5.1 package from Microsoft.

You have all the basic references in your project for Crystal so it's a matter of why won't the project load them.  As I said, the most common reason is because the wrong framework is set in the project properties.

If you have set them and rebuilt the solution after each try then the problem may be with the framework itself.  I'm just guessing at this point because what you have said here should work.

An experiment would be to create a new solution and in the project add the Crystal viewer and references.  Make sure the target framework is correct.  Drop a button on the form that calls a report.  Does that work?

Good luck,

Brian

Former Member
0 Kudos

Ok thanks for your reply.

Now updating Visual studio to latest available version i.e VS 2012 update 4.

I have already tried creating a new project with Framework 4.5 but no luck. Will try uninstalling/ re installing Framework version ..

Former Member
0 Kudos

hello

I solved this issue my self. I just set Dot Net version to 3.5 and it is fixed.

and here is reply against your post at http://scn.sap.com/message/15580636#15580636

I am afraid with your reply at said URL. You and SAP don't have enough patience to see your competitors/alternatives in market. they may be competitor for you but for developer other alternatives to CR are just like another solution. When your buggy product is not able to help a developer then a developer will have to look towards other alternatives.

SAP claim to be largest group/company in field of Databases and reporting but sorry to say that you are just a big company but are not a good company and you have worst support.
From My side a BIG SHAME ON ALL OF YOUR TEAM AND COMPANY for not offering a proper support your free products.

Sajid.

former_member183750
Active Contributor
0 Kudos

I'm glad you got it working, though I know this does work with frm 4 and 4.5. As I said in the other post, sometimes it's useful to pose the question; why me, why not everyone else?

It's too bad that you feel the way you do about SAP. In out defense, one thing to remember is that these are community forums, not technical support. Technical support you can obtain from the link I posted previously. The forums are a low, low priority for us and phones are much better at troubleshooting.

You also need to think a bit about why it is that I had to ask at least twice for basic information regarding your environment, why it is that you could not tell me the version of the assemblies referenced in your project ("I have not added any CR assembly manually." has nothing to do with the question / answer...), etc.,etc.

- Ludek

former_member292966
Active Contributor
0 Kudos

Hi Sajid,

Did you install .NET 3.5 after uninstalling 4 and 4.5?  I believe you may have run into the same problem I had when .NET 4.0 came out.  My .NET 3.5 framework didn't update all of it's components so .NET 4.0 didn't install properly.

This would be why Crystal is loading properly with 3.5 and not 4 or 4.5.  I didn't know you had 3.5 installed or I would have also recommended uninstalling it as well.

Brian

Answers (0)