interop >> Excel selects wrong .NET runtime

by a2g » Mon, 22 May 2006 08:08:41 GMT

Hi. I have developed a very basic .NET 2.0 CCW for use from Excel. My dev box
has both 2.0 and 1.1 installed. MSDN docs tell me Excel will use the latest
.NET version by default, but using fuslogvw.exe I can confirm that Excel is
in fact attempting to run my component using .NET 1.1.

How does Excel decide which .NET version to use, and how can I ensure this
does not happen when I deploy my component to user machines with 1.1 and 2.0
installed?

Thanks

kh


interop >> RE: Excel selects wrong .NET runtime

by v-phuang » Mon, 22 May 2006 14:49:45 GMT


Hi KH,

You can use the code below to check the current runtime.
MessageBox.Show(System.Environment.Version.ToString());

Also we can use an app.config to force Excel to load certian version .NET.
<supportedRuntime> Element
http://msdn2.microsoft.com/en-us/library/w4atty68.aspx

You can make an app.config file as the link above and save it as
excel.exe.config and put it into the same directory of the Excel.exe.

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

interop >> RE: Excel selects wrong .NET runtime

by a2g » Mon, 22 May 2006 15:59:02 GMT

Thanks Peter

I already know Excel is using version 1.1, and I know I can force Excel to
use version 2.0 using a config file as you suggest, but my point is that I
should not need to do this - Excel should default to using 2.0, not 1.1. Or
am I mistaken?

If I cannot reliably predict the runtime used by Excel, I cannot reliably
deploy my app. Hence my original question: how does Excel decide which
version to use?

Many thanks

kh

interop >> RE: Excel selects wrong .NET runtime

by v-phuang » Tue, 23 May 2006 11:54:32 GMT

Hi KH,

Thanks for your posting!
Based on my test, the Excel will keep loading .NET 2.0 as the default
runtime, no wonder I build the Addin at IDE 2003 or IDE 2005.

So I just wonder did the problem occur on all the machine or just certain
machine?
Did the Excel load any other Managed Addin? Please try to remove them
temporarily for testing.
This will help us isolate the problem, please collect the information above
and let me know the result.

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

interop >> RE: Excel selects wrong .NET runtime

by a2g » Tue, 23 May 2006 16:36:01 GMT

Peter

Thanks for getting back to me. I have not tested this on any other machine
yet. This is all on my developer box with VS03/.NET 1.1 and VS05/.NET 2.0
installed. From what I can tell there are no .NET addins being explicitly
loaded, although after starting Excel I can see the following two dlls have
been loaded into the process by default:

C:\Program Files\Microsoft Visual Studio 8\Visual Studio Tools for
Office\VSTOExcelAdaptor.dll [Version: 8.0.50727.42]
C:\WINNT\system32\mscoree.dll [Version: 2.0.50727.42]

If I run VBA code from Excel which uses my COM component (installed in the
GAC) I see the following file system activity using Sysinternals' FileMonitor
(column headings are Time, Process, Request, Path, Result, Other):

<snip
08:52:50 EXCEL.EXE:2376 OPEN C:\WINNT\Microsoft.NET\Framework\v2.0.50727 SUCCESS Options: Open Access: All
08:52:50 EXCEL.EXE:2376 QUERY
INFORMATION C:\WINNT\Microsoft.NET\Framework\v2.0.50727 SUCCESS Attributes:
Any
08:52:50 EXCEL.EXE:2376 CLOSE C:\WINNT\Microsoft.NET\Framework\v2.0.50727 SUCCESS
08:52:50 EXCEL.EXE:2376 OPEN C:\WINNT\Microsoft.NET\Framework\v1.1.4322\ SUCCESS Options: Open Directory Access: All
08:52:50 EXCEL.EXE:2376 DIRECTORY C:\WINNT\Microsoft.NET\Framework\v1.1.4322\ SUCCESS FileBothDirectoryInformation: mscorwks.dll
08:52:50 EXCEL.EXE:2376 CLOSE C:\WINNT\Microsoft.NET\Framework\v1.1.4322\ SUCCESS
08:52:50 EXCEL.EXE:2376 OPEN C:\WINNT\Microsoft.NET\Framework\v1.1.4322\mscorwks.dll SUCCESS Options: Open Access: All
08:52:50 EXCEL.EXE:2376 QUERY
INFORMATION C:\WINNT\Microsoft.NET\Framework\v1.1.4322\mscorwks.dll SUCCESS Attributes: A
08:52:50 EXCEL.EXE:2376 CLOSE C:\WINNT\Microsoft.NET\Framework\v1.1.4322\mscorwks.dll SUCCESS
<snip>

So looks like Excel first tries to look in the 2.0 directory, can't find
what it is looking for and resorts to the 1.1 directory instead. (Note that
the .NET 2.0 path is accessed without a trailing path separator).

Let me know if there is any more information I can supply that would help

kh

interop >> RE: Excel selects wrong .NET runtime

by a2g » Wed, 24 May 2006 00:24:01 GMT

i should add that i am using excel 2002 (10.6789.6714) SP3

thanks

interop >> RE: Excel selects wrong .NET runtime

by v-phuang » Wed, 24 May 2006 16:28:13 GMT

Hi

Commonly this is the same as scenario that the unmanaged App to load the
managed dll scenario.
The rule is that it will try to load the High version .NET CLR, based on my
test at my side and the Filemon log, that does prove that.

But in your machine, both .NET 1.1. and .NET 2.0 are installed, but your
Excel Application will load .NET 1.1. by default.
If I am wrong please correct me.

Also what is the order you install .NET framework? 1.1 and then 2.0 or in
the reverse order?

Also here is KB you may have a try.
Add-ins, smart documents, or smart tags that you create by using Microsoft
Visual Studio 2005 do not run in Office
http://support.microsoft.com/kb/908002

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

