Hi all,
Using VS 2022 (17.12.3) and X# 2.21
I'm getting a strage error when trying to add a reference to Microsoft Excel and Word to my project.
Following the example 4 to add an Ole Automation object I get: "Operation is not valid due to current state of the object"
there is any way to solve this?
thanks
Stefano
VS error when adding reference
-
- Posts: 90
- Joined: Mon Sep 26, 2016 12:59 pm
- Location: Italy
Re: VS error when adding reference
Hi Stefano,
Thanks for the report I also see the problem, seems it happens with any COM reference. I'm sure Robert can fix this too for the upcoming build.
Thanks for the report I also see the problem, seems it happens with any COM reference. I'm sure Robert can fix this too for the upcoming build.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
-
- Posts: 90
- Joined: Mon Sep 26, 2016 12:59 pm
- Location: Italy
Re: VS error when adding reference
Hi Chris,
thanks.
I tried in Xide to add COM reference but I don't see Microsoft.Office.Interop.Excel in the list of COM interop Assemblies
Stefano
thanks.
I tried in Xide to add COM reference but I don't see Microsoft.Office.Interop.Excel in the list of COM interop Assemblies
Stefano
Re: VS error when adding reference
Hi Stefano,
In XIDE, you need to create the assemblies first, by pressing the "Create COMM Assemblies" button (it's also available as a menu command under Tools) first, then they will be available for all apps in the COM references page.
In case you get an error doing that, plese check that XIDE has found correctly the location of the .Net SDK in Preferences/Folders, it should point to something like
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools
In XIDE, you need to create the assemblies first, by pressing the "Create COMM Assemblies" button (it's also available as a menu command under Tools) first, then they will be available for all apps in the COM references page.
In case you get an error doing that, plese check that XIDE has found correctly the location of the .Net SDK in Preferences/Folders, it should point to something like
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
-
- Posts: 90
- Joined: Mon Sep 26, 2016 12:59 pm
- Location: Italy
Re: VS error when adding reference
Hi Chris,
it is in the 'Create COM interop Assemblies' that I do not see Excel or Word in the list.
this is what I see:
in the Preferences/Folders I have:
thanks
Stefano
it is in the 'Create COM interop Assemblies' that I do not see Excel or Word in the list.
this is what I see:
in the Preferences/Folders I have:
thanks
Stefano
Re: VS error when adding reference
Stefano,
If you install the "Visual Studio Tools for Office" from the VS Setup / Components page, then all the assemblies that you need are installed on your machine.
On my machine these are in:
"c:\Program Files (x86)\Microsoft Visual Studio\Shared\Visual Studio Tools for Office\PIA\Office14"
and
"c:\Program Files (x86)\Microsoft Visual Studio\Shared\Visual Studio Tools for Office\PIA\Office15"
Inside VS you can find these DLLs on the "Extensions" page.
Using these DLLs you do not need a COM reference.
Robert
If you install the "Visual Studio Tools for Office" from the VS Setup / Components page, then all the assemblies that you need are installed on your machine.
On my machine these are in:
"c:\Program Files (x86)\Microsoft Visual Studio\Shared\Visual Studio Tools for Office\PIA\Office14"
and
"c:\Program Files (x86)\Microsoft Visual Studio\Shared\Visual Studio Tools for Office\PIA\Office15"
Inside VS you can find these DLLs on the "Extensions" page.
Using these DLLs you do not need a COM reference.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Re: VS error when adding reference
Hi Stefano,
I think it's the Office one, this should include all (Excel, Word etc). But I see your SDK folder option is empty, please put there the folder I mentioned earlier (might be slightly different in your machine).
But as Robert said, you can also directly reference the dlls if they already exist in your disk.
I think it's the Office one, this should include all (Excel, Word etc). But I see your SDK folder option is empty, please put there the folder I mentioned earlier (might be slightly different in your machine).
But as Robert said, you can also directly reference the dlls if they already exist in your disk.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
-
- Posts: 90
- Joined: Mon Sep 26, 2016 12:59 pm
- Location: Italy
Re: VS error when adding reference
Hi Robert and Chris,
thanks for all the input. I've installed the 'Visual Studio Tools for Office' and now I've all the assemblies installed exactly in the same path as Robert said.
I've added the dll to reference in my project, are this right?
thanks
Stefano
thanks for all the input. I've installed the 'Visual Studio Tools for Office' and now I've all the assemblies installed exactly in the same path as Robert said.
I've added the dll to reference in my project, are this right?
thanks
Stefano
Re: VS error when adding reference
Hi Stefano,
I think both of these need one more base dll, which is referenced by both, but not totally sure. What is the full list of the files in that folder in your PC?
I think both of these need one more base dll, which is referenced by both, but not totally sure. What is the full list of the files in that folder in your PC?
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Re: VS error when adding reference
The Excel dll has a reference to the dll "office.dll" and "Microsoft.Vbe.Interop.dll"
The Word dll has the same references.
Btw: I have located the problem and will be fixed in the next version of the VS integration.
Robert
The Word dll has the same references.
Btw: I have located the problem and will be fixed in the next version of the VS integration.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu