Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / May 2006

Tip: Looking for answers? Try searching our database.

Excel selects wrong .NET runtime

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kh - 22 May 2006 01:08 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
"Peter Huang" [MSFT] - 22 May 2006 07:49 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.
kh - 22 May 2006 08:59 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

> Hi KH,
>
[quoted text clipped - 18 lines]
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Peter Huang" [MSFT] - 23 May 2006 04:54 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.
kh - 23 May 2006 09:36 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
kh - 23 May 2006 17:24 GMT
i should add that i am using excel 2002 (10.6789.6714) SP3

thanks
"Peter Huang" [MSFT] - 24 May 2006 09:28 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.
"Peter Huang" [MSFT] - 24 May 2006 11:08 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.
kh - 24 May 2006 15:51 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
kh - 24 May 2006 17:13 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
"Peter Huang" [MSFT] - 25 May 2006 02:43 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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.