This is a migrated thread and some comments may be shown as answers.

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

4 Answers 295 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Christian
Top achievements
Rank 1
Christian asked on 27 Nov 2009, 03:59 PM
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

4 Answers, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 03 Dec 2009, 07:06 AM
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.
0
Christian
Top achievements
Rank 1
answered on 03 Dec 2009, 10:45 AM
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

0
Christian
Top achievements
Rank 1
answered on 03 Dec 2009, 11:18 AM
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
0
PetarP
Telerik team
answered on 04 Dec 2009, 03:10 PM
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.
Tags
General Discussions
Asked by
Christian
Top achievements
Rank 1
Answers by
PetarP
Telerik team
Christian
Top achievements
Rank 1
Share this question
or