ASP.Net Web API Could not load file or assembly 'System.Web.Http

2 posts, 0 answers
  1. Dave Miller
    Dave Miller avatar
    64 posts
    Member since:
    Oct 2004

    Posted 12 Jun 2013 Link to this post

    I have been trying to use the Web API as an Open Access Service and continue to get the build error below. I have tried using the wizard as well as all the ways of manually adding it that are described at http://www.telerik.com/support/kb/orm/general/manually-install-web-api-service-references.aspx all which leads to the same build error. Interestingly I can install both OpenAccess or the ASP.Net API seperately with no problems. It is only when I try to use the API as an OpenAcces Service that I have the problems.

    I am trying to add it to an ASP.Net 4.0 web Application and I am using VS 2010 sp1 on windows 7 Professional. I have tried adding it to my working application as well as creating new ones with nothing else in them and still get the same result.

    The error is below and any help would be greatly appreciated.

    Thanks,
    Dave

    Error 1 Unable to load assembly 'WebApplication1, 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. Operation is not supported. (Exception from HRESULT: 0x80131515)
    ExceptionString:
    System.SystemException: Unable to load assembly 'WebApplication1, 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. Operation is not supported. (Exception from HRESULT: 0x80131515) ---> 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() \\VALINOR\VirtualDir4\WebApplication1\WebApplication1\obj\Debug\WebApplication1.dll WebApplication1

  2. Yordan
    Admin
    Yordan avatar
    39 posts

    Posted 14 Jun 2013 Link to this post

    Hello Dave,

    Two things may be the reason for the described error:

    1) The web application cannot execute assemblies from remote sources. More on that matter can be found in this article. Could you please add this code block to the web.config file:
    <configuration>
       <runtime>
          <loadFromRemoteSources enabled="true"/>
       </runtime>
    </configuration>

    2) Find the folder that contains the 'System.Web.Http.dll' assembly. Right click the assembly. If a button called Unblock is visible click it - see the attached picture as an example.

    If the suggested approaches do not help in you scenario could you please send us a sample project so we can test it in our environment?

    If you have any more questions or issues please do not hesitate to get back to us for assistance.
     
    Regards,
    Yordan
    Telerik
    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
  3. DevCraft banner
Back to Top