Solved

Primary Interop Assembly Missing

Posted on 2009-05-06
9
1,664 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
  • 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
 
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now