Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. What's .NET equivalent of a VC++ COM component with OLE DB via ATL?? Can't find info!

What's .NET equivalent of a VC++ COM component with OLE DB via ATL?? Can't find info!

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++questiondatabasecom
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    ThomasH1
    wrote on last edited by
    #1

    Hello everyone! I'm new here, and hopefully this is the right place to be. (Other forums haven't helped me in my search for information.) Last year, I wrote a web application with Visual Studio 6.0. I had ASP pages using JScript under IIS 5.0/Win2k server. To handle my business logic and database access, I wrote a COM component using VC++ 6.0. The COM component accessed the Oracle database using OLE DB via ATL - no ADO was used. My Big Question is: What's the equivilant of my old COM component in Visual Studio .NET 2003?? I realize that nobody uses straight OLE DB anymore. (It was hard enough to find the OLE DB SDK 2.0 book last year!) So I'll be using ADO.NET instead, which means I'll be using Managed C++. I found a great example on how to use ADO.NET from MC++ from this website (link is http://www.codeproject.com/managedcpp/adonet\_mcpp.asp?target=ado.net|primer|using|managed ). But I can't seem to find any help on designing a component for use with ASP! Perhaps I'm using the wrong term? Every search I've done for ".NET component" has pointed me to text boxes, or data grids, or the term "object"- and "Object" has pointed me back to text boxes and data grids. I want to stick with Managed Visual C++ for performance reasons. With the VC++ COM component, the server didn't even come close to bogging down- very cool! So I can't bring myself to write everything in ASP.NET, as most of the examples on the 'net seem to do. I want to write a component (or whatever the current terminology is?) that I can access from anywhere- from ASP.NET, from WSH, from VB.NET, etc! How do I do it? I also can't find anything about threading. My COM component used apartment threading. Do I need to specifically implement threading for the .NET equivalent? Or would this be handled by the NET Framework automatically? If so, why do I see examples on the 'net for VC# that describe how to add threading support? In fact, you know what I'd really like? I started off with a book by Wrox Press, called "Beginning Components for ASP using VB, VC++, and ATL". That book tied -everything- together for me, and started me off in the right direction. Is there such a book for .NET? Thanks in advance! This is driving me nuts- I've figured out everything else, but I don't know how to convert my component into .NET technology. I know I could use my old COM DLL from .NET, but this is probably the best time for me to upgrade my application. I don't want to be locked into using COM for the next 5 years. -Thom

    B J T 3 Replies Last reply
    0
    • T ThomasH1

      Hello everyone! I'm new here, and hopefully this is the right place to be. (Other forums haven't helped me in my search for information.) Last year, I wrote a web application with Visual Studio 6.0. I had ASP pages using JScript under IIS 5.0/Win2k server. To handle my business logic and database access, I wrote a COM component using VC++ 6.0. The COM component accessed the Oracle database using OLE DB via ATL - no ADO was used. My Big Question is: What's the equivilant of my old COM component in Visual Studio .NET 2003?? I realize that nobody uses straight OLE DB anymore. (It was hard enough to find the OLE DB SDK 2.0 book last year!) So I'll be using ADO.NET instead, which means I'll be using Managed C++. I found a great example on how to use ADO.NET from MC++ from this website (link is http://www.codeproject.com/managedcpp/adonet\_mcpp.asp?target=ado.net|primer|using|managed ). But I can't seem to find any help on designing a component for use with ASP! Perhaps I'm using the wrong term? Every search I've done for ".NET component" has pointed me to text boxes, or data grids, or the term "object"- and "Object" has pointed me back to text boxes and data grids. I want to stick with Managed Visual C++ for performance reasons. With the VC++ COM component, the server didn't even come close to bogging down- very cool! So I can't bring myself to write everything in ASP.NET, as most of the examples on the 'net seem to do. I want to write a component (or whatever the current terminology is?) that I can access from anywhere- from ASP.NET, from WSH, from VB.NET, etc! How do I do it? I also can't find anything about threading. My COM component used apartment threading. Do I need to specifically implement threading for the .NET equivalent? Or would this be handled by the NET Framework automatically? If so, why do I see examples on the 'net for VC# that describe how to add threading support? In fact, you know what I'd really like? I started off with a book by Wrox Press, called "Beginning Components for ASP using VB, VC++, and ATL". That book tied -everything- together for me, and started me off in the right direction. Is there such a book for .NET? Thanks in advance! This is driving me nuts- I've figured out everything else, but I don't know how to convert my component into .NET technology. I know I could use my old COM DLL from .NET, but this is probably the best time for me to upgrade my application. I don't want to be locked into using COM for the next 5 years. -Thom

      B Offline
      B Offline
      Bo Hunter
      wrote on last edited by
      #2

      Microsoft has tons of stuff. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/\_atl\_Introduction\_to\_COM\_and\_ATL.asp?frame=true

      T 1 Reply Last reply
      0
      • B Bo Hunter

        Microsoft has tons of stuff. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/\_atl\_Introduction\_to\_COM\_and\_ATL.asp?frame=true

        T Offline
        T Offline
        ThomasH1
        wrote on last edited by
        #3

        Thanks for the fast reply! But, that appears to be a link to old COM stuff, not a .NET equivalence. I already have my COM component written; I want to re-do it in Managed C++ .NET, not unmanaged. My goal is to not use COM anymore, but to use whatever the .NET equivalence is. And I don't want to use my old COM from .NET. Or did I misunderstand your link? Thanks! -Thomas

        1 Reply Last reply
        0
        • T ThomasH1

          Hello everyone! I'm new here, and hopefully this is the right place to be. (Other forums haven't helped me in my search for information.) Last year, I wrote a web application with Visual Studio 6.0. I had ASP pages using JScript under IIS 5.0/Win2k server. To handle my business logic and database access, I wrote a COM component using VC++ 6.0. The COM component accessed the Oracle database using OLE DB via ATL - no ADO was used. My Big Question is: What's the equivilant of my old COM component in Visual Studio .NET 2003?? I realize that nobody uses straight OLE DB anymore. (It was hard enough to find the OLE DB SDK 2.0 book last year!) So I'll be using ADO.NET instead, which means I'll be using Managed C++. I found a great example on how to use ADO.NET from MC++ from this website (link is http://www.codeproject.com/managedcpp/adonet\_mcpp.asp?target=ado.net|primer|using|managed ). But I can't seem to find any help on designing a component for use with ASP! Perhaps I'm using the wrong term? Every search I've done for ".NET component" has pointed me to text boxes, or data grids, or the term "object"- and "Object" has pointed me back to text boxes and data grids. I want to stick with Managed Visual C++ for performance reasons. With the VC++ COM component, the server didn't even come close to bogging down- very cool! So I can't bring myself to write everything in ASP.NET, as most of the examples on the 'net seem to do. I want to write a component (or whatever the current terminology is?) that I can access from anywhere- from ASP.NET, from WSH, from VB.NET, etc! How do I do it? I also can't find anything about threading. My COM component used apartment threading. Do I need to specifically implement threading for the .NET equivalent? Or would this be handled by the NET Framework automatically? If so, why do I see examples on the 'net for VC# that describe how to add threading support? In fact, you know what I'd really like? I started off with a book by Wrox Press, called "Beginning Components for ASP using VB, VC++, and ATL". That book tied -everything- together for me, and started me off in the right direction. Is there such a book for .NET? Thanks in advance! This is driving me nuts- I've figured out everything else, but I don't know how to convert my component into .NET technology. I know I could use my old COM DLL from .NET, but this is probably the best time for me to upgrade my application. I don't want to be locked into using COM for the next 5 years. -Thom

          J Offline
          J Offline
          J Dunlap
          wrote on last edited by
          #4

          ThomasH1 wrote: But I can't seem to find any help on designing a component for use with ASP! Just use COM interop (see the link below, and Managed Extensions for C++ and COM Interoperability Tutorial[^]). If you follow the guidelines listed, you can use a .NET component just like any COM component. ThomasH1 wrote: I also can't find anything about threading. My COM component used apartment threading. Do I need to specifically implement threading for the .NET equivalent? Or would this be handled by the NET Framework automatically? If so, why do I see examples on the 'net for VC# that describe how to add threading support? .NET is by default free-threaded, but it's not very hard to make a given thread be an STA Apartment thread. Basically, you just set the current thread's ApartmentState to STA:

          System::Threading::Thread::CurrentThread->ApartmentState =
          System::Threading::ApartmentState::STA;

          You'll want to do this in the entry point (WinMain) method. In C#/VB.NET, you can also use the STAThreadAttribute attribute on the entry point to ensure that the main thread is STA by default:

          [STAThread]
          public static void Main(string args)
          ...

          ...but I don't know if this works in MC++. Here's a reference on threading in .NET: Managed and Unmanaged Threading[^]. It mainly deals w/C# and VB.NET, but it's also relevant to MC++. There's also a reference section on Exposing .NET Framework Components to COM[^], which might help.

          T 1 Reply Last reply
          0
          • J J Dunlap

            ThomasH1 wrote: But I can't seem to find any help on designing a component for use with ASP! Just use COM interop (see the link below, and Managed Extensions for C++ and COM Interoperability Tutorial[^]). If you follow the guidelines listed, you can use a .NET component just like any COM component. ThomasH1 wrote: I also can't find anything about threading. My COM component used apartment threading. Do I need to specifically implement threading for the .NET equivalent? Or would this be handled by the NET Framework automatically? If so, why do I see examples on the 'net for VC# that describe how to add threading support? .NET is by default free-threaded, but it's not very hard to make a given thread be an STA Apartment thread. Basically, you just set the current thread's ApartmentState to STA:

            System::Threading::Thread::CurrentThread->ApartmentState =
            System::Threading::ApartmentState::STA;

            You'll want to do this in the entry point (WinMain) method. In C#/VB.NET, you can also use the STAThreadAttribute attribute on the entry point to ensure that the main thread is STA by default:

            [STAThread]
            public static void Main(string args)
            ...

            ...but I don't know if this works in MC++. Here's a reference on threading in .NET: Managed and Unmanaged Threading[^]. It mainly deals w/C# and VB.NET, but it's also relevant to MC++. There's also a reference section on Exposing .NET Framework Components to COM[^], which might help.

            T Offline
            T Offline
            ThomasH1
            wrote on last edited by
            #5

            jdunlap wrote: ThomasH1 wrote: But I can't seem to find any help on designing a component for use with ASP! Just use COM interop (see the link below, and Managed Extensions for C++ and COM Interoperability Tutorial[^]). If you follow the guidelines listed, you can use a .NET component just like any COM component. But, one problem- like I said, I don't want to use COM interop- I don't want anything to do with COM! :) Or are you telling me that COM is the only way to do what I want? I don't think that's what you're saying, because you just mentioned a ".NET component"- how do I make a .NET component??? That's my big question! (grin) I dug up some more info, specifically, http://www.asptoday.com/contentprint.asp?id=617, "Creating a DB Component with C# and ADO.NET", and the guy has me make a new C# class. Is that what I'd do in managed C++? Just make a class? And that would become my .NET component, and I could reference that component from ASP pages? There's no more DLL registration (regsvr32), it's all "automatic" somehow, right? Also, with regards to threads- from the way you wrote your message, and from what I see at managed & unmanaged threading, it seems that manual threading code is only needed for COM interop- is that correct? Thanks! -Thomas

            1 Reply Last reply
            0
            • T ThomasH1

              Hello everyone! I'm new here, and hopefully this is the right place to be. (Other forums haven't helped me in my search for information.) Last year, I wrote a web application with Visual Studio 6.0. I had ASP pages using JScript under IIS 5.0/Win2k server. To handle my business logic and database access, I wrote a COM component using VC++ 6.0. The COM component accessed the Oracle database using OLE DB via ATL - no ADO was used. My Big Question is: What's the equivilant of my old COM component in Visual Studio .NET 2003?? I realize that nobody uses straight OLE DB anymore. (It was hard enough to find the OLE DB SDK 2.0 book last year!) So I'll be using ADO.NET instead, which means I'll be using Managed C++. I found a great example on how to use ADO.NET from MC++ from this website (link is http://www.codeproject.com/managedcpp/adonet\_mcpp.asp?target=ado.net|primer|using|managed ). But I can't seem to find any help on designing a component for use with ASP! Perhaps I'm using the wrong term? Every search I've done for ".NET component" has pointed me to text boxes, or data grids, or the term "object"- and "Object" has pointed me back to text boxes and data grids. I want to stick with Managed Visual C++ for performance reasons. With the VC++ COM component, the server didn't even come close to bogging down- very cool! So I can't bring myself to write everything in ASP.NET, as most of the examples on the 'net seem to do. I want to write a component (or whatever the current terminology is?) that I can access from anywhere- from ASP.NET, from WSH, from VB.NET, etc! How do I do it? I also can't find anything about threading. My COM component used apartment threading. Do I need to specifically implement threading for the .NET equivalent? Or would this be handled by the NET Framework automatically? If so, why do I see examples on the 'net for VC# that describe how to add threading support? In fact, you know what I'd really like? I started off with a book by Wrox Press, called "Beginning Components for ASP using VB, VC++, and ATL". That book tied -everything- together for me, and started me off in the right direction. Is there such a book for .NET? Thanks in advance! This is driving me nuts- I've figured out everything else, but I don't know how to convert my component into .NET technology. I know I could use my old COM DLL from .NET, but this is probably the best time for me to upgrade my application. I don't want to be locked into using COM for the next 5 years. -Thom

              T Offline
              T Offline
              ThomasH1
              wrote on last edited by
              #6

              ThomasH1 wrote: My Big Question is: What's the equivilant of my old COM component in Visual Studio .NET 2003?? Okay, I know I'm replying to myself, but I think I might've found what I was looking for. It was above a link in the MSDN docs that jdunlap pointed me to. Link is http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconexposingnetframeworkcomponentstocom.asp , "Developing Components". The docs are written for VB & VC# (figures), but I think I can apply it to MC++. One bit jumps out at me, under the "Class vs Component vs Control" section, under the Container & Site heading. It says "If you are developing components...for Web Forms pages (ASP.NET pages), you do not have to implement containers or sites". I've got more reading to do, but can I assume that ASP will take care of threading? Thanks! -Thomas

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups