cancel
Showing results for 
Search instead for 
Did you mean: 

The type initializer for 'CrystalDecisions.Shared.SharedUtils' threw an exc

Former Member
0 Kudos

I'm new to Crystal Reports and trying to work my way into it.

I created a form and dropped a CrystalReportViewer onto it. I set the ReportSource to a .rpt file that I also created.

When I run my VB.NET 2010 application and click the button to open up the Viewer form I get the following error:

The type initializer for 'CrystalDecisions.Shared.SharedUtils' threw an exception.

The details says that it's the log4net error that I've seen on here in several threads. I followed these directions from another thread:


- Go into your project Properties.
- Then go to the Publish tab. 
- Click the Application Files button.
- Select to Exclude any file with CrystalDecisions or BusinessObjects in the name. Plus exclude log4net.dll.
- Click OK
- Rebuild your application, then republish it to your site or file share to be installed by your clients.

No luck with that.

I then tried changing my my compile options from AnyCPU to x86 but that crashes the program on startup by complaining about my OdbcConnection.

Any suggestions are greatly appreciated.

I'm running Visual Studio 2010 on a Win 7 64-bit computer. I tried the same process in a new project and it worked there, but without actually connecting to a DSN database. I assume I have something configured wrong in my actual application but I don't know enough about Crystal Reports yet to know what to look for.

Edited by: wolfmanyoda on Jan 15, 2011 4:14 AM

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Set your project framework to 4.0, not the client version.

Don't use c:\temp, rename it to c:\mytemp

Use a report with saved data then it doesn't need a DB connection as a test. Create your DSN using the 32 bit ODBC administrator in \syswow64 folder for 32 bit applications.

Have a look at these samples:

Root Page

http://wiki.sdn.sap.com/wiki/display/BOBJ/BusinessObjectsHome

Enterprise Samples (including managed and unmanaged ras)

http://wiki.sdn.sap.com/wiki/display/BOBJ/BusinessObjectsSDKSampleApplications

Non-Enterprise Samples

http://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsSDKSampleApplications

Exporting Samples (RAS)

http://wiki.sdn.sap.com/wiki/display/BOBJ/NETRASSDK+Samples#NETRASSDKSamples-Exporting%2FPrinting

Thank you

Don

Former Member
0 Kudos

Yes, I neglected to mention I already set the project to Framework 4.0.

I will try a report with saved data, but I'm not sure what C:\temp folder you are referring to.

I will also go through the links you sent me.

Thank you, I will report back what happens.

0 Kudos

Some people create a temp folder off their root drive C. I've discovered it can cause problems if one exists. CR uses one also and some xml files can cause the DB Expert to crash.

Also what CR assemblies are you adding to your Project?

Thanks again

Don

Former Member
0 Kudos

I am using:

CrystalDecisions.CrystalReports.Engine

CrystalDecisions.ReportSource

CrystalDecisions.Shared

CrystalDecisions.Windows.Forms

Thanks

0 Kudos

See this post and the reply on Jan, 13th and how to create a new VB project:

See if that works for you.

Don

Former Member
0 Kudos

Thanks Don.

I don't think my problem is with Crystal Reports. I can start a new project and CR will work great.

My application relies on an Access database. When I switch my compile options from AnyCPU over to x86 I get connection errors to the database, long before the application tries to use a report. This leads me to believe that the problem may be in my DSN settings.

I will try an Access forum and see if I can find answers there.

Thank you for your time.

0 Kudos

That's odd... install MDAC or WDAC from Microsoft, it should have the Access Jet Drivers

Please mark as answered.

Thank you

Don

Former Member
0 Kudos

Ok, I'll give that a shot.

Have a good one.

0 Kudos

Oh and be sure to use the right ODBC Administrator. On 64 bit OS's there is one the Admin tools but for 32 bit applications you have to Create your System DSN using the ODBC admin in \syswow64 directory.

Likely it's not the MDAC issue. I believe MS installs it by default.

Thank you

Don

Former Member
0 Kudos

I switched from a DSN connection to connecting directly to the .accdb file with an oledb connection and it all seems to be working fine now.

Thank you again.

0 Kudos

Thank you for the update. Now that we know it's an Access 2007 database you are correct, the only support we have for that database type is through ODBC or OLE DB.

Thank you

Don

Former Member
0 Kudos

Don Williams,

I have a DSN connection to a MySQL server, not access, and i was getting this issue as well when opening a DSN connection and when i tried to say


crystalreportviewer.ReportSource = input.toString  'input is where the .rpt file is

it would crash and give me this error.

I am forced to use a DSN as he wants to put them on computers so that only those computers could access the db to view the crystalreport.

ideas? Thoughts?

below is the code posted from my program, its not long:


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Dim connectionstring As String
            Dim conn As New OdbcConnection("DSN=lalConnect")
            conn.Open()
            Dim input As String = getfile()
            While (Not (input.Contains(".rpt")))
                MessageBox.Show(input & " is NOT a .rpt file")
                input = getfile()
            End While
            CrystalReportViewer1.ReportSource = input.ToString
            conn.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            'txtUsername.Text = (ex.InnerException.ToString)
        Finally
        End Try
    End Sub

    Function getfile() As String
        Dim item As OpenFileDialog = New OpenFileDialog()
        item.Title = "Find *.rpt file"
        item.InitialDirectory = CurDir()
        item.Filter = "Reports (*.rpt)|*.rpt|All files (*.*)|*.*"
        item.FilterIndex = 2
        item.RestoreDirectory = True
        item.ShowDialog()
        Return item.FileName
    End Function

0 Kudos

New issue, this post was marked as answered. Re-post your question along with version you are using.

Search first for an answer before posting though.

Thank you

Don

Answers (0)