COM works in VB.net, not C#??

I am converting a site from asp to asp.net.  This site uses a COM object and I would like to use C#.  I've included aspcompat=true in my page directive.

In VB.net, it works great.......
Dim oLDS as Object
oLDS = Server.CreateObject("ldswebapi.Lookup")
oLDs.Initialize("C:\LDSDATA")

In C#, not so great........
Object oLDS = new Object();    // or Object oLDS;
oLDS = Server.CreateObject("ldswebapi.Lookup");
oLDs.Initialize("C:\LDSDATA");

I get error "object does not contain a definition Initialize"

I don't get it.  Can I not use C# for this?

 


jepatte
0
jepatte
2/17/2007 4:30:05 AM
asp.net.migrating-from-asp 901 articles. 0 followers. Follow

3 Replies
630 Views

Similar Articles

[PageSpeed] 21

Yeah you can. The problem is that VB.NET is loose. The "object" object doesn't have a method called Initialize. Your object might, but because it is of type object, C# won't recognize it. It is like turning EXPLICIT and STRICT on in VB.NET. You would have to cast your object to a COM wrapper, or Invoke it with reflection.
Cheers,
       Kevin Jones


0
vcsjones
2/17/2007 5:39:24 AM
So what is an example of a COM wrapper or Invoke it w/ reflection?
jepatte
0
jepatte
2/17/2007 5:13:30 PM

you can add reference your com object in Visual Studio by right click on your project and select Add Preference. Select the dlls you want to use.

 This will create an Interop dll.

You can try the following

 using ldswebapi.Lookup;

 ldswebapi.Lookup oLDS = new ldswebapi.Lookup();

oLDs.Initialize("C:\LDSDATA");

 

Hope this helps

0
christopher_hoang
3/7/2007 11:20: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...

