Using COM Objects in a VB.NET Class

I hope this is an OK post for this forum - the only other place I could find for it is the ASP Conversion alpha one - 

I'm converting some legacy ASP code into a VB.NET Class for use in a web application.
Here's the problem line:
Set Executor = Server.CreateObject("ASPExec.Execute")
Which returns this error when compiled:
error BC30807: 'Let' and 'Set' assignment statements are no longer supported.
If I take off the "set" from the line above, and recompile, i get this error:
BC30451: Name 'Server' is not declared.
How do you call a legacy COM Component from a VB.NET Class? I know that if I want to call it from an ASP.NET Page, i have to add this directive:
<%@ Page aspcompat=true %>
This is one of my first dealings with VB.NET classes. Thanks in advance for any help.
0
claygarrett
6/9/2004 2:37:05 PM
asp.net.free-for-all 9281 articles. 0 followers. Follow

7 Replies
968 Views

Similar Articles

[PageSpeed] 51

This shows that you've never really coded before.  You need to apply the reference to your own assembly, and call the object as it is.  Dim Executor As New ASPExec.Execute

Welcome to the world of real code.. well almost. You're still in the asp/vbscript mindset and vb6 blah whatevers.
Kay Lee
MySpace.com - http://www.myspace.com/kragie
Infrastructure Group
MySpace.com

- Code to live, but Live to code.
0
KraGiE
6/9/2004 7:55:11 PM
Right you are I'm still stuck in VBScript Mode.  And trying desperately to climb out.  

First of all - I don't have Visual Studio.NET - I'm compiling with the command line tool. So how do I apply the reference to my assembly? I tried the following (which may be off) but it didn't work (dummyfied code):
'--------------------------------------------
Imports System
Imports ASPExec
Namespace MyNamespace
Public Class NewClass
Function MyFunction As Boolean
Dim Executor As New ASPExec.Execute
End Function
End Class
End Namespace
'--------------------------------------------
Here's the compile error:
error BC30466: Namespace or type 'ASPExec' for the Imports 'ASPExec' cannot be found.
Imports ASPExec
~~~~~~~
The ASPExec.dll file is in the same directory as the file i'm compiling. I'm sure its novice what I'm missing. Thanks for your help in advance.
Clay
0
claygarrett
6/9/2004 8:48:47 PM
do you have a project file created?
Kay Lee
MySpace.com - http://www.myspace.com/kragie
Infrastructure Group
MySpace.com

- Code to live, but Live to code.
0
KraGiE
6/9/2004 8:57:40 PM
No - I don't have VisualStudio.Net.  I'm using all I have - which is dreamweaver mx to code my pages and the vbc.exe command line compiler to compile.
0
claygarrett
6/9/2004 8:58:41 PM
Would creating an interop assembly for the aspexec.dll file help in solving my problem?
0
claygarrett
6/9/2004 10:18:24 PM
your command line arguements is off.

csc /reference:ASPExec.dll; /out:out.exe input.
You need to reference your com object in the compiler command line.
Kay Lee
MySpace.com - http://www.myspace.com/kragie
Infrastructure Group
MySpace.com

- Code to live, but Live to code.
0
KraGiE
6/9/2004 10:26:52 PM
Just simply say:

Executor = CreateObject("ASPExec.Execute")

