473,563 Members | 2,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Connectio n 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.Connectio n object. So for example,
it would be used from VBScript like this:

Dim adoConn, conn

Set adoConn = CreateObject("M yLib.MyClass")
Set conn = adoConn.Conn("d atabaseName")
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.Connectio nClass Conn(string alias);
ADODB.Connectio nClass 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( ClassInterfaceT ype.None)]
[Guid("9E74AA5C-282E-42d5-A0E8-FB5C3AE48045")]
public class ADOConnection : IADOConnection
{
public ADODB.Connectio nClass Conn(string alias)
{
AuthMode = 0;
Alias = alias;
lookupXML();

return m_conn;
}
public ADODB.Connectio nClass 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 ("..\\..\\KeyFi le.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.IADOConn ection.Conn(#0) , MyAssembly'. Error: Type library exporter
can n
ot load type ADODB.Connectio nClass (error: System.IO.FileN otFoundExceptio n:
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.330 0.0, Culture=neutral ,
PublicKeyToken= b0
3f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = C:\WINNT\Micros oft.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 7902
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.dl l).

Patrice

--

"Jessard" <Je*****@discus sions.microsoft .com> a écrit dans le message de
news:5F******** *************** ***********@mic rosoft.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.Connectio n 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.Connectio n object. So for example, it would be used from VBScript like this:

Dim adoConn, conn

Set adoConn = CreateObject("M yLib.MyClass")
Set conn = adoConn.Conn("d atabaseName")
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.Connectio nClass Conn(string alias);
ADODB.Connectio nClass 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( ClassInterfaceT ype.None)]
[Guid("9E74AA5C-282E-42d5-A0E8-FB5C3AE48045")]
public class ADOConnection : IADOConnection
{
public ADODB.Connectio nClass Conn(string alias)
{
AuthMode = 0;
Alias = alias;
lookupXML();

return m_conn;
}
public ADODB.Connectio nClass 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 ("..\\..\\KeyFi le.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.IADOConn ection.Conn(#0) , MyAssembly'. Error: Type library exporter
can n
ot load type ADODB.Connectio nClass (error: System.IO.FileN otFoundExceptio n: 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.330 0.0, Culture=neutral ,
PublicKeyToken= b0
3f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = C:\WINNT\Micros oft.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.Connectio n 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.dl l).

Patrice

--

"Jessard" <Je*****@discus sions.microsoft .com> a écrit dans le message de
news:5F******** *************** ***********@mic rosoft.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.Connectio n 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.Connectio n object. So for

example,
it would be used from VBScript like this:

Dim adoConn, conn

Set adoConn = CreateObject("M yLib.MyClass")
Set conn = adoConn.Conn("d atabaseName")
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.Connectio nClass Conn(string alias);
ADODB.Connectio nClass 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( ClassInterfaceT ype.None)]
[Guid("9E74AA5C-282E-42d5-A0E8-FB5C3AE48045")]
public class ADOConnection : IADOConnection
{
public ADODB.Connectio nClass Conn(string alias)
{
AuthMode = 0;
Alias = alias;
lookupXML();

return m_conn;
}
public ADODB.Connectio nClass 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 ("..\\..\\KeyFi le.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.IADOConn ection.Conn(#0) , MyAssembly'. Error: Type library exporter
can n
ot load type ADODB.Connectio nClass (error:

System.IO.FileN otFoundExceptio n:
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.330 0.0, Culture=neutral ,
PublicKeyToken= b0
3f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = C:\WINNT\Micros oft.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
10396
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 the RTFM rigors I have been going through all morning, I just give Format an expression with the first value being either numeric or string. But when...
1
6882
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 xs xsl asp or html (my option Using a simple ASP.NET form with only a System.Web.UI.WebControls.Xml on it, I receive an error (below) that the...
11
6564
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 where the job is running, the job runs sucessfully, PDF files got generated, everything is good. If I scheduled the job to run at the time that I am...
1
4074
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 done in C# using the params keyword. However, if I AddObject the instance to the MSScriptControl, and try to ivoke a function with variable number of...
1
1138
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 application, class, and function names) and got no errors during the process. But now I try to access my library from vbscript, I get a "Can't create...
1
4186
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: <ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _ Public Class ComClass1 #Region "COM GUIDs"
1
3598
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 Main() MsgBox("Hello!") End Sub End Class
2
426
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 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...
7
7638
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 to adjust the master volume. I thought maybe if I upgraded this into VS2005 VB.Net then it might be a little easier. But now I am getting...
0
7664
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.