Type.GetType does not work in VB.NET but works in C#. VB.NET gurus Please help
Friends,   I am an experienced C# programmer who is working on a VB.NET project now. I am writing different methods covering the following functionalities 1) Take a datareader as input and return an arraylist of class object2) Take an xmlnode (received from a webservice) as input and return an arraylist of class object. The methods are generic methods which take datareader/xmlnode as first parameter and classname (string) as the second parameter. This way it will work trivially. The schema of class object matches with the input (datareader or xmlnode)In C# I used to do th...

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 developing. The trick is to use the "Src" attribute of the @Page directive. Check out the link if you are inclined. You are welcome to download the code if you are interested further, found at the same link. (Note that the reason that I looked for a way to do this is because I wanted to have the option to include some VB.NET-based demos at my site. Since my site is a C#.NET ASP.NET, I was told that there was no want to do this. Therefore, I looked for a workaround and just happened to find one.) Enjoy (and then get back to work!) http://www.NetBrainer.com you are right !!!mixing languages could cause unknow and uncontrolled problems !!! if a developer has to mix ....the practical way is to create a new project with different language and what will be absolutely fine !!!thanks mkamoski for raising this issue !!Fadil Alnassar www.fadilalnassar.com | FREE Nodil Tab Controlhttp://www.mefranchisi...

How to migrate code from vb.net to c#.net?
Hi all,If anybody knows information on migration of VB.Net application to C#.net. i.e Any tools available, best practices, methodology for estimation. etc.   RegardsHelen    Hey, Take a look at this topic http://forums.asp.net/t/1100603.aspxMaybe some of these sites can be of help to you.  Arnold you can do it by page by page just copy and paste ur page in the following link http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx and convert ur vb.net to c# gotcha!!YasserSpica.www.spica.aewww.bncnetwork.netPlease remember to mark as answers i...

Migrate code from vb.net to C#.net
Hello friends, I had created a web site using visual studio 2005. web site was created using the language vb i.e. VB.net. Now as per the clint requirement I have to migrate all the code in C#. So the question is that is there any tool or any inbuild utility in Visual Stuidio so that we can migrate the site from vb.net to C#.net. Or we have to do it mannually i.e. by changing each and every line of code mannually? Kindly suggest me. Thanks & Regards Girish NehteThanks & RegardsGirish NehteIf This post helps you to solve your problem please mark this as an answer. Hi, at the mome...

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) { ...

vb.net vs c#.net vs j#.net
just out of curiousity which looks, acts most like java? i'm still learning trying to used to vb.net but it seems that it was easier to do some stuff with java. C# is Java++ in my opinion. If you have done C or Jave you will prefer C#.Mike Schellenberger - MCAD If you are looking for language similar to java go for J#. However most code samples you find on the net will be in VB.NET and C#....

C#.NET or VB.NET
what lang does everyone prefer? Thanks, Peter Iuvara, MCP It's a very famous debatable question in forums! I would say if you are from Java/C/C++, then C# would be easy to use for you. If you are from ASP/VB, then VB.NET would be easy for you! As long as if you follow CLS, then what ever the language you use, it's going to be the same for CLR!Sreedharhttp://www.w3coder.orgweblog http://weblogs.asp.net/skoganti I would agree with that ... just curious as to what user's on this forum predominantly code in?Thanks, Peter Iuvara, MCP I came from no real programming background, started i...

vb .net or c# .net
I currently develop websites using php but have been requested to develop a site using asp.net. The question I have is for someone who knows php would it be better to transition to vb.net or c#.net? Thanks, Fr. Robert C# -> There is a converter that will transition about 60% or more of your PHP code to C#. Plus C# is closer to PHP than VB.NET.Jason N. GaylordASPInsider and Microsoft MVPhttp://jasongaylord.com...

VB.Net To C#.Net
Hello... Since Last from 1 year i had develope web application in using vb.net now i want to transfer from vb.net to c#.net so what should i do to transform to c# language any link or book related to me through i can easily understand and coding using c# in a short time... Thanks~ Mark As Answer If UseFull ~Kaushal. Hi, you can read the specifications of the language. You're already familiar with .NET and how to program in an OO manner thanks to your experience with vb.net. The only thing you need to learn is the new syntax of C#. You can also convert parts of your v...

Help Me C# is working But VB.net Not working
Edited by SomeNewKid. Please post code between <code> and </code> tags. Pls, Help me, It is simple chat programe. My <IFRAME> src is calling the bellow event in C# it is working perfectly. private void Page_Load(object sender, System.EventArgs e) { string sDealer=""; string sWrite=""; if ( Session["Channel"] != null ) sDealer = Session["Channel"].ToString(); Response.Write( "<meta http-equiv=\"Refresh\"content=\"4\">" ); sWrite=MyModule.MyChat.GetAl...

vb.net and c#.net same app
Been asked before, but... If I build a c# web app and someone builds a vb.net desktop app, can they communicate? and can you develop against it...ie..in my c# web app, can I add the vb.net desktop app as a reference? or at least make calls to it? web apps or desktop apps can contain components created in either language. i have a web solution that contains 4 projects. One of the projects is C# the others are VB.Mike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/ Thanks...that is what I was looking for ...

Converting from vb.net to c#.net
Hello I have recently purchased VBGolds RawDataPrinter which should allow users to print directly to label printers on our network directly from a c# web form.  Unfortunately they only supply vb.net examples and I have need of c#.  The component has been installed on our web server.  This is some code that they have supplied as examples in vb.net   "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" >"Head1" runat="server&qu...

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================...

Difference Between VB.Net And C#.Net
 hi friends,Please tell me the key difference between the Vb.Net And C#.Net..wheather vb.net supports operator overloading..Thanks & Regards,Pravin Kumar T.   Regards,Pravin Kumar T. pravin_thanusu:Please tell me the key difference between the Vb.Net And C#.Net.. Neither are ASP.NET so you probably want a different forum.  You'll also find your answers at Microsoft.com. JeffPlease: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.  >Please tell me the k...

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

convert c#.net page to vb.net
ok I have an entire page in vb.net and now I want to integrate some code from another page but it written in c#.net what is the easiest way to convert c#.net to vb.net I tried using www.kamalpatel.net/ConvertCSharp2VB.aspx but it only gave me errors here is what I am trying to convert let me know if you have any ideas http://www.nomorepasting.com/paste.php?pasteID=20953 With Alex Lowe's translator ' Messages Private NoFileMessage As String = "No file selected" Private UploadSuccessMessage As String = "Uploaded Sucess" Private NoImagesMessag...

Call to non .net COM not working after .NET
I have developed small samples of ASP.NET and one of them I tried to call a standard COM (non .NET). I took the code out for now, but a call to that COM from traditional ASP application now does not work. Does anyone have an idea how to correct this?...

Structures in VB.NET > C#.NET
Hello,I have a VB.NET codePublic Structure MyDates    Dim _Title as String    Dim _Date as DateTimeEnd StructureSOME CODE GOES HERE temp = New MyDates()While(myDataReader.Read()) temp._Title = myDataReader.Item("Title")   -------------------------------------------------------------------------I have written this using C#.NET.Here is the code public struct MyDates    {        string _Title;        DateTime _Date;       ...

Integrating the C#.net and VB.net application
Hello All,  I'm trying to integrate the C#.net application and VB.net application.  Can you give me any suggestions of how to merge them.  Thanks in Advance You are probably goign to have to convert one of the applications to the other language at one point.  There are online conversion tools to help http://www.carlosag.net/Tools/CodeTranslator/- WilliamPlease mark the most helpful reply/replies as "Answer".Give some of my PWSK modules a try.  Type of application?We All move to our original place.Don't forget.Imran Baloch @weighfield: I d...

Convert VB.Net application to C#.net
Haican any one help me to convert VB.Net application in this link to C#.net http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=6718&lngWId=10RegardsAnu Palavila  Regards Anu Palavila Use this Free Conversion tool - http://www.developerfusion.com/tools/convert/vb-to-csharp/  ASP.NET Grid With Excel Capabilities | 27 GridView Tips & Tricks | Hosting your site? | SQL Server Tips Other Code Convertors (convert VB to C# and C# to VB) http://converter.telerik.com/ http://www.developerfusion.com/tools/convert/csharp-to-vb/ http://www.dotnetspider.com...

How to change vb.net code to C#.Net ?...
Hi, Earlier i had a class  that i got it from this Forum, it in vb.net and i am trying it to convert it in c#.net but i am unable to covert properly to work. the functionality of this class is to convert number value to words. i am putting both of code c#.net and VB.net please rectify it.Public Class NumberToWords Dim Character As String Public Function ConvertNumber(ByVal A As Double) As String On Error Resume Next Dim MM Dim IM ConvertNumber = "" MM = Microsoft.VisualBasic.Len(A) IM = Microsoft.VisualBasic.Left(A, Mic...

Can VB.NET and C#.NET combined?
Hi, I have a web application so far written in VB.NET using Web Matrix. I need to create a chat program like MSN ... but I wish to use C#.NET to create this chat program, so I can learn about it ... can I combined VB.NET and C#.NET in the same application? Hello, I thought you could have a look at this: Mixing VB and C# in same Web Application regards.Bilal Hadiar, MCP, MCTS, MCPD, MCTMicrosoft MVP - Telerik MVP I don't recommend mixing the two in the same application (if is even possible), but what you can do is encapsulate all of your logic into an asembly (dll) written in c# and ...

is it true, that vb.net is a wrapper to c#.net.??
is it true, that vb.net is a wrapper to c#.net.?? can anyone validate that? and if so, what source? Thanx Kamran Sorathia No, it is not true. See this: Programming Languages (Designing Distributed Applications with Visual Studio .NET) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsent7/html/vxconProgrammingLanguages.asp These languages are mainly equal, though they do have differences mainly related to what their compiler does and what the corresponding dev team at MS has had in mind when they've though out the features. Both languages have t...

Web resources about - COM works in VB.net, not C#?? - asp.net.migrating-from-asp

Energized Work
Fat free approach. No bureaucracy. No waste. Just common sense,disciplined technique, and radical transparency.

Financial Wisdom Works
Home Staff Privacy Policy Contact Search for: News Budgeting Education Debt Insurance Retirement Investing Credit Cards Teach Kids Financial ...

Research Works Act - Wikipedia, the free encyclopedia
The Research Works Act , also known as H.R. 3699, is a bill that was introduced in the United States House of Representatives at the 112th United ...

Gay concedes 'teething problems' in work to reduce Sydney Airport road gridlock
Consider the train when it's essential to get to the airport, says Duncan Gay.

Va. says suicide hotline improvements were in the works
13newsnow.com Va. says suicide hotline improvements were in the works 13newsnow.com Improvements were underway at the Veterans Affairs suicide ...

Kojima, del Toro vow to work together again after Silent Hills debacle
... like an odd professional and artistic partnership. In a wide-ranging talk on the DICE stage Thursday, though, both creators detailed a working ...

Now you can live in a dorm-like apartment building where neighbors use a work app called Slack to communicate ...
Slack is a hot San Francisco startup that makes a chat app for the workplace. Now, it's coming to a dorm-like apartment building in the trendy ...

Donald Trump: "Torture works"
The GOP frontrunner also said the U.S. should "go much stronger" than waterboarding

The Sun: Prince William is ‘quite petulant’ & ‘a bit bored’ with his pilot work
... here to read . This event in Wales today was only William’s second event of the year. The excuse being used for William’s lack of royal work ...

Deadpool 2 Movie Is Already In The Works
Now that Deadpool has made it out of development hell and into box office heaven, setting opening weekend records for an R-rated movie and for ...

Resources last updated: 2/19/2016 4:51:47 AM