interop >> RE: Excel selects wrong .NET runtime

by v-phuang » Wed, 24 May 2006 18:08:25 GMT

Hi KH,

Also here is a link for your reference.
http://blogs.msdn.com/seshadripv/archive/2006/02/24/538610.aspx

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

interop >> RE: Excel selects wrong .NET runtime

by a2g » Wed, 24 May 2006 22:51:01 GMT

Thanks Peter

Yes, I have both 1.1 and 2.0 installed on my machine but Excel is loading
1.1 by default. I can confirm that applying the Excel.exe.config fix works,
but this is not a realistic solution for deployment to client machines.

The installation order was 1.1 (VS03) followed by 2.0 (VS05).

The Microsoft Support article you refer to relates to the creation of
Add-ins, Smart Documents or Smart Tags only. In my scenario this is just a
very simply COM component so the update should not apply, and in any case I
cannot distribute an Office update to my clients.

So at the moment I can only describe this as a 'bug', although it is quite
reasonable to suspect an unusual or non-standard configuration of my
developer box (which is derived from a standard build within this
organisation). Please let me know if there is any further evidence I can
supply to assist you in the resolution of this issue.

Many thanks

kh

interop >> RE: Excel selects wrong .NET runtime

by a2g » Thu, 25 May 2006 00:13:02 GMT

solved. i used regmon from sysinternals to trace registry reads from excel.
there is an interesting entry in the registry which is forcing excel to use
v1.1. the key is:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v2.0.50727.00000\excel.exe\{2CCAA9FE-6884-4AF2-99DD-5217B94115DF}\Target Version

this was set to v1.1.4322 on my machine. i set this to v2.0.50727 and the
COM component works as expected. i googled the guid in the registry key and
found a blog entry from another developer facing this issue:

http://mcfunley.com/cs/blogs/dan/archive/2006/02/07/947.aspx

he links to a microsoft support article and it appears that the original
microsoft support article you linked to is indeed related to my problem,
although the description of the knowledge base article should be changed to
include COM components developed using VS05 IMO.

i will now try to establish if this also affects client machines. many
thanks for your help

kh

interop >> RE: Excel selects wrong .NET runtime

by v-phuang » Thu, 25 May 2006 09:43:25 GMT

Hi KH,

Thanks for your quickly reply and knowledge sharing!
Cheers!

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Similar Threads

1. .Net Runtime Optimization Service Amok from Outlook 2007 w BCM .Net Frmwk 2.0 Hotfixes - MS Office Setup

2. Excel asp.net error : System.Runtime.InteropServices.COMException (0x80080005):

Hi All!!

I have an application, which was up and running, suddenly it has
started giving an error msg:

System.Runtime.InteropServices.COMException (0x80080005): Server
execution failed

and sometimes

System.Runtime.InteropServices.COMException (0x80080005): HSRESULT
(something..)
Tried to debug and the problem looks like its in the below line:
Dim excApp As New Excel.Application

Please help !!

TIA..

3. Urgent: Excel 2003 and ASP.NET 2.0 interop fails at runtime

4. Excel dependent on .Net Framework Runtime?

Hello everyone,


I am wondering whether Microsoft Excel 2003 is a native application or 
dependent on any .Net Framework Runtime, like 1.1, 2.0 or 3.0?

How about Microsoft Excel 2007?


thanks in advance,
George

5. Excel libs/Runtime for .NET - Excel

6. Runtime-error 1004 (excel 2007) when selecting validation list option triggering worksheet_change property

Hi

I experience a problem with a worksheet that worked fine in 2000, yet
in excel 2007 it generates a problem
I have localised the problem yet do not know the cause/solution

This is the problem:
when I select a cell containg a validation list ("drop down list") and
when I let some action follow through excel's worksheet_change
property (VBA) it generates a 1004 error the moment this same sub
starts writing to a cell (any cell)

The strange thing is: when I manually change the validation list to a
different value (that means: I enter and type in one of the  possible
values the validation list allows) everything works flawlessly

So in fact excel 2007 generates the problem only when I change the
value of a cell with validation list by picking from drop-down list
*and* let some write action follow in worksheet_change
When I manually enter the new value, it works as expected

please! Any any suggestions on how to solve this
It appears to me as an excel bug

kind regards
erik

7. Runtime-error 1004 (excel 2007) when selecting validation list opt - Excel

8. Excel VBA Runtime error 1004 "Select method of Range class failed"

I'm trying perform the following with a VBA script in Excel 2000:

1. Unhide a hidden worksheet.
2. Copy a range of cells from another worksheet
3. Paste the copied selection into the worksheet that was unhidden.
4. Some simple formatting steps in the unhidden worksheet

But the script is failing when I tried to Paste.

Here's the code:

Private Sub cmdZoomProgSumm_click()
    Sheets("Project Summary").Visible = True
    Sheets("6-Blocker").Select
    Range("B5:R33").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("B5:R36").Select
    Application.CutCopyMode = False
    Selection.Copy
    ActiveWorkbook.Sheets("Project Summary").Select
    Range("A1").Select
    Selection.Paste
    Columns("A:A").ColumnWidth = 5.29
    Columns("A:P").Select
    ActiveWindow.SmallScroll ToRight:=6
    Columns("A:Q").Select
    Selection.ColumnWidth = 4.71
    ActiveWindow.SmallScroll ToRight:=-6
End Sub

I'm getting the error 1004  "Select method of Range class failed"
where I specify Range("A1").Select

The odd thing is that when I ran the code as a recorded macro, it
worked fine. However when I copied the code to a VBA button control, I
got the 1004 error.

Can somebody explain why I'm getting this error on the button control
and what I can do to solve this problem?

Thank you in advance.