dll for use by Excel

E

ewm

I created a .dll with multiple functions for use from Excel. I am using
CreateObject in Excel to create the object. My problem is the CreateObject
call error with "Automation Error. The system cannot find the path
specified." This only occurs when I try to use the .dll on a machine
different from the one I created it on. I have registered the .dll using
regasm assemblyname /tlb and have registered the dll in the GAC. Any ideas
what is wrong?

Here's the code:

AssemblyInfo.cs

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OEExcel")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OEExcel")]
[assembly: AssemblyCopyright("Copyright © 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

//Strong Name
[assembly:AssemblyKeyFile("D:\\VSProjects\\OEExcel\\OEExcel\\bin\\Release\\OEExcel.snk")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(true)]

// The following GUID is for the ID of the typelib if this project is
exposed to COM
[assembly: Guid("231df3f2-2f71-494a-9776-01029e92dd1d")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision
Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]


Implementation Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;


namespace OEExcel
{
[Guid("16FBF6A5-B5E3-4332-8E4F-B0519BC5A59A")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface _CanopyInterface
{
[DispId(1)] int CreateOrder(string CustomerCode, int
WarehouseCode, string UserID_EnteredBy, string ScheduledShipDate,
string Customer_PO, int SalespersonCode);
[DispId(2)] int AddOrderLine(int OrderNumber, string ProductCode,
double OrderQuantity, double PriceOverride, string UM_SellBy, string UM_Prc);
[DispId(3)] void SetValues(int Warehouse, string UserID);

}

[Guid("5ACBCF1C-BDE7-40a2-B8DC-813B7B681235")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("CanopyInterface")]
public class CanopyInterface : _CanopyInterface
/*
* Name: CanopyInterface
* Author: ewm
* Date: 4/2009
* Copyright: Edward Miller, 2009
* Purpose: Creates and order in Aspen Systems, Inc. Canopy ERP
system from and Excel spreadsheet.
*
* Usage:
*
*
*/

Below here is just standard C# code to do the things I want.

One thing to note. If I add OEExcel as a reference to my Excel worksheet, it
shows in the object browser complete with all exposed functions; however, the
object still wont create using
Dim oInterface As myClassName
Set oInterface = New myClassName

Any ideas?
 
E

ewm

Thanks. I will try that. I posted here because I did a search of this
newsgroup on "com interop" and found much discussion on the topic many with
similar problems to mine most of which who had received answers. It worked
for them and hopefully will work for me.

Peter Duniho said:
I created a .dll with multiple functions for use from Excel. I am using
CreateObject in Excel to create the object. My problem is the
CreateObject
call error with "Automation Error. The system cannot find the path
specified." This only occurs when I try to use the .dll on a machine
different from the one I created it on. I have registered the .dll using
regasm assemblyname /tlb and have registered the dll in the GAC. Any
ideas
what is wrong? [...]

I don't see anything in your question that is actually pertinent to C#, or
even .NET.

You will probably get much better help posting your question to a more
appropriate newsgroup, such as one devoted to using Excel, especially one
where programming Excel is on-topic. There, they can tell you how to
ensure that Excel can find your DLL and load it.

Pete
 
A

AA2e72E

Try registering the dll with the /codebase switch.

ALso, Google for COMRegisterFunction and COMUnregisterFunction.

ewm said:
I created a .dll with multiple functions for use from Excel. I am using
CreateObject in Excel to create the object. My problem is the CreateObject
call error with "Automation Error. The system cannot find the path
specified." This only occurs when I try to use the .dll on a machine
different from the one I created it on. I have registered the .dll using
regasm assemblyname /tlb and have registered the dll in the GAC. Any ideas
what is wrong?

Here's the code:

AssemblyInfo.cs

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OEExcel")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OEExcel")]
[assembly: AssemblyCopyright("Copyright © 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

//Strong Name
[assembly:AssemblyKeyFile("D:\\VSProjects\\OEExcel\\OEExcel\\bin\\Release\\OEExcel.snk")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(true)]

// The following GUID is for the ID of the typelib if this project is
exposed to COM
[assembly: Guid("231df3f2-2f71-494a-9776-01029e92dd1d")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision
Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]


Implementation Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;


namespace OEExcel
{
[Guid("16FBF6A5-B5E3-4332-8E4F-B0519BC5A59A")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface _CanopyInterface
{
[DispId(1)] int CreateOrder(string CustomerCode, int
WarehouseCode, string UserID_EnteredBy, string ScheduledShipDate,
string Customer_PO, int SalespersonCode);
[DispId(2)] int AddOrderLine(int OrderNumber, string ProductCode,
double OrderQuantity, double PriceOverride, string UM_SellBy, string UM_Prc);
[DispId(3)] void SetValues(int Warehouse, string UserID);

}

[Guid("5ACBCF1C-BDE7-40a2-B8DC-813B7B681235")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("CanopyInterface")]
public class CanopyInterface : _CanopyInterface
/*
* Name: CanopyInterface
* Author: ewm
* Date: 4/2009
* Copyright: Edward Miller, 2009
* Purpose: Creates and order in Aspen Systems, Inc. Canopy ERP
system from and Excel spreadsheet.
*
* Usage:
*
*
*/

Below here is just standard C# code to do the things I want.

One thing to note. If I add OEExcel as a reference to my Excel worksheet, it
shows in the object browser complete with all exposed functions; however, the
object still wont create using
Dim oInterface As myClassName
Set oInterface = New myClassName

Any ideas?
 
E

ewm

/codebase switch is for private assemblies - assemblies that are tied to a
particular exe. This requires the dll to reside in the same path. That's not
the case here. As an experiment I did try it though. It did not solve the
problem. Thanks for the reply though. One thing I have learned using these
forums is that a reply may not solve the original poster's problem but other
people find the answer to their question. I am sure you made somebody happy
with your answer and I appreciate the effort.

AA2e72E said:
Try registering the dll with the /codebase switch.

ALso, Google for COMRegisterFunction and COMUnregisterFunction.

ewm said:
I created a .dll with multiple functions for use from Excel. I am using
CreateObject in Excel to create the object. My problem is the CreateObject
call error with "Automation Error. The system cannot find the path
specified." This only occurs when I try to use the .dll on a machine
different from the one I created it on. I have registered the .dll using
regasm assemblyname /tlb and have registered the dll in the GAC. Any ideas
what is wrong?

Here's the code:

AssemblyInfo.cs

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OEExcel")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OEExcel")]
[assembly: AssemblyCopyright("Copyright © 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

//Strong Name
[assembly:AssemblyKeyFile("D:\\VSProjects\\OEExcel\\OEExcel\\bin\\Release\\OEExcel.snk")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(true)]

// The following GUID is for the ID of the typelib if this project is
exposed to COM
[assembly: Guid("231df3f2-2f71-494a-9776-01029e92dd1d")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision
Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]


Implementation Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;


namespace OEExcel
{
[Guid("16FBF6A5-B5E3-4332-8E4F-B0519BC5A59A")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface _CanopyInterface
{
[DispId(1)] int CreateOrder(string CustomerCode, int
WarehouseCode, string UserID_EnteredBy, string ScheduledShipDate,
string Customer_PO, int SalespersonCode);
[DispId(2)] int AddOrderLine(int OrderNumber, string ProductCode,
double OrderQuantity, double PriceOverride, string UM_SellBy, string UM_Prc);
[DispId(3)] void SetValues(int Warehouse, string UserID);

}

[Guid("5ACBCF1C-BDE7-40a2-B8DC-813B7B681235")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("CanopyInterface")]
public class CanopyInterface : _CanopyInterface
/*
* Name: CanopyInterface
* Author: ewm
* Date: 4/2009
* Copyright: Edward Miller, 2009
* Purpose: Creates and order in Aspen Systems, Inc. Canopy ERP
system from and Excel spreadsheet.
*
* Usage:
*
*
*/

Below here is just standard C# code to do the things I want.

One thing to note. If I add OEExcel as a reference to my Excel worksheet, it
shows in the object browser complete with all exposed functions; however, the
object still wont create using
Dim oInterface As myClassName
Set oInterface = New myClassName

Any ideas?
 

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