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. C#
  4. How to use VC++.Net code in VC#.Net project?

How to use VC++.Net code in VC#.Net project?

Scheduled Pinned Locked Moved C#
csharphelpc++tutorialquestion
8 Posts 2 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.
  • D Offline
    D Offline
    Divyang Mithaiwala
    wrote on last edited by
    #1

    Hello I have one VC++.Net project & want to use it in VC#.Net project. For that i add reference oc VC++ project & it is successfully added. But the problem is that in VC++ project there is no namespace & no class. All functions are globle. All are display in object browser. But no reference found in C# editor. plz help me. Regards


    Divyang Mithaiwala

    H 1 Reply Last reply
    0
    • D Divyang Mithaiwala

      Hello I have one VC++.Net project & want to use it in VC#.Net project. For that i add reference oc VC++ project & it is successfully added. But the problem is that in VC++ project there is no namespace & no class. All functions are globle. All are display in object browser. But no reference found in C# editor. plz help me. Regards


      Divyang Mithaiwala

      H Offline
      H Offline
      HakunaMatada
      wrote on last edited by
      #2

      If I am not mistaken, you are trying to use VC++ code in a C# Project! Right? Well, you simply can't do that? .NET has given us Language independence but not true Language Independence! I mean, you can't use VC++ code in a C# Environment. Got it? What you could so is, compile the functions from the VC++ project into a dll and then use it from the C# project. :) Hope this helps... --- With best regards, A Manchester United Fan The Genius of a true fool is that he can mess up a foolproof plan!

      D 1 Reply Last reply
      0
      • H HakunaMatada

        If I am not mistaken, you are trying to use VC++ code in a C# Project! Right? Well, you simply can't do that? .NET has given us Language independence but not true Language Independence! I mean, you can't use VC++ code in a C# Environment. Got it? What you could so is, compile the functions from the VC++ project into a dll and then use it from the C# project. :) Hope this helps... --- With best regards, A Manchester United Fan The Genius of a true fool is that he can mess up a foolproof plan!

        D Offline
        D Offline
        Divyang Mithaiwala
        wrote on last edited by
        #3

        Actually i am not trying to use code of VC++ in VC#. But i want to use function call of VC++ in VC#. Which is successfully done if project have namespace & class. But for my condition there is no namespace & no class in VC++ project. Regards,


        Divyang Mithaiwala

        H 1 Reply Last reply
        0
        • D Divyang Mithaiwala

          Actually i am not trying to use code of VC++ in VC#. But i want to use function call of VC++ in VC#. Which is successfully done if project have namespace & class. But for my condition there is no namespace & no class in VC++ project. Regards,


          Divyang Mithaiwala

          H Offline
          H Offline
          HakunaMatada
          wrote on last edited by
          #4

          Is the code you have written in VC++ managed? --- With best regards, A Manchester United Fan The Genius of a true fool is that he can mess up a foolproof plan!

          D 1 Reply Last reply
          0
          • H HakunaMatada

            Is the code you have written in VC++ managed? --- With best regards, A Manchester United Fan The Genius of a true fool is that he can mess up a foolproof plan!

            D Offline
            D Offline
            Divyang Mithaiwala
            wrote on last edited by
            #5

            VC++ project is Win32 console dll.


            Divyang Mithaiwala System Engineer & Software Developer

            H 1 Reply Last reply
            0
            • D Divyang Mithaiwala

              VC++ project is Win32 console dll.


              Divyang Mithaiwala System Engineer & Software Developer

              H Offline
              H Offline
              HakunaMatada
              wrote on last edited by
              #6

              Divyang Mithaiwala wrote:

              VC++ project is Win32 console dll.

              That's your problem. If you want to use a dll using Namespaces then the dll must be managed. If it is unmanaged then you will have to import the function of the dll using DLLImport. Check out articles related to calling Win32 APIs using C# in CP. Hope this helps...:) --- With best regards, A Manchester United Fan The Genius of a true fool is that he can mess up a foolproof plan!

              D 1 Reply Last reply
              0
              • H HakunaMatada

                Divyang Mithaiwala wrote:

                VC++ project is Win32 console dll.

                That's your problem. If you want to use a dll using Namespaces then the dll must be managed. If it is unmanaged then you will have to import the function of the dll using DLLImport. Check out articles related to calling Win32 APIs using C# in CP. Hope this helps...:) --- With best regards, A Manchester United Fan The Genius of a true fool is that he can mess up a foolproof plan!

                D Offline
                D Offline
                Divyang Mithaiwala
                wrote on last edited by
                #7

                Any other method to use it. Becoz when i use it as DLLImport then at run time it will give error that "Attempt to read or write protected memory". thanx.


                Divyang Mithaiwala

                H 1 Reply Last reply
                0
                • D Divyang Mithaiwala

                  Any other method to use it. Becoz when i use it as DLLImport then at run time it will give error that "Attempt to read or write protected memory". thanx.


                  Divyang Mithaiwala

                  H Offline
                  H Offline
                  HakunaMatada
                  wrote on last edited by
                  #8

                  Now I am not sure what your problem is? Refer to this[^] and this[^] for more details on DllImport. Hope this Helps...:) --- With best regards, A Manchester United Fan The Genius of a true fool is that he can mess up a foolproof plan!

                  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