Solved

Primary Interop Assembly Missing

Posted on 2009-05-06
9
1,696 Views
Last Modified: 2013-11-26
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
Comment
Question by:nmcdermaid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
9 Comments
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
ID: 24322931
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
 
LVL 30

Author Comment

by:nmcdermaid
ID: 24331400
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
 
LVL 30

Author Comment

by:nmcdermaid
ID: 24331417
Forgot to add screenshot...
ReferencesInSSIS.jpg
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 24336584
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
 
LVL 30

Author Comment

by:nmcdermaid
ID: 24341910
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
 
LVL 30

Author Comment

by:nmcdermaid
ID: 24372788
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
 
LVL 30

Author Comment

by:nmcdermaid
ID: 24542973
Can anyone explain that?
0
 
LVL 30

Author Closing Comment

by:nmcdermaid
ID: 31578849
You've added to my .Net knowledge although the primary question wasn't answered. Thanks for your help anyway.
0
 
LVL 30

Author Comment

by:nmcdermaid
ID: 25020253
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question