473,236 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,236 software developers and data experts.

Need help adding reference to Microsoft.Office.Core

Hi all,

Using C#, I've created a simple wrapper class for using Excel. I have
Office Pro 2003 installed on my devel machine. The wrapper class works
great, reading and writing to/from Excel. To do this, I created a
reference to "Microsoft Excel 11.0 Object Library", and have a "using
Excel;" directive.

I decided to add a method for creating a TextBox using the
Shapes.AddTextBox method, which requires a
Microsoft.Office.Core.MsoTextOrientation as a parameter. Unfortunately,
I can't find what I need to reference to get the Microsoft.Office.Core
namespace into my project. I've tried adding references to "Microsoft
Office 11.0 Object Library" in COM, but that didn't provide me with the
needed namespace.

I then added a reference to "Office" (version 11.0.0.0) in the GAC, and
received the following errors:

D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(303,10 ) : error CS0012: The
type 'Microsoft.Office.Core.MsoTextOrientation' is defined in an
assembly that is not referenced. You must add a reference to assembly
'office, Version=11.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c'.
D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(303,20 ) : error CS1502: The
best overloaded method match for
'Excel.Shapes.AddTextbox(Microsoft.Office.Core.Mso TextOrientation,
float, float, float, float)' has some invalid arguments
D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(305,17 ) : error CS1503:
Argument '1': cannot convert from
'Microsoft.Office.Core.MsoTextOrientation
[c:\WINDOWS\assembly\GAC\Office\7.0.3300.0__b03f5f7 f11d50a3a\Office.dll]'
to 'Microsoft.Office.Core.MsoTextOrientation []'

Any help would be greatly appreciated,
Michael

May 26 '06 #1
5 49681
Michael Russell wrote:
Hi all,

D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(303,10 ) : error CS0012: The
type 'Microsoft.Office.Core.MsoTextOrientation' is defined in an
assembly that is not referenced. You must add a reference to assembly
'office, Version=11.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c'.
D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(303,20 ) : error CS1502: The
best overloaded method match for
'Excel.Shapes.AddTextbox(Microsoft.Office.Core.Mso TextOrientation,
float, float, float, float)' has some invalid arguments
D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(305,17 ) : error CS1503:
Argument '1': cannot convert from
'Microsoft.Office.Core.MsoTextOrientation
[c:\WINDOWS\assembly\GAC\Office\7.0.3300.0__b03f5f7 f11d50a3a\Office.dll]'
to 'Microsoft.Office.Core.MsoTextOrientation []'

Any help would be greatly appreciated,
Michael


No one has any input? This is a real problem for me, I could really use
some pointers.

Michael
May 27 '06 #2
Hi Michael,

Without seeing your code also, it is hard to tell what the exact problem is.
Maybe something accidentally got out of whack with changing references and
all. Try this to get things back to normal:

1. Delete the "Excel", "Microsoft.Office.Core", and "VBIDE" references from
your project.
2. Right-click on References and select "Add Reference"
3. Click the COM tab.
4. Select Microsoft Excel 11.0 Object Library and click OK.
5. You should see Excel, Microsoft.Office.Core, and VBIDE in your
references list.

If you don't see those items (from #5) in your references list, you may not
have Office PIAs installed properly. You may have to uninstall and
reinstall them. Another alternative is to go into the Excel installation
process and find the process that allows you to select which components are
installed. There is an option to install .NET or Managed code
programability options, which will ensure PIAs are installed for you.

Here's some code I ran to try to reproduce your problem. However, following
the procedures I used above, it worked just fine:

using System;
using System.Collections.Generic;
using System.Text;

namespace OfficeAppTest
{
class Program
{
static void Main(string[] args)
{
Microsoft.Office.Core.MsoTextOrientation orientation =
Microsoft.Office.Core.MsoTextOrientation.msoTextOr ientationHorizontal;
}
}
}

Your error message also indicates that it is possible that the method you
are trying to use takes only a single instance of MsoTextOrientation, but
you are trying to give it an array of MsoTextOrientation
(MsoTextOrientation[]), which are different types.

If you do post some code, you should make it the smallest example possible
that I can cut-and-paste so I can see the problem for myself. A large
listing that doesn't compile is often not much use.

Joe
--
http://www.csharp-station.com

"Michael Russell" <mr*******@hotmail.com> wrote in message
news:uX**************@TK2MSFTNGP02.phx.gbl...
Michael Russell wrote:
Hi all,

D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(303,10 ) : error CS0012: The
type 'Microsoft.Office.Core.MsoTextOrientation' is defined in an assembly
that is not referenced. You must add a reference to assembly 'office,
Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.
D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(303,20 ) : error CS1502: The
best overloaded method match for
'Excel.Shapes.AddTextbox(Microsoft.Office.Core.Mso TextOrientation, float,
float, float, float)' has some invalid arguments
D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(305,17 ) : error CS1503:
Argument '1': cannot convert from
'Microsoft.Office.Core.MsoTextOrientation
[c:\WINDOWS\assembly\GAC\Office\7.0.3300.0__b03f5f7 f11d50a3a\Office.dll]'
to 'Microsoft.Office.Core.MsoTextOrientation []'

