?
Solved

Integrating vb.net and c#

Posted on 2004-11-19
2
Medium Priority
?
773 Views
Last Modified: 2012-06-21
hi,
i have this methods in vb.net and i want to access them from c#
i am posting both of them...
can any one help me out

[[[[vb.net]]]]---------------------------------------------------------------------------------------------

Imports System.Management
Public Function GetSignalStrength() As String
        On Error GoTo oops

        Dim query As ManagementObjectSearcher
        Dim Qc As ManagementObjectCollection
        Dim Oq As ObjectQuery
        Dim Ms As ManagementScope
        Dim Co As ConnectionOptions
        Dim Mo As ManagementObject
        Dim outp As String
        Dim ssid As String
        Co = New ConnectionOptions
        Ms = New ManagementScope("root\wmi")
        Oq = New ObjectQuery("SELECT * FROM MSNdis_80211_ReceivedSignalStrength Where active=true")
        query = New ManagementObjectSearcher(Ms, Oq)
        Qc = query.Get
        outp = ""
        For Each Mo In query.Get
            outp = outp & Mo("Ndis80211ReceivedSignalStrength") & " "
        Next
        Return Trim(outp)
        Exit Function
oops:
        Return Err.Description
    End Function

[[[[c# code]]]]--------------------------------------------------------------------------------------------------------
using System;
using System.Net;
using System.Net.Sockets;

namespace UdpEchoServer
{
    class App
    {
        private const int ServerPortNumber = 9696;

            [STAThread]
        static void Main(string[] args)
        {
            try {
                Socket udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

                        EndPoint localEP = new IPEndPoint(IPAddress.Any, ServerPortNumber);
                EndPoint remoteEP = new IPEndPoint(IPAddress.None, ServerPortNumber);
                udpSocket.Bind(localEP);

                byte [] receiveBuffer = new byte [512];
                try
                        {
                    while (true)
                              {
                        int receivedSize = udpSocket.ReceiveFrom(receiveBuffer, ref remoteEP);
                                                                                                             ***********//// i want to access the wireless signal strength method here
                        udpSocket.SendTo(receiveBuffer, receivedSize, SocketFlags.None, remoteEP);
                    }
                }
                        finally
                        {
                    udpSocket.Close();
                }
                        }
                        catch (SocketException se)
                        {
                              Console.WriteLine(se.ToString());
                        }
        }
    }
}
0
Comment
Question by:prashanth_gurijala
2 Comments
 
LVL 5

Assisted Solution

by:volking
volking earned 800 total points
ID: 12630655
Create two projects in ONE solution.
Project 1 = VB.NET
Project 2 = C#

Then simply call in either direction. VB.NET and C# are totally compatible, just not in the same project. Two projects, ONE solution.
0
 
LVL 7

Accepted Solution

by:
NipNFriar_Tuck earned 1200 total points
ID: 12630742
If you compile your VB.Net code into a dll and include the dll as a reference in your C# code and use the name space that your vb code is in then you would simply instantiate the class that the function is in and execute the function on that class...
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Screencast - Getting to Know the Pipeline
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month16 days, 10 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question