Problem accesing Excel sheet from model program
-
2012年3月23日 8: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
すべての返信
-
2012年3月23日 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 -
2012年3月23日 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!!! -
2012年3月23日 16:39
Hi Vivek,
my idea is that you made just
Microsoft.Office.Interop.Excel.ApplicationClass
native, but not also
Microsoft.Office.Interop.Excel.WorkbooksYou 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.
- 回答の候補に設定 Yiming Cao 2012年3月26日 5:22
- 回答としてマーク Vivek.Vishal 2012年3月26日 8:58
-
2012年3月26日 5:21
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
- 回答としてマーク Vivek.Vishal 2012年3月26日 8:58

