473,387 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Using C# Class Library in VBScript

Help!

Hi, I'm having a bit (well a lot - it's getting annoying) of trouble using a
C# class library within a VBScript on a computer other than the development
machine. All the class is needed for at the moment is to create an
ADODB.Connection object based on a passed in parameter. The passed in
parameter is looked up in an XML document which then creates a connection
string. It would then return the ADODB.Connection object. So for example,
it would be used from VBScript like this:

Dim adoConn, conn

Set adoConn = CreateObject("MyLib.MyClass")
Set conn = adoConn.Conn("databaseName")
conn.Open
etc...

I understand that I require an interface which contains all the methods and
properties that I wish to use from VBScript. Therefore I have the following:

<Note: A reference to ADODB is imported>
using System;
using System.Runtime.InteropServices;
using ADODB;

[Guid("F100B75D-8DF4-4672-867D-BECF2F844E3A")]
public interface IADOConnection
{
ADODB.ConnectionClass Conn(string alias);
ADODB.ConnectionClass ConnUser(string alias, string user, string pass);
}

Next I have the class which uses the interface - ADOConnection (extract):

using System.Runtime.InteropServices;
using ADODB;

[ComVisible(true), ClassInterface(ClassInterfaceType.None)]
[Guid("9E74AA5C-282E-42d5-A0E8-FB5C3AE48045")]
public class ADOConnection : IADOConnection
{
public ADODB.ConnectionClass Conn(string alias)
{
AuthMode = 0;
Alias = alias;
lookupXML();

return m_conn;
}
public ADODB.ConnectionClass ConnUser(string alias, string user, string pass)
{
Alias = alias;
Username = user;
Password = pass;
AuthMode = 1;
lookupXML();

return m_conn;
}
}

I have generated a KeyFile using sn.exe and placed the path of the file in
the AssemblyInfo.cs file as follows:

[assembly: AssemblyKeyFile("..\\..\\KeyFile.snk")]

I build the project and it goes fine.
I have a test VBscript file on the development machine to use the class. It
works fine. I copy the dll to another machine which has the .NET Framework
installed and also copy the VBscript file. I then run the command:
RegASM.exe /tlb:myAssembly.tlb myAssembly.dll

I get greeted with:

Types registered successfully
RegAsm error: Type library exporter encountered an error while processing
'ObjWa
re.Lib.IADOConnection.Conn(#0), MyAssembly'. Error: Type library exporter
can n
ot load type ADODB.ConnectionClass (error: System.IO.FileNotFoundException:
File
or assembly name ADODB, or one of its dependencies, was not found.
File name: "ADODB"

=== Pre-bind state information ===
LOG: DisplayName = ADODB, Version=7.0.3300.0, Culture=neutral,
PublicKeyToken=b0
3f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = C:\WINNT\Microsoft.NET\Frame

What am I doing wrong? Any questions or more info I can give if needed.

Thanks always,
Jesse

Jul 21 '05 #1
2 7873
If I understood, your app uses a wrapper to use the ADODB COM compoant from
..NET. IMO this is this wrapper that misses (likely interop.adox.dll).

Patrice

--

"Jessard" <Je*****@discussions.microsoft.com> a écrit dans le message de
news:5F**********************************@microsof t.com...
Help!

Hi, I'm having a bit (well a lot - it's getting annoying) of trouble using a C# class library within a VBScript on a computer other than the development machine. All the class is needed for at the moment is to create an
ADODB.Connection object based on a passed in parameter. The passed in
parameter is looked up in an XML document which then creates a connection
string. It would then return the ADODB.Connection object. So for example, it would be used from VBScript like this:

Dim adoConn, conn

Set adoConn = CreateObject("MyLib.MyClass")
Set conn = adoConn.Conn("databaseName")
conn.Open
etc...

I understand that I require an interface which contains all the methods and properties that I wish to use from VBScript. Therefore I have the following:
<Note: A reference to ADODB is imported>
using System;
using System.Runtime.InteropServices;
using ADODB;

[Guid("F100B75D-8DF4-4672-867D-BECF2F844E3A")]
public interface IADOConnection
{
ADODB.ConnectionClass Conn(string alias);
ADODB.ConnectionClass ConnUser(string alias, string user, string pass);
}

Next I have the class which uses the interface - ADOConnection (extract):

using System.Runtime.InteropServices;
using ADODB;

[ComVisible(true), ClassInterface(ClassInterfaceType.None)]
[Guid("9E74AA5C-282E-42d5-A0E8-FB5C3AE48045")]
public class ADOConnection : IADOConnection
{
public ADODB.ConnectionClass Conn(string alias)
{
AuthMode = 0;
Alias = alias;
lookupXML();

return m_conn;
}
public ADODB.ConnectionClass ConnUser(string alias, string user, string pass) {
Alias = alias;
Username = user;
Password = pass;
AuthMode = 1;
lookupXML();

return m_conn;
}
}

I have generated a KeyFile using sn.exe and placed the path of the file in
the AssemblyInfo.cs file as follows:

[assembly: AssemblyKeyFile("..\\..\\KeyFile.snk")]

I build the project and it goes fine.
I have a test VBscript file on the development machine to use the class. It works fine. I copy the dll to another machine which has the .NET Framework installed and also copy the VBscript file. I then run the command:
RegASM.exe /tlb:myAssembly.tlb myAssembly.dll

I get greeted with:

Types registered successfully
RegAsm error: Type library exporter encountered an error while processing
'ObjWa
re.Lib.IADOConnection.Conn(#0), MyAssembly'. Error: Type library exporter
can n
ot load type ADODB.ConnectionClass (error: System.IO.FileNotFoundException: File
or assembly name ADODB, or one of its dependencies, was not found.
File name: "ADODB"

=== Pre-bind state information ===
LOG: DisplayName = ADODB, Version=7.0.3300.0, Culture=neutral,
PublicKeyToken=b0
3f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = C:\WINNT\Microsoft.NET\Frame

What am I doing wrong? Any questions or more info I can give if needed.

Thanks always,
Jesse

Jul 21 '05 #2
Hi Patrice,

Where do I find that file? I've searched for it on my system and it doesn't
exist. Do I have to add a reference to it? The class is meant to return an
ADODB.Connection object so if that means its a wrapper then yes that is what
I have.

Jesse

"Patrice" wrote:
If I understood, your app uses a wrapper to use the ADODB COM compoant from
..NET. IMO this is this wrapper that misses (likely interop.adox.dll).

Patrice

--

"Jessard" <Je*****@discussions.microsoft.com> a écrit dans le message de
news:5F**********************************@microsof t.com...
Help!

Hi, I'm having a bit (well a lot - it's getting annoying) of trouble using

a
C# class library within a VBScript on a computer other than the

development
machine. All the class is needed for at the moment is to create an
ADODB.Connection object based on a passed in parameter. The passed in
parameter is looked up in an XML document which then creates a connection
string. It would then return the ADODB.Connection object. So for

example,
it would be used from VBScript like this:

Dim adoConn, conn

Set adoConn = CreateObject("MyLib.MyClass")
Set conn = adoConn.Conn("databaseName")
conn.Open
etc...

I understand that I require an interface which contains all the methods

and
properties that I wish to use from VBScript. Therefore I have the

following:

<Note: A reference to ADODB is imported>
using System;
using System.Runtime.InteropServices;
using ADODB;

[Guid("F100B75D-8DF4-4672-867D-BECF2F844E3A")]
public interface IADOConnection
{
ADODB.ConnectionClass Conn(string alias);
ADODB.ConnectionClass ConnUser(string alias, string user, string pass);
}

Next I have the class which uses the interface - ADOConnection (extract):

using System.Runtime.InteropServices;
using ADODB;

[ComVisible(true), ClassInterface(ClassInterfaceType.None)]
[Guid("9E74AA5C-282E-42d5-A0E8-FB5C3AE48045")]
public class ADOConnection : IADOConnection
{
public ADODB.ConnectionClass Conn(string alias)
{
AuthMode = 0;
Alias = alias;
lookupXML();

return m_conn;
}
public ADODB.ConnectionClass ConnUser(string alias, string user, string

pass)
{
Alias = alias;
Username = user;
Password = pass;
AuthMode = 1;
lookupXML();

return m_conn;
}
}

I have generated a KeyFile using sn.exe and placed the path of the file in
the AssemblyInfo.cs file as follows:

[assembly: AssemblyKeyFile("..\\..\\KeyFile.snk")]

I build the project and it goes fine.
I have a test VBscript file on the development machine to use the class.

It
works fine. I copy the dll to another machine which has the .NET

Framework
installed and also copy the VBscript file. I then run the command:
RegASM.exe /tlb:myAssembly.tlb myAssembly.dll

I get greeted with:

Types registered successfully
RegAsm error: Type library exporter encountered an error while processing
'ObjWa
re.Lib.IADOConnection.Conn(#0), MyAssembly'. Error: Type library exporter
can n
ot load type ADODB.ConnectionClass (error:

System.IO.FileNotFoundException:
File
or assembly name ADODB, or one of its dependencies, was not found.
File name: "ADODB"

=== Pre-bind state information ===
LOG: DisplayName = ADODB, Version=7.0.3300.0, Culture=neutral,
PublicKeyToken=b0
3f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = C:\WINNT\Microsoft.NET\Frame

What am I doing wrong? Any questions or more info I can give if needed.

Thanks always,
Jesse


Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Catherine Lynn Smith | last post by:
OK, newbie here - I am trying to figure how how in the heck I can use the Format command to pre-format integers to display a fixed length supplimenting leading zeros when needed. According to...
1
by: Peter Petrillo | last post by:
The Access development group here at this company has exported its reports in xml format from Access 2003. I have no influence on how they have created them. I received the following files xm...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
1
by: Jozsef Bekes | last post by:
Hi All, I need to offer scripting possibilities in my app, and have to use MSSCriptControl for some reasons. I would like to use the feature that's called variable number of arguments, that is...
1
by: MattB | last post by:
I have a vb.net assembly I need to make available as a COM object. After some Googling, I found this site: http://www.dnzone.com/ShowDetail.asp?NewsId=126 I followed the steps (substituting my...
1
by: MisterT | last post by:
I created a .NET library using the VS 2003 COM template. I can do a CreatObject() from vbscript, but none of the properties are visible. What is wrong? Here is the code: ...
1
by: Greg | last post by:
I have a .NET VB class library application ClassLibrary1 that creates an Excel object (Excel 2000 – 9.0 build 6926 SP-3) as below: Public Class Class1 Dim app As New Excel.Application Sub...
2
by: Jessard | last post by:
Help! Hi, I'm having a bit (well a lot - it's getting annoying) of trouble using a C# class library within a VBScript on a computer other than the development machine. All the class is needed...
7
by: Rich Milburn [MVP] | last post by:
Ok I am not a programmer, I copied some code and very painfully got it working in VB6. I can adjust the volume with waveOutSetVolume on winmm.dll. But I could not seem to be able to figure out how...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.