Solved

Primary Interop Assembly Missing

Posted on 2009-05-06
9
1,701 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

729 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