Creating an interop assembly makes things easy in one sense if you have an IDE that supports Intellisense, you'll see the members and it'll wrap some other things up for you that you would otherwise have to do manually.
You should try this pattern if you do it manually, this will be the easiest if you are using the command prompt, but there are better ways (if you're using an IDE that makes it relatively transparent, unlike the command prompt):
Imports System.Runtime.InteropServices.Marshal
....
....
Dim Executer As Object
....
Try
Executer = CreateObject("ASPExec.Execute")
...
Finally
If (Not Executer Is Nothing) Then
ReleaseComObject(Executor)
End If
End Try

Thanks,
Shawn
Shawn B.

www.zenofdotnet.com
0
shawnb
6/11/2004 5:02:09 PM
Reply:

Similar Artilces:

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

.Net 2.0 Web application using Vb.net is unable to create object of another dll writen in C# .net 2.0
Hi, I habe created one ASP.net web application using Vb.net which is adding reference of dlls written in C# and .net 2.0. But whenever trying to create object of referencing dll, it is throwing error :Object reference does not set to an object. But, locally it is working fine,. In the server i have deployed the .aspx files and dll files in the bin. There were already an web.config in the server which is of .net 1.1. But checked it is retrieving value for that web.config correctly. Should i have to deply any other files and if not what can be the solution for this? Please help. Thanks, So...

Using com object in vb.net
I successfully included in my web form an object of the DateTimePicker control 6.0 (sp4) - dropdownlist control. This is not native to vb.net. I want to read the entry of this object. Can anybody give a clue to this problem.J. Bouyea...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

How do I use the "Response" object in a separate vb .NET class?
Hey everyone,We are developing some custom web controls, which are separate VB .NET class files.We've discovered we need to implement some methods & properties of the "response" object (such as contenttype and binarywrite). However, we cannot figure out how to do this since:a) System.Web.HttpResponse is not inheritable ANDb) Vb classes which are custom web controls must inherit the "Control" class.Does anyone have any ideas on how to get around this?Thanks! You can access the current HttpContext by using the following: System.Web.HttpContext.CurrentYou can then access the Response Obj...

use of vb.net and c#.net
i make a small website using vb.net,  in it i make a 2 class in C#.net. that i want to use in that website, i dont know how to call that class. let your class is  - class clsMyClass    {        public void myFunction()        {            // do something        }    } now the first way - create objectclsMyClass myObj = new clsMyClass();myObj.myFunction(); // call function================...

VB.NET
All, This is probably a much harder question than what should go in the "Getting Started" forum, but I am new and don't know where to put it. Anyways, I am currently developing an FTP class in VB.NET. It's kid tested, mother approved when trying to access an FTP Server on a Windows box meaning I can connect, run commands, upload and download a file no problem. My issues come when I try to use the same class with the same commands to access an FTP server on a UNIX box. I can connect and login just fine, but after that all my commands come back "500 'PWD': command not understood.". This is fo...

how can i write this line using vb.net : container.dataitem ?.... in vb.net its not working
Dim container As GridView = CType(newLinkButton.NamingContainer, GridView) Dim dataValue As Object = DataBinder.Eval(container.dataitem, _ColName)   _ColName its just a string a name of the field in my database   This is Vb.Net code man what you want? You can convert any format from this link http://www.developerfusion.com/tools/convert/vb-to-csharp/  If this post is answer of your question then don't forgot to Click Mark As Answer...

How to use InterBase with VS.NET (vb.net)??
Hi all; Q1:How can I use "InterBase" as a RDMS with Visual Studio.NET (VB.NET) for developing a small application?? Q2:What should I use for a Data Provider? Q3:How ConnectionString will be build?? Thanks in advanced!Regards,CS4Ever~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Dont forget to click "Mark as Answer" on the post that helped you.This credits that member, earns you a point and marks your thread as Resolved so we will ALL know you have been helped. This will help me, you and others....

.NET classes hindering .net assembly from being com?
I posted an earlier thread about instanciating a .net assembly from a com client, like an asp page. My problem was that no matter what I did, I could not get the class to instaciate, so I could not call any methods on that class. After quite a bit of trial and error, as far as weak and strong named assemblies, GAC, etc, I came to the conclusion that the object WAS being referenced properly, therefore it was not a problem getting access to the object's class declaration. My problem was that everytime I called a method on the object, I got a "object not set to instance" error. ...

how to declare an internal class within a public class using vb.net?
how to declare an internal class within a public class using vb.net? Not sure exactly what you mean...  Is this what you are talking about? Public class Class1   Private Class availableOnlyToClass1   End ClassEnd ClassMark this post as the "Answer" if it was the answer....

Re: Gadget using vb.net and c#.net
 Hi, I am new to Gadget Concept. i want to create new Gadget. it must show the name 'Gadget Application'. pls, guide me how to create Gadget using .net application with some sample. thanks for your help in advance. Regards,Suriyanarayana.N  Unfortunately creating a Gadget using the .NET framework is not so simple. I have found a few post that might help you understand the process:http://www.codeproject.com/KB/gadgets/gadgettips.aspx http://www.codeproject.com/KB/gadgets/GadgetInterop.aspx Gabriel Bogéa (http://www.gbogea.com)-----------------Please 'Mark...

converting to vb.net from c#.net authorize.net
authorize.net offered me some sample code when I signed up with them the only problem is the sample code is in c#.net but my page that they type all of their credit card into is vb.net <code><%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %> <script language="C#" runat="server"> void Page_Load(Object Src, EventArgs E) { myPage.Text = readHtmlPage("https://certification.authorize.net/gateway/transact.dll"); } private String readHtmlPage(string url) { ...

Insert datetime, using ADO.net VB.net
Hello there,I got a little code there are inserting a record into my msSQL database..But i cant insert the datetime, for one reason?The problem is in line 7 () where i want to insert DateTime.Now 1 Protected Sub SendPmTilAfviste(ByVal modtager As String, ByVal festID As String) 2 ' Connection 3 Dim conn As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True") 4 conn.Open() 5 6 ' SQL-kommandoen 7 Dim cm...

Web resources about - Using COM Objects in a VB.NET Class - asp.net.free-for-all

Smart Personal Objects Technology - Wikipedia, the free encyclopedia
Smart Personal Object Technology (SPOT) was developed by Microsoft to personalize household electronics and other everyday devices, through "smart" ...

Review: Encounters: Revealing stories of Aboriginal and Torres Strait Islander objects from the British ...
This show will have a strong impact on viewers who pause to hear the voices of the assembled objects.

The Safety of Objects
The Safety of Objects Artforum WITH BLOCKBUSTER BIENNIALS increasingly wedded to the galleries underwriting them, the term “biennial art”—the ...

Boston Police detonate suspicious object; looking for man who left it behind
Boston Police's bomb squad detonated a suspicious object on Atlantic Avenue after shutting down access to vehicles and pedestrians in the area, ...

UK trio GoGo Penguin releasing 'Man Made Object' on Blue Note, making NYC debut at Winter Jazzfest
by Andrew Sacher It's probably not a coincidence that UK jazz trio GoGo Penguin's promo photo (above) looks an awful lot like the cover of James ...

Divers pull objects from lake in San Bernardino investigation - Videos - CBS News
In a murky lake, divers looking for clues pulled what looked like a CD or DVD out of the water. The lake is less than three miles from the Inland ...

Chicken Of The Sea, Bumble Bee Abandon Plan To Unite As One Giant Can Of Tuna After DOJ Objects
Chicken of the Sea and Bumble Bee will be leaving their underwater wedding separately despite going steady since 2014 : the two tuna companies ...

Turkish Fans Throw Objects At Israeli Basketball Team During Anthem
'This was a complex experience with a hostile arena,' Eden Inbar, coach of the Isareli national told Sport 5.

Pluto Probe Spies Object Lurking in the Kuiper Belt
Although Pluto is a distant memory to NASA's New Horizons mission, which flew past the dwarf planet in July, it doesn't mean its voyage of discovery ...

This is your closest look yet at a Kuiper Belt object
... you see in the picture above may not seem like much at first glance, but it's a pretty big deal it's humanity's closest-ever look at an object ...

Resources last updated: 12/15/2015 8:47:59 AM