Any help would be greatly appreciated,
Michael


No one has any input? This is a real problem for me, I could really use
some pointers.

Michael

May 27 '06 #3
Joe Mayo [C# MVP] wrote:
Hi Michael,

Without seeing your code also, it is hard to tell what the exact problem is.
Maybe something accidentally got out of whack with changing references and
all. Try this to get things back to normal:

1. Delete the "Excel", "Microsoft.Office.Core", and "VBIDE" references from
your project.
2. Right-click on References and select "Add Reference"
3. Click the COM tab.
4. Select Microsoft Excel 11.0 Object Library and click OK.
5. You should see Excel, Microsoft.Office.Core, and VBIDE in your
references list.
Tried this, VBIDE and Microsoft.Office.Core never appear in the list of
references.

If you don't see those items (from #5) in your references list, you may not
have Office PIAs installed properly. You may have to uninstall and
reinstall them. Another alternative is to go into the Excel installation
process and find the process that allows you to select which components are
installed. There is an option to install .NET or Managed code
programability options, which will ensure PIAs are installed for you.

Using Office 2003 setup, removed then reinstalled the .Net Programming
support for all the components of Office, the problem remains unchanged.
I also made sure that I've downloaded the SP and updates for Office 2003.

FWIW, while reinstalling the support from the CD, I noticed that it said
that the support is for version 1.1 of the .Net Runtime; the PIA
redistributable on Microsoft's web site also says that 1.1 is required,
no mention of 2.0 or "1.1 or higher". Perhaps this is my problem?

<Sample code deleted>

Your error message also indicates that it is possible that the method you
are trying to use takes only a single instance of MsoTextOrientation, but
you are trying to give it an array of MsoTextOrientation
(MsoTextOrientation[]), which are different types.

If you do post some code, you should make it the smallest example possible
that I can cut-and-paste so I can see the problem for myself. A large
listing that doesn't compile is often not much use.


The section of code where I need the Microsoft.Office.Core reference:

Excel.Shapes shapes = xlWks.Shapes;
xlShape = shapes.AddTextbox(
MsoTextOrientation.msoTextOrientationHorizontal,
(float)left, (float)top, (float)width, (float)height );

I don't think it's a problem with the code, but it won't compile because
I'm unable to get a reference to Microsoft.Office.Core.

Thanks,
Michael
May 28 '06 #4
"Michael Russell" <mr*******@hotmail.com> wrote in message
news:uO****************@TK2MSFTNGP04.phx.gbl...
Joe Mayo [C# MVP] wrote:
Hi Michael,

Without seeing your code also, it is hard to tell what the exact problem
is. Maybe something accidentally got out of whack with changing
references and all. Try this to get things back to normal:

1. Delete the "Excel", "Microsoft.Office.Core", and "VBIDE" references
from your project.
2. Right-click on References and select "Add Reference"
3. Click the COM tab.
4. Select Microsoft Excel 11.0 Object Library and click OK.
5. You should see Excel, Microsoft.Office.Core, and VBIDE in your
references list.


Tried this, VBIDE and Microsoft.Office.Core never appear in the list of
references.

If you don't see those items (from #5) in your references list, you may
not have Office PIAs installed properly. You may have to uninstall and
reinstall them. Another alternative is to go into the Excel installation
process and find the process that allows you to select which components
are installed. There is an option to install .NET or Managed code
programability options, which will ensure PIAs are installed for you.


Using Office 2003 setup, removed then reinstalled the .Net Programming
support for all the components of Office, the problem remains unchanged. I
also made sure that I've downloaded the SP and updates for Office 2003.

FWIW, while reinstalling the support from the CD, I noticed that it said
that the support is for version 1.1 of the .Net Runtime; the PIA
redistributable on Microsoft's web site also says that 1.1 is required, no
mention of 2.0 or "1.1 or higher". Perhaps this is my problem?

<Sample code deleted>

Your error message also indicates that it is possible that the method you
are trying to use takes only a single instance of MsoTextOrientation, but
you are trying to give it an array of MsoTextOrientation
(MsoTextOrientation[]), which are different types.

If you do post some code, you should make it the smallest example
possible that I can cut-and-paste so I can see the problem for myself. A
large listing that doesn't compile is often not much use.


The section of code where I need the Microsoft.Office.Core reference:

Excel.Shapes shapes = xlWks.Shapes;
xlShape = shapes.AddTextbox(
MsoTextOrientation.msoTextOrientationHorizontal,
(float)left, (float)top, (float)width, (float)height );

I don't think it's a problem with the code, but it won't compile because
I'm unable to get a reference to Microsoft.Office.Core.


I was able to get it to work like this:

Excel.Shapes shapes = xlWks.Shapes;
xlShape = shapes.AddTextbox(
Microsoft.Office.Core.MsoTextOrientation.msoTextOr ientationHorizontal,
(float)left, (float)top, (float)width, (float)height );

The only thing now is to get the reference to the Microsoft.Office.Core dll.
Something is keeping it from properly adding the right proxies to your
reference list. Here's something else to try:

1. Remove the Excel, Microsoft.Office.Core, VBIDE reference from your list.
2. Close down Visual Studio to make sure it isn't holding any file locks.
Are you using Visual Studio 2003? There was a problem with this on some
machines that was similar to this, which was incredibly difficult to fix.
3. Look in the directories of your project, looking for interop assemblies.
They are named Interop.*.dll. Delete the Interop.Excel.dll,
Microsoft.Office.Core.dll, and Interop.VBIDE.dll wherever you find them.
4. Maybe reboot after that, but I'm not sure that's necessary. Perhaps
just an old habit that sometimes worked. <grin>
5. Restart Visual Studio and re-add the Microsoft Office Excel 11.0 Object
Library reference.
6. Keep your fingers crossed if it properly added a reference to
Microsoft.Office.Core.dll.

The previous steps were the ideal situation. If they don't work, try to add
the reference back from the GAC, like you did before.

Then run and see if it works.

Joe
--
http://www.csharp-station.com
May 28 '06 #5
Joe Mayo [C# MVP] wrote:
"Michael Russell" <mr*******@hotmail.com> wrote in message
news:uO****************@TK2MSFTNGP04.phx.gbl...
Joe Mayo [C# MVP] wrote:

<snip>
I was able to get it to work like this:

Excel.Shapes shapes = xlWks.Shapes;
xlShape = shapes.AddTextbox(
Microsoft.Office.Core.MsoTextOrientation.msoTextOr ientationHorizontal,
(float)left, (float)top, (float)width, (float)height );

The only thing now is to get the reference to the Microsoft.Office.Core dll.
Something is keeping it from properly adding the right proxies to your
reference list. Here's something else to try:

1. Remove the Excel, Microsoft.Office.Core, VBIDE reference from your list.
2. Close down Visual Studio to make sure it isn't holding any file locks.
Are you using Visual Studio 2003? There was a problem with this on some
machines that was similar to this, which was incredibly difficult to fix.
3. Look in the directories of your project, looking for interop assemblies.
They are named Interop.*.dll. Delete the Interop.Excel.dll,
Microsoft.Office.Core.dll, and Interop.VBIDE.dll wherever you find them.
4. Maybe reboot after that, but I'm not sure that's necessary. Perhaps
just an old habit that sometimes worked. <grin>
5. Restart Visual Studio and re-add the Microsoft Office Excel 11.0 Object
Library reference.
6. Keep your fingers crossed if it properly added a reference to
Microsoft.Office.Core.dll.

The previous steps were the ideal situation. If they don't work, try to add
the reference back from the GAC, like you did before.

Then run and see if it works.

Joe


Joe,
Thanks for following up on this. I'm not running VS, but SharpDevelop
2.0. To verify the problem, though, I downloaded Visual C# Express and
loaded my code into it to see what would happen. Sure enough, when I
added the reference to Excel in COM, the references to
Microsoft.Office.Core and VBIDE appeared just as they should.

So, the problem appears to be limited to SharpDevelop, and I've
submitted this to them to find out what's going on. Again, thanks for
the follow-up, it helped to have someone verify that I wasn't doing
something wrong in my part.

Michael
May 28 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Helene Day | last post by:
I am trying to access the Word Objects from a .NET project. I have some sample from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_vsto2003_ta/html/WordObject.asp and I...
0
by: Tomas Vera | last post by:
Hello All I have a project that references Interop.Microsoft.Office.Core But when I try to build, I get this error Exception from HRESULT: 0x80131019. (3 times) followed by The dependency...
0
by: AllenF | last post by:
I have a library (named DSG) created in C# which other programs use to build Excel spreadsheeets. This library uses the office PIAs "Microsoft.Office.Interop.Excel.dll" and also references the...
2
by: Simon | last post by:
Overnight, I've developed this error somehow, when I try to build/run my application: "Parser Error Message: Unable to load file 'Interop.Microsoft.Office.Core'." I'm pretty sure I haven't...
0
by: ns2k | last post by:
I tried to implements Microsoft.Office.Core.Range Interface, but the dot net raise errors : + ' '_Default' cannot implement '_Default' because there is no matching property on interface 'Range'.'...
2
by: William LaMartin | last post by:
I have created a program that allows for the automation of things in Word documents, like changing the values of DocVariables and the links to Excel Sheets. I did it using interoperoperatability,...
1
by: Alan T | last post by:
VS 2005 and MS Office 2003 installed. I can include Microsoft.Office.Core and Word in the references so I can add the using Microsoft.Office.Interop.Word. However, my workmate cannot do the...
0
by: spinz2112 | last post by:
Im trying to create a windows utility that opens an excel file in VS2005 using C#. Everything that I have found on the web says the first thing to do is to add a reference to the MS Excel 10 Object...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.