PC Review


Reply
Thread Tools Rate Thread

dll for use by Excel

 
 
ewm
Guest
Posts: n/a
 
      23rd Apr 2009
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?
 
Reply With Quote
 
 
 
 
ewm
Guest
Posts: n/a
 
      23rd Apr 2009
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" wrote:

> On Thu, 23 Apr 2009 10:12:02 -0700, ewm <(E-Mail Removed)>
> wrote:
>
> > 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
>

 
Reply With Quote
 
AA2e72E
Guest
Posts: n/a
 
      24th Apr 2009
Try registering the dll with the /codebase switch.

ALso, Google for COMRegisterFunction and COMUnregisterFunction.

"ewm" wrote:

> 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?

 
Reply With Quote
 
ewm
Guest
Posts: n/a
 
      24th Apr 2009
/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" wrote:

> Try registering the dll with the /codebase switch.
>
> ALso, Google for COMRegisterFunction and COMUnregisterFunction.
>
> "ewm" wrote:
>
> > 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?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Paste failed in excel file migrated from Excel 2003 to Excel Handong Chen Microsoft Excel Crashes 1 4th Mar 2010 06:05 PM
Application coded in excel 2000 when used in excel 2003 excel doesnot perform well and takes double the time to give the output Prince Microsoft Excel Programming 4 17th Feb 2009 03:05 PM
Problem with Excel reports ::::Excel 2003 Migration To Excel 2007 =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?= Microsoft Excel Programming 0 5th Oct 2007 10:26 AM
Excel 2003 crashes loading excel files created Excel 2000 =?Utf-8?B?SmVmZiBMZXdpbiAgQXVzdHJhbGlh?= Microsoft Excel Misc 0 27th Jun 2005 04:20 AM
Why my Excel 2003 don't open excel files by duble click on excel . =?Utf-8?B?VmFseQ==?= Microsoft Excel Crashes 1 20th Jan 2005 03:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:38 PM.