Compatibilty between .NET framework and EXCEL

D

dabramov

So I am running into an interesting problem trying to access a sample
COM object I wrote in C# (see code below) from EXCEL (see VB code
below). I created 2 projects: One called COMTEST2003 which I compiled
and registered using Visual Studio 2003 and another called COMTEST2005
which I compiled and registered using Visual Studio 2005. So now I have
2 references in Excel's VB References called COMTEST2003 and
COMTEST2005. I created 2 different spreadsheets: one using a reference
to COMTEST2003 and the other using a reference to COMTEST2005 and ran
on different versions of Microsoft Office. I found the following:

(A) COMTEST2003 works on Office 2002 & Office 2003's Excel.
(B) COMTEST2005 doesn't work on Office 2002 (it says "File or assembly
name "COMTEST2005", or one of it dependencies, was not found) but works
fine on 2003.

What is going on here? Does anyone have any ideas why COMTEST2005
doesn't work on Office 2002? What version of the .NET framework does
Excel use?

########################################################################
########################################################################
For reference here is the code I am trying to run in VB in a
spreadsheet with 1 button:


' VB Code ********************************************************
' Build and register C# class library first
' Add a reference to the class library CSCL in the VB project.
' Paste this code into a simple form with 1 button (Name = Command1)
Option Explicit
Private WithEvents moComObj As COMTEST<2003 or 2005>.ComClassCS

Private Sub Command1_Click()
moComObj.Method
End Sub

Private Sub moComObj_MyEvent(ByVal StringParam As String)
MsgBox "Event caught : " & StringParam
End Sub

Private Sub Form_Load()
Set moComObj = New COMTEST<2003 or 2005>.ComClassCS
End Sub

Private Sub CommandButton1_Click()
Form_Load
Command1_Click
End Sub

#######################################################
#######################################################
For reference here is the code for the COM object I am trying to
compile in C#:

// C# Code ********************************************************
// Project type = Class Library
// Project name = CSCL
// Post build step = regasm cscl.dll /tlb:cscl.tlb /codebase

using System;
using System.Runtime.InteropServices;

namespace CSCL
{
[Guid("42E6DFAC-E988-4883-AC63-8D61A479D86B")]
public interface IComClassCS
{
string Method();
}

public delegate void MyEventHandler(string StringParam);

// Events interface
[Guid("49F6403F-B05D-4f97-AD1E-D62EC8C28DEC"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IComClassCSEvents
{
void MyEvent(string StringParam);
}

// Class ComClassCS
[Guid("F610875B-40D3-4666-B367-60CDF30F5647"),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(IComClassCSEvents))]
public class ComClassCS : IComClassCS
{
public event MyEventHandler MyEvent;

public ComClassCS()
{
}
public string Method()
{
if (MyEvent != null)
{
MyEvent("C# Event string...New");
}
return "C# COM Object return string";
}
}
}
 
J

Jim Cone

Re: "What is going on here? Does anyone have any ideas why COMTEST2005
doesn't work on Office 2002? What version of the .NET framework does Excel use?"

------------------------------------
From ... http://msdn.microsoft.com/vstudio/default.aspx

To run Visual Studio 2005 Tools for Office solutions,
you must install the following software on the each user's computer:

* The Microsoft .NET Framework version 2.0.
* A version of Word 2003, Excel 2003, or Outlook 2003 that supports Visual Studio 2005 Tools for Office.
* Microsoft Office 2003 primary interop assemblies.
* Visual Studio 2005 Tools for Office Runtime
* Microsoft Visual Studio 2005 Tools for the Microsoft Office System (VSTO2005) Language Package (optional)
 
N

NickHK

Jim,
I must say that it seems to me that using the latest VB.Net with Office is
just asking for trouble on anything other than a dev machine.
Despite MS pushing the .Net way, it looks virtually impossible to do things
that VB5/6 does in a few lines (without an 100MB+ installation of all those
dependencies you listed).
Or am I missing something ??

NickHK

Jim Cone said:
Re: "What is going on here? Does anyone have any ideas why COMTEST2005
doesn't work on Office 2002? What version of the .NET framework does Excel use?"

------------------------------------
From ... http://msdn.microsoft.com/vstudio/default.aspx

To run Visual Studio 2005 Tools for Office solutions,
you must install the following software on the each user's computer:

* The Microsoft .NET Framework version 2.0.
* A version of Word 2003, Excel 2003, or Outlook 2003 that supports
Visual Studio 2005 Tools for Office.
* Microsoft Office 2003 primary interop assemblies.
* Visual Studio 2005 Tools for Office Runtime
* Microsoft Visual Studio 2005 Tools for the Microsoft Office System
(VSTO2005) Language Package (optional)
 
J

Jim Cone

Re: "Or am I missing something ??"

I doubt it.

Jim Cone
San Francisco, USA
http://www.officeletter.com/blink/specialsort.html


"NickHK"
<[email protected]>
wrote in message
Jim,
I must say that it seems to me that using the latest VB.Net with Office is
just asking for trouble on anything other than a dev machine.
Despite MS pushing the .Net way, it looks virtually impossible to do things
that VB5/6 does in a few lines (without an 100MB+ installation of all those
dependencies you listed).
Or am I missing something ??
NickHK


"Jim Cone"
wrote in message
Re: "What is going on here? Does anyone have any ideas why COMTEST2005
doesn't work on Office 2002? What version of the .NET framework does Excel use?"
* The Microsoft .NET Framework version 2.0.
* A version of Word 2003, Excel 2003, or Outlook 2003 that supports
Visual Studio 2005 Tools for Office.
* Microsoft Office 2003 primary interop assemblies.
* Visual Studio 2005 Tools for Office Runtime
* Microsoft Visual Studio 2005 Tools for the Microsoft Office System
(VSTO2005) Language Package (optional)
 
D

dabramov

Don't forget the additional licenses required for MSOffice 2003.

Jim said:
Re: "Or am I missing something ??"

I doubt it.

Jim Cone
San Francisco, USA
http://www.officeletter.com/blink/specialsort.html


"NickHK"
<[email protected]>
wrote in message
Jim,
I must say that it seems to me that using the latest VB.Net with Office is
just asking for trouble on anything other than a dev machine.
Despite MS pushing the .Net way, it looks virtually impossible to do things
that VB5/6 does in a few lines (without an 100MB+ installation of all those
dependencies you listed).
Or am I missing something ??
NickHK


"Jim Cone"
wrote in message
Re: "What is going on here? Does anyone have any ideas why COMTEST2005
doesn't work on Office 2002? What version of the .NET framework does Excel use?"
* The Microsoft .NET Framework version 2.0.
* A version of Word 2003, Excel 2003, or Outlook 2003 that supports
Visual Studio 2005 Tools for Office.
* Microsoft Office 2003 primary interop assemblies.
* Visual Studio 2005 Tools for Office Runtime
* Microsoft Visual Studio 2005 Tools for the Microsoft Office System
(VSTO2005) Language Package (optional)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top