Bloqueado Problem accesing Excel sheet from model program

  • sexta-feira, 23 de março de 2012 08:29
     
     

    Hello all,

    I am trying to make a  model which heavily depends on data. For this reason i need to access an excel sheet to find the required data from the model program. The code has no error. However exploring the model gives an error.

    "1 fatal execution failure: Method Microsoft.Office.Interop.Excel.ApplicationClass..ctor doesn't have an entry point.
    Setting type "Microsoft.Office.Interop.Excel.ApplicationClass" to native with "Microsoft.Xrt.Runtime.NativeTypeAttribute" or in XRT.Config file might solve the problem. Spec Explorer 0 0 "

    I cannot find a solution yet. help needed !!!

    Thanks,

    Vivek

Todas as Respostas

  • sexta-feira, 23 de março de 2012 13:26
     
     

    Hi Vivek,

    Do you tried already adding this attribute to your model-namespace:
    [assembly: NativeType(typeof(Sample.MyLoader))]
    and replaced "Sample.MyLoader" with the method accessing the Excel-application-objects?
    Replacing "Sample.MyLoader" with just the Excel-application-object should also work as mentioned in the error message...

    Hope it helps.

    P.S.:

    A full example to reading external data is shown on the Spec Explorer Team Blog:
    http://blogs.msdn.com/b/specexplorer/archive/2011/08/02/how-to-initialize-the-initial-state-from-an-external-source.aspx

  • sexta-feira, 23 de março de 2012 14:33
     
     

    HI, Bububa

    I have already tried that approach

    [

    assembly: Microsoft.Xrt.Runtime.NativeType("Microsoft.Office.Interop.Excel.ApplicationClass")] but it runs into another problem 

    Microsoft.Xrt.RecoverFromFatalErrorException: cannot retrieve generic definition of Microsoft.Office.Interop.Excel.Workbooks.Open

    Any Suggestions!!!

  • sexta-feira, 23 de março de 2012 16:39
     
     Respondido

    Hi Vivek,

    my idea is that you made just

    Microsoft.Office.Interop.Excel.ApplicationClass
    native, but not also
    Microsoft.Office.Interop.Excel.Workbooks

    You can try to
    * Add all classes you find in your error messages with the native attribute.
    Or (I have this setup):
    * Put all your Excel access methods into an own project (project "Helper").
    * Add this project ("Helper") to your references and make only your own Helper class native.

    Hope someone else has an even better solution for you.

    • Sugerido como Resposta Yiming Cao segunda-feira, 26 de março de 2012 05:22
    • Marcado como Resposta Vivek.Vishal segunda-feira, 26 de março de 2012 08:58
    •  
  • segunda-feira, 26 de março de 2012 05:21
     
     Respondido Contém Código

    Hi Vivek,

    It's very likely that Office Interop calls into native code which is not executable by Spec Explorer, so the direction that bububa suggested should be the way to go. You probably want to set all classes under Microsoft.Office.Interop.Excel to native. You can either do it following bububa's suggestion and creating a wrapper for all interop calls and set the wrapper class to native, or alternatively use a regular expression to set all all classes to native in a batch, like:

    [assembly: NativeType("Microsoft.Office.Interop.Excel.*")]

    Thanks, Yiming

    • Marcado como Resposta Vivek.Vishal segunda-feira, 26 de março de 2012 08:58
    •