0
votes

i have a .net app that was in .net 3.0 and using crystal reports 10.5 we migrated to .net 4.5 and a new development/testing web server using .net 4.5 now the application will not load.

the errors that i receive are:

Server Error in '/' Application.

Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load file or assembly 'CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified.

Source Error:

Line 16:     <compilation debug="true" targetFramework="4.5">
Line 17:       <assemblies>
Line 18: <add assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
Line 19:         <add assembly="CrystalDecisions.Shared, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
Line 20:         <add assembly="CrystalDecisions.ReportSource, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />

Source File: E:\IIS_Sites\NOSSA\WebSAR\3.8.1\web.config Line: 18

Assembly Load Trace: The following information can be helpful to determine why the assembly 'CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' could not be loaded.

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll Running under executable c:\windows\system32\inetsrv\w3wp.exe --- A detailed error log follows.

=== Pre-bind state information === LOG: DisplayName = CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304 (Fully-specified) LOG: Appbase = file:///C:/inetpub/wwwroot/ LOG: Initial PrivatePath = C:\inetpub\wwwroot\bin

Calling assembly : (Unknown).

LOG: This bind starts in default load context. LOG: Using application configuration file: C:\inetpub\wwwroot\web.config LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. LOG: Post-policy reference: CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304 LOG: The same bind was seen before, and was failed with hr = 0x80070002.

i have installed the crystal runtime.

i'm not sure what else to try.

thanks

1

1 Answers

0
votes

Are the following files in the bin directory of your website/application? crystaldecisions.crystalreports.engine.dll, crystaldecisions.reportsource.dll, crystaldecisions.shared.dll, crystaldecisions.web.dll.

Also, I believe that version of CR is compiled under .NET 2.0 so you may need to enable the legacyV2 runtime. You can do so via the app.config file by adding useLegacyV2RuntimeActivationPolicy="true" to the startup element. Or, you can do it in code by using the RuntimePolicyHelper class. eg.

Imports System.Runtime.InteropServices
Imports System.Runtime.CompilerServices

'instantiate your class

Public Sub New()

    Try
        'runtime support for mixed mode assemblies
        'this is used to load .NET 2.0 assemblies that crystal reports is built against.
        If RuntimePolicyHelper.LegacyV2RuntimeEnabledSuccessfully = True Then

        Else
            If MsgBox("Legacy CLR could not be loaded. Continue?", _
                      vbYesNo + vbExclamation, _
                      "Failed to load legacy runtime.") = vbNo Then
                Application.Exit()
            End If
        End If
    Catch ex As Exception
        ex = New Exception(ex.Message & vbCrLf & ex.StackTrace)
        Throw ex
    End Try

End Sub

Public NotInheritable Class RuntimePolicyHelper
    Private Sub New()
    End Sub
    Public Shared Property LegacyV2RuntimeEnabledSuccessfully() As Boolean
        Get
            Return m_LegacyV2RuntimeEnabledSuccessfully
        End Get
        Private Set(value As Boolean)
            m_LegacyV2RuntimeEnabledSuccessfully = value
        End Set
    End Property

    Private Shared m_LegacyV2RuntimeEnabledSuccessfully As Boolean

    Shared Sub New()
        Try

            Dim clrRuntimeInfo As ICLRRuntimeInfo = _
              DirectCast(RuntimeEnvironment.GetRuntimeInterfaceAsObject(Guid.Empty, _
              GetType(ICLRRuntimeInfo).GUID), ICLRRuntimeInfo)
            Try
                clrRuntimeInfo.BindAsLegacyV2Runtime()
                LegacyV2RuntimeEnabledSuccessfully = True
            Catch generatedExceptionName As COMException
                LegacyV2RuntimeEnabledSuccessfully = False
            End Try

        Catch ex As Exception
            ex = New Exception(ex.Message & vbCrLf & ex.StackTrace)
            Throw ex
        End Try
    End Sub



    <ComImport()> _
    <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _
    <Guid("xxxxxxx-xxxxxxx-xxxxxxx-xxxxxxx")> _
    Private Interface ICLRRuntimeInfo
        Sub xGetVersionString()
        Sub xGetRuntimeDirectory()
        Sub xIsLoaded()
        Sub xIsLoadable()
        Sub xLoadErrorString()
        Sub xLoadLibrary()
        Sub xGetProcAddress()
        Sub xGetInterface()
        Sub xSetDefaultStartupFlags()
        Sub xGetDefaultStartupFlags()

        <MethodImpl(MethodImplOptions.InternalCall, _
           MethodCodeType:=MethodCodeType.Runtime)> _
        Sub BindAsLegacyV2Runtime()
    End Interface
End Class

Please note that I didn't come up with this code - I may have even found it on this site - but I can't find the original contributor. However, it works for me so you may want to give it a try.