Write DLL in VB.NET for C++

Erdenemandal

Well-known member
Joined
Jul 5, 2004
Messages
63
Location
Deutschland
Hallo

I am working in VB.NET, and I want to write a DLL for Visual C++. It works in VB.net (Create a DLL and use it in VB.NET) but in Visual C++, It does not recognize a function.

This is a code.

Code:
Imports System.Drawing

Public Class clsMyClass
        Private mMyName As String

        Property MyName() As String
                Get
                        MyName = mMyName
                End Get
                Set(ByVal Value As String)
                        mMyName = Value
                End Set
        End Property

        Public Function GetDate() As String
                 Return todays date
                Return "Today is " & Today
        End Function

        Public Sub DrawResult(ByRef Obj As Windows.Forms.Panel, _
                 ByRef TotalHit As Integer, _
                 ByRef RightHit As Integer, _
                 ByRef FormObj As Windows.Forms.TabPage)

                Obj.Visible = False

                 Get a Graphics object from the current form and clear its background.

                Dim gr As Graphics = FormObj.CreateGraphics

                Dim mPen As New Pen(Color.White, 2)
                Dim mPen2 As New Pen(Color.RoyalBlue.Black, 1)

                Dim TotalProzent, Total2 As Integer


                Dim rr As New Rectangle(Obj.Left, Obj.Top, Obj.Width, Obj.Height)
                gr.FillRectangle(Brushes.White, rr)
               
                TotalProzent = Int(RightHit / TotalHit * 360)

                 Draw a green filled rectangle.

                Dim x, y, mWidth, mHeight, StartAngle, SweepAngle As Integer

                x = Obj.Left + 10
                y = Obj.Top + 10
                mHeight = Obj.Height - 20
                mWidth = Obj.Width - 20

                 Draw a red pie (portion of an ellipse).
                Dim i, j As Integer
                For i = 0 To TotalProzent
                        gr.FillPie(Brushes.Blue, x, y, mWidth, mHeight, 0, i)
                Next


                gr.DrawPie(mPen2, x, y, mWidth, mHeight, 0, TotalProzent)

                Total2 = 360 - TotalProzent

                For i = 0 To Total2
                        gr.FillPie(Brushes.Red, x, y, mWidth, mHeight, TotalProzent, i)
                Next

                gr.DrawPie(mPen2, x, y, mWidth, mHeight, TotalProzent, Total2)
                gr.Dispose()
                
        End Sub


End Class

Please help me.
 
If this is for a managed C++ project, youre in luck! Just add a reference to the VB.NET DLL (or project, if both projects are in the same solution)!

If this is for unmanaged C++, youre outta luck, mostly. You can probably wrap the VB.NET code as a COM object and create/use the object from unmanged C++, but thats a LOT of work.

-ner
 
Nerseus said:
If this is for a managed C++ project, youre in luck! Just add a reference to the VB.NET DLL (or project, if both projects are in the same solution)!

If this is for unmanaged C++, youre outta luck, mostly. You can probably wrap the VB.NET code as a COM object and create/use the object from unmanged C++, but thats a LOT of work.

-ner

You have a bit more options. Some of the things that come to mind is creating a mixed mode c++ dll, or using the gcroot template
 
Back
Top