Unable to load assembly - System.Web.Http, Version=4.0.0.0

7 posts, 0 answers
  1. Vikash
    Vikash avatar
    14 posts
    Member since:
    Nov 2013

    Posted 19 Jan 2015 Link to this post

    I am trying to configure Telerik Reporting into MVC application.
    The things which are done.
    1. Installed libraries: Data Access(2014.3.1209.1), Telerik Report (8.2.14.1204), System.Web.Http(5.2.2.0)

    2. Registered Reporting route on WebApiConfig.
    Telerik.Reporting.Services.WebApi.ReportsControllerConfiguration.RegisterRoutes(config);

    3. Added reporting controller
        public class ReportsController : ReportsControllerBase
        {
            protected override IReportResolver CreateReportResolver()
            {
                var reportsPath = HttpContext.Current.Server.MapPath("~/Reports");

                return new ReportFileResolver(reportsPath)
                    .AddFallbackResolver(new ReportTypeResolver());
            }

            protected override ICache CreateCache()
            {
                return Telerik.Reporting.Services.Engine.CacheFactory.CreateFileCache();
            }
        }

    While building application I am getting this error:
    ----------------------------------------------------------------------------------------
    Unable to load assembly 'Project.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' : Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. General Exception (Exception from HRESULT: 0x80131500)
    ExceptionString:
    System.SystemException: Unable to load assembly 'Project.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' : Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. General Exception (Exception from HRESULT: 0x80131500) ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
       at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
       at System.Reflection.RuntimeModule.GetTypes()
       at System.Reflection.Assembly.GetTypes()
       at Telerik.OpenAccess.Metadata.MetadataAttributesReader.PrepareMetaModelTypes(Assembly assembly)
       --- End of inner exception stack trace ---
       at Telerik.OpenAccess.Metadata.MetadataAttributesReader.PrepareMetaModelTypes(Assembly assembly)
       at Telerik.OpenAccess.Metadata.MetadataAttributesReader.ReadMetaModel(Assembly assembly)
       at Telerik.OpenAccess.Metadata.AttributesMetadataSource.<>c__DisplayClass1.<FromAssembly>b__0()
       at Telerik.OpenAccess.Metadata.AttributesMetadataSource.CreateModel()
       at Telerik.OpenAccess.Metadata.MetadataSource.GetModelCore(MetadataContainer old)
       at Telerik.OpenAccess.Sdk.Enhancer.Enhancer.CrossDomainRunImpl(AssemblyLoader assemblyLoader)
       at Telerik.OpenAccess.Sdk.Enhancer.EnhancerBase.CrossDomainRun()    C:\Projects\ProjectAbc\Project.Web\obj\Debug\Project.Web.dll    Project.Web

    ----------------------------------------------------------------------------------------

    Yes, this clearly means that mapping is missed out for System.Web.Http but it is being set correctly:
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
          </dependentAssembly>

    From error it seems like, it is related to Data Access but if I comment entire class (ReportsController) from step 3 then it is working fine. Also during upgrade I have cleared cache from every possible location .Net Temp, bin folder, checked proper reference of libraries. This is my first attempt to use Telerik reporting on my existing application.

    Please suggest what needs to be done.

  2. Vikash
    Vikash avatar
    14 posts
    Member since:
    Nov 2013

    Posted 20 Jan 2015 Link to this post

    Just to add to add more clarification on above point.
    If I comment out ReportsController class then I am not getting any compile time error also if I load[Assembly.Load("System.Web.Http")] up System.Web.Http assembly it is working fine with 5.2.2.0 version.

    I had also tried creating entirely fresh project to test Telerik Reporting which is working very well.
  3. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 22 Jan 2015 Link to this post

    Hello Vikash,

    We tested the reported problem with the project in the attachment:
    • VS 2012;
    • Telerik Data Access Nuget packages v2014.3.1209.1;
    • Telerik Reporting v8.2.14.1222 (the latest available internal build);
    • Build and Run the report preview in browser - successfully;

    Please compare your settings and if the problem is still reproducible open a support ticket and send us a demo project or exact steps how to reproduce the problem. Test also if adding the binding redirects in VS configuration file (devenv.exe.config) resolves the issue.

    Regards,
    Stef
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  4. Vikash
    Vikash avatar
    14 posts
    Member since:
    Nov 2013

    Posted 28 Jan 2015 in reply to Stef Link to this post

    On fresh application it is working fine. The provided application and our any newly created application are working well.
    After enabling Fusion Log https://msdn.microsoft.com/en-us/library/e74a18c4%28v=vs.110%29.aspx. I am able to see the request is being made by "Telerik.Reporting.Services.WebApi" for "System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
    Here is the log file:
    ------------------------------------------------------------------------------------------------------------------

    *** Assembly Binder Log Entry  (28-Jan-15 @ 12:32:32 PM) ***

    The operation failed.
    Bind result: hr = 0x80070002. The system cannot find the file specified.

    Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
    Running under executable  C:\Program Files (x86)\MSBuild\12.0\bin\MSBuild.exe
    --- A detailed error log follows. 

    === Pre-bind state information ===
    LOG: DisplayName = System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
     (Fully-specified)
    LOG: Appbase = file:///C:/Program Files (x86)/Telerik/Data Access/sdk
    LOG: Initial PrivatePath = NULL
    LOG: Dynamic Base = NULL
    LOG: Cache Base = NULL
    LOG: AppName = NULL
    Calling assembly : Telerik.Reporting.Services.WebApi, Version=8.2.14.1204, Culture=neutral, PublicKeyToken=a9d7983dfcc261be.
    ===
    LOG: This bind starts in default load context.
    LOG: Using application configuration file: C:\Program Files (x86)\MSBuild\12.0\bin\MSBuild.exe.Config
    LOG: Using host configuration file: 
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
    LOG: Post-policy reference: System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    LOG: GAC Lookup was unsuccessful.
    LOG: Attempting download of new URL file:///C:/Program Files (x86)/Telerik/Data Access/sdk/System.Web.Http.DLL.
    LOG: Attempting download of new URL file:///C:/Program Files (x86)/Telerik/Data Access/sdk/System.Web.Http/System.Web.Http.DLL.
    LOG: Attempting download of new URL file:///C:/Program Files (x86)/Telerik/Data Access/sdk/System.Web.Http.EXE.
    LOG: Attempting download of new URL file:///C:/Program Files (x86)/Telerik/Data Access/sdk/System.Web.Http/System.Web.Http.EXE.
    LOG: All probing URLs attempted and failed.

    *** Assembly Binder Log Entry  (28-Jan-15 @ 12:32:32 PM) ***

    The operation failed.
    Bind result: hr = 0x80070002. The system cannot find the file specified.

    Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
    Running under executable  C:\Program Files (x86)\MSBuild\12.0\bin\MSBuild.exe
    --- A detailed error log follows. 

    === Pre-bind state information ===
    LOG: DisplayName = System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
     (Fully-specified)
    LOG: Appbase = file:///C:/Program Files (x86)/Telerik/Data Access/sdk
    LOG: Initial PrivatePath = NULL
    LOG: Dynamic Base = NULL
    LOG: Cache Base = NULL
    LOG: AppName = NULL
    Calling assembly : Telerik.Reporting.Services.WebApi, Version=8.2.14.1204, Culture=neutral, PublicKeyToken=a9d7983dfcc261be.
    ===
    LOG: This bind starts in default load context.
    LOG: Using application configuration file: C:\Program Files (x86)\MSBuild\12.0\bin\MSBuild.exe.Config
    LOG: Using host configuration file: 
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
    LOG: Post-policy reference: System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    LOG: GAC Lookup was unsuccessful.
    LOG: Attempting download of new URL file:///C:/Program Files (x86)/Telerik/Data Access/sdk/System.Web.Http.DLL.
    LOG: Attempting download of new URL file:///C:/Program Files (x86)/Telerik/Data Access/sdk/System.Web.Http/System.Web.Http.DLL.
    LOG: Attempting download of new URL file:///C:/Program Files (x86)/Telerik/Data Access/sdk/System.Web.Http.EXE.
    LOG: Attempting download of new URL file:///C:/Program Files (x86)/Telerik/Data Access/sdk/System.Web.Http/System.Web.Http.EXE.
    LOG: All probing URLs attempted and failed.

    ---------------------------------------------------------------------------------------------------------------

    After further investigation I have found that it is not asking for System.Web.Http on compilation on new application for Telerik Reporting. Also If I remove "ReportsController" from existing application then it is not looking for System.Web.Http-4.0.0.0.

    When I have put System.Web.Http-4.0.0.0 under C:\Program Files (x86)\Telerik\Data Access\sdk then it started work fine.
    This worked but not sure whether it is going to work on hosted server. Please let me know if you have any other alternative for this.

  5. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 29 Jan 2015 Link to this post

    Hello Vikash,

    Telerik Reporting REST WebAPI service has dependency on System.Web.Http.dll 4.0.0.0, which is why the later is loaded. If the assembly is already referenced in the project and has different version, you will need to add proper binding redirects per How To: Add Telerik Reporting REST Web API to Web Application.

    The problem is not reproducible in our tests. Thus please check if deploying the current test project runs as expected in test environment without installed Telerik Reporting and Telerik Data Access on the machine.


    If the problem still occurs with the suggested deployment test, please open a support ticket and send us the tested project to check its settings.

    Regards,
    Stef
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Vikash
    Vikash avatar
    14 posts
    Member since:
    Nov 2013

    Posted 29 Jan 2015 in reply to Stef Link to this post

    Hello Stef,

    Yes, as mentioned in my first comment I have already set those as per the link you have shared. I understand that it is really difficult to get exact thing without code base but in my situation I am not able to reproduce in fresh projects.

    On server application is getting the new version of System.Web.Http. Don't know, somehow the issue is related to that particular application but all binding configuration and other settings are checked carefully.

    Anyway the above solution that I mentioned is working out and also I have tried hosting the application, it is working well. 

    Thank You,
    Vikash Kumar.

  7. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 30 Jan 2015 Link to this post

    Hi Vikash,

    If you have time and manage to reproduce the problem in a demo project, we will appreciate it if you open a support ticket and send us the project for further investigation.

    Thank you for your cooperation.

    Regards,
    Stef
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top