• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1824
  • Last Modified:

Primary Interop Assembly Missing

This is related to this question, which I am assisting with:

http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/Q_24357093.html

Basically, I cannot find the

Microsoft.Office.Interop.Excel

assembly in my .Net references window. (under Project/Add Reference). I can't find it in Visual Studio, or the SSIS .Net script editor

I have found a file called

Microsoft.Office.Interop.Excel

In the C:\Windows\assembly folder.

I have also installed the Redistributable Primary Interop Assemblies from here:

http://www.microsoft.com/downloads/details.aspx?familyid=59DAEBAA-BED4-4282-A28C-B864D8BFA513&displaylang=en


I am a vb 6 developer, not a .Net developer. I basically want to control Excel through the Excel object model and I do not want to use the COM objects directly.


My understanding is that I need to reference this assembly to do this.


Just another question: Is this statement:

Imports Microsoft.Office.Interop.Excel

equivalent to adding the reference to the project from the menu? I first picked up on this issue when the Import statement said it couldn't find the reference. Do I need to do both or would the Imports statement alone be sufficient normally?

I am using Visual Studio 2005 8.0.50727.867
I have Microsoft .Net Framework 2.0.50727 installed

I assume when I get this assembly to appear in VS, it will appear in the SSIS editor (which is my real goal)
VSVersion.jpg
0
nmcdermaid
Asked:
nmcdermaid
  • 7
1 Solution
 
Wayne Taylor (webtubbs)Commented:
To add a reference, you will need to look under the "COM" tab of the references dialog. It will be called "Microsoft Excel XX.0 Object Library", where "XX" is the version of Excel.

A reference is required before it can be "Imported". The Imports keyword allows a namespace to be accessed directly, which will mean that you can declare objects like this....

    Dim xlApp As Application

...instead of like this....

    Dim xlApp As Microsoft.Office.Interop.Excel.Application

A side note - when I import Excel, I use this construct....

    Imports Excel = Microsoft.Office.Interop.Excel

...which allows me to declare objects in such a way that I can easily see what namespace they are from....

    Dim xlApp As Excel.Application

Wayne
0
 
nmcdermaidAuthor Commented:
Only one problem: the SSIS visual studio editor does not have a COM tab it only has a .Net tab. I'm not sure why this is.
I see that .Net has the CreateObject statement. That would probably allow me to get around not having a 'COM' tab.
 
So if I understand correctly, the Imports keyword is a way of making a particular namespace 'pre-selected' in the editor, kind of similiar to 'With' in VB6?. You always need to add the reference under the menu, the imports is a just a way of making your code neat and making the namespace 'pre existing'?
 
0
 
nmcdermaidAuthor Commented:
Forgot to add screenshot...
ReferencesInSSIS.jpg
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Anurag ThakurTechnical ManagerCommented:
i see u r using VS 2005 professional, its surprising why are u not getting the tabs that we normally get
what kind of project are you using please explain it

here are a few samples hot to automate excel
http://support.microsoft.com/kb/302096
http://www.codeproject.com/KB/office/package.aspx
0
 
nmcdermaidAuthor Commented:
Sorry I didn't make it very clear. The purpose of this is to automate Excel from SQL Server Integration Services (SSIS). SSIS has a 'script' task which lets you write .Net script. It seems it only lets you reference .Net assemblies though.
I have plenty of experience automating Excel through VB6 and COM but none through .Net and Assemblies. It looks like I may need to use CreateObject to instantiate the various COM objects.
 
0
 
nmcdermaidAuthor Commented:
I've used CreateObject but I needed to tick 'Option Strict On by default' to enable late binding.
Can someone clarify: even though I have installed the assembly, and can see the assembly in C:\Windows\Assembly, why can't I see it in the .Net references tab?
0
 
nmcdermaidAuthor Commented:
Can anyone explain that?
0
 
nmcdermaidAuthor Commented:
You've added to my .Net knowledge although the primary question wasn't answered. Thanks for your help anyway.
0
 
nmcdermaidAuthor Commented:
I've found this information:
The .NET tab of the Add Reference dialog box in Microsoft Visual Studio for Applications lists the managed assemblies found in the %windir%\Microsoft.NET\Framework\v2.0.xxxxx folder. Therefore, by default, this list is largely limited to assemblies from the Microsoft .NET Framework class library. The contents of the list are determined exclusively by file location and not by installation in the global assembly cache (GAC) or by other assembly attributes or properties. Therefore, a copy of any assembly that you want to reference must be present in the specified folder. The Add Reference dialog box in VSA does not include the Browse button that is present in Microsoft Visual Studio for locating and referencing managed assemblies in other folders, and does not include the COM tab for referencing COM components.
at this site:
http://msdn.microsoft.com/en-us/library/ms136033(SQL.90).aspx
 This explains my issue. Basically I needed to copy the Microsoft.Office.Interop.Excel
 file into %windir%\Microsoft.NET\Framework\v2.0.xxxxx folder
I have not tested this but I'm pretty sure that was my issue.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now