473,387 Members | 1,476 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

WSALookupServiceBegin failing C#

Hi

I am trying to run WSALookupServiceBegin from C#, here is my code extract of what I am doing

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal struct WSAQuerySet
{
public Int32 dwSize;
public string lpszServiceInstanceName;
public GuidlpServiceClassId;
public LPWSAVERSION lpVersion;
public string lpszComment;
public UInt32 dwNameSpace;
public Guid lpNSProviderId;
public string lpszContext;
public UInt32 dwNumberOfProtocols;
public LPAFPROTOCOLS lpafpProtocols;
public string lpszQueryString;
public UInt32 dwNumberOfCsAddrs;
public CSADDR_INFO lpcsaBuffer;
public UInt32 dwOutputFlags;
public LPBLOB lpBlob;
}

[DllImport("ws2_32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
internal static extern int WSAStartup(
[In] short wVersionRequested,
[Out] out WSAData lpWSAData
);
[DllImport("ws2_32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
internal static extern int WSALookupServiceBegin(
[MarshalAs(UnmanagedType.Struct)]
ref WSAQuerySet lpqsRestrictions,
ushort dwControlFlags,
ref Int32 lphLookup
);
int result = WSAStartup(VERSION, out d);
//it is successful
wsaq.dwNameSpace = NS_BTH;
wsaq.lpServiceClassId = GUID_BLUETOOTH_RADIO_IN_RANGE; // GUID_BLUETOOTH_L2CAP_EVENT;
wsaq.dwSize = 138; // System.Runtime.InteropServices.Marshal.SizeOf(wsaq );
int iRet = WSALookupServiceBegin( ref wsaq, dwFlags, ref hLookup);

I get this error

Attempted to read or write protected memory. This is often an indication that other memory has been corrupted.

Any help to improve this will appreciated
--------------------------------
From: Gund appa

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>tkrigo9STEG5VJkHvnlXjw==</Id>
Nov 16 '05 #1
0 2753

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Simon Stewart | last post by:
Has anyone else experience of imagecreatefromjpeg failing with an error message about memory even though the size of the image being uploaded is nothing like the space available to the script? ...
0
by: Sundeep Gawande | last post by:
I am facing a strange problem. I am trying to host a .NET(C#) control in a VC6 COM ocx. Now when I create the control using CreateControl(...) or CoCreateInstance(...) my call is failing with...
7
by: Kieran Simkin | last post by:
Hi all, I'm having some trouble with a linked list function and was wondering if anyone could shed any light on it. Basically I have a singly-linked list which stores pid numbers of a process's...
3
by: bob | last post by:
Hello, I've tried a few testing frameworks with C# but so far haven't found a way to debug into a failing test. I'm used to S Unit (Smalltalk) where when a test fails you just right click on it...
1
by: Frank Rizzo | last post by:
Hello, I have a bunch of thread in my app doing variuos things. One of them is failing at some point in the app and I can't (actually don't know how) figure out which one it is. Is there a way to...
3
by: Michael Tissington | last post by:
I'm using LoadLibrary to import a DLL in a asp.net application. The dll was written in c++ and is located in the bin folder I have been testing the website on my development machine and our...
18
by: Scott David Daniels | last post by:
There has been a bit of discussion about a way of providing test cases in a test suite that _should_ work but don't. One of the rules has been the test suite should be runnable and silent at every...
0
by: a_rajanikanth | last post by:
Hi, The following is the trigger which is failing when executing. Can you please tell me the reason why it is failing ? Trigger got created but throwing exception. CREATE TRIGGER TOBJ_U...
3
by: noon | last post by:
I'm runing an xmlHttpRequest to get the site's source code and then applying the regex xhr.responseText.split(/<body*>((?:.|\n)*)<\/body>/i) Works for google.com. Fails on yahoo.com and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.