"Could not load file or assembly" at Telerik.OpenAccess.Database.Get

Thread is closed for posting
5 posts, 0 answers
  1. Christian
    Christian avatar
    3 posts
    Member since:
    Sep 2008

    Posted 27 Nov 2009 Link to this post

    When I'm requesting an ObjectScope from by ObjectScopeProvider for the first time, OpenAccess is throwing the following exception:

    System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.
    File name: 'Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
       at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
       at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
       at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
       at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
       at Telerik.OpenAccess.SPI.Util.AssemblyHelper.Load(AssemblyName name)
       at Telerik.OpenAccess.Config.References.ReferencesManager.FillReferences(Assembly[] rootAssemblies, AssemblyProvider asmProvider, ReferenceData[] refs)
       at Telerik.OpenAccess.Config.ConfigManager.Init()
       at Telerik.OpenAccess.Config.ConfigManager.GetConnectionData(String apiUser, String apiPassword, ArrayList mappingXmlNodes, ArrayList mappingSources, Boolean partial)
       at Telerik.OpenAccess.Config.ConfigManager.GetConnectionData(String apiUser, String apiPassword, Boolean partial)
       at Telerik.OpenAccess.Config.ConfigManager.MapConnectionId2Url()
       at Telerik.OpenAccess.DBRegistry.GetDatabase(String urlOrConnectionId, XmlElement configOverride, Assembly[] entryAssemblies)
       at Telerik.OpenAccess.DBRegistry.GetDatabase(String urlOrConnectionId, XmlElement configOverride)
       at Telerik.OpenAccess.Database.Get(String connectionId)
       at Common.DataAccess.AvpObjectScopeProvider.Database() in c:\Develop\src\MAIN\source.Common\DataAccess\DataAccess\AvpObjectScopeProvider.cs:line 57
       at Common.DataAccess.AvpObjectScopeProvider.ObjectScope() in c:\Develop\src\MAIN\source.Common\DataAccess\DataAccess\AvpObjectScopeProvider.cs:line 69
       at Common.DataAccess.DataAccess.GetObjectScope(enumDatenbank datenbank) in c:\Develop\src\MAIN\source.Common\DataAccess\DataAccess\DataAccess.cs:line 55
       at Common.DataAccess.DataAccess.GetReFiEingangTable() in c:\Develop\src\MAIN\source.Common\DataAccess\DataAccess\DataAccess.cs:line 39
       at OpenAccessAssemblyLoaderTest.StartForm.StartForm_Load(Object sender, EventArgs e) in C:\Develop\OpenAccessAssemblyLoaderTest\OpenAccessAssemblyLoaderTest\StartForm.cs:line 36


    Why is OpenAccess trying to load the assembly Microsoft.Office.Interop.Excel? I'm only using one enhanced assembly which is referenced in my app.config:

      <openaccess xmlns="http://www.telerik.com/OpenAccess">
        <references />
        <connections>
          <connection id="MyConnection">
            ...
            <reference assemblyname="DataAccess.ReFi" configrequired="True" />
          </connection>
        </connections>
        ...
      </openaccess>

    Greetings,
    Christian
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 03 Dec 2009 Link to this post

    Hi Christian,

    Can you please provide us with more detailed information on which assemblies are referenced in your failing project? This would most certainly help us to locate the problem. Thank you in advance for your cooperation.

    Sincerely yours,
    Petar
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Christian
    Christian avatar
    3 posts
    Member since:
    Sep 2008

    Posted 03 Dec 2009 Link to this post

    Hi Petar,

    please see attached screenshot for a full list of the referenced assemblies.

    DataAccess.ReFi.dll is the enhanced assembly which contains the persistent objects (in this example ReFiEingang). This one is referenced in my app.config.
    DataAccess.Contracts.dll and Types.dll contain interfaces for the objects in DataAccess.ReFi.

    That's about it.

    To make sure that the assembly Microsoft.Office.Interop.Excel is included in my applications manifest, I included the following two lines:

    Microsoft.Office.Interop.Excel.Application ExcelApp = null
    Microsoft.Office.Interop.Excel.Workbook ExcelDoc = null

    You can see the rest of the code in the screenshot (except ObjectContextProvider.cs and Programm.cs which only contain code generated by Visual Studio and OpenAccess).

    Sincerely,
    Christian

  4. Christian
    Christian avatar
    3 posts
    Member since:
    Sep 2008

    Posted 03 Dec 2009 Link to this post

    Maybe I should add some more details about Microsoft.Office.Interop.Excel.

    The application uses version 12 of this assembly (that is Office 2007). On my development machine this works fine.

    The clients where we deploy the application don't have Office 2007 installed. So the assembly actually is missing. I can get rid of the exception by copying the assembly from my development machine and putting it into the application's directory.

    However, my question is: why does OpenAccess care about this assembly at all? Our application (the real one, not the demo I've been describing in my last post) imports more than 50 assemblies. Obviously OpenAccess tries to load every single one of them. Because when I'm creating an ObjectScope for the first time, this takes several (up to 25) seconds. Why?

    Sincerely,
    Christian
  5. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 04 Dec 2009 Link to this post

    Hi Christian,

    This is done because we are traverse all referenced assemblies and try to load them if needed. This is now fixed and it will not be rising any exceptions with the next internal build that will be available either today or in Monday latest. Sorry for the inconvenience this might have caused.

    Kind regards,
    Petar
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top