System.Runtime.InteropServices.COMException (0x80010108) - c#

I try to find out our machine is connected with private or public network.
So, I have used the below code in C# to identify the connected networks name.
IEnumerable<INetwork> = NetworkListManager.GetNetworks(NLM_ENUM_NETWORK.NLM_ENUM_NETWORK_CONNECTED).Cast<INetwork>();
But while executing this code I am getting below exception
System.Runtime.InteropServices.COMException (0x80010108): The object invoked has disconnected from its clients
Why am I getting this exception and how do I resolve this?

Related

MSMQ Read message not working when trying to read from a server which is in WorkGroup

I have private queue created with Anonymous, Everyone, NetworkService full control on a server which is in workgroup mode. I can send a message using .net stub without any issue where as it throws exception while receiving the message. I tried to read the message using
Message.Receive() and Message.ReceiveByID() both throws exception. I tried to add the registry key as told in below link but it did not work
https://blogs.msdn.microsoft.com/johnbreakwell/2007/01/15/msmq-3-0-too-secure-for-you/
MessageQueue messageQueue = new MessageQueue(queueFormatPath);
var message = messageQueue.Receive();
MyMessageQueue.ReceiveById(e.Message.Id);
exception:
You're performing RPC communication so there are several areas to check, in addition to the one you've already found.
https://blogs.msdn.microsoft.com/johnbreakwell/2010/03/24/understanding-how-msmq-security-blocks-rpc-traffic/
https://blogs.msdn.microsoft.com/johnbreakwell/2009/05/17/failing-to-read-from-remote-msmq-queues/
https://blogs.msdn.microsoft.com/johnbreakwell/2008/07/10/getting-msmq-messages-out-of-windows-server-2008-remotely/

Working with Microsoft.Web.Administration on a remote server in a different domain

I the following piece of code, and it works perfectly when it is run on a machine located in the same domain as the one in which is the remote server is.
However, if I run the same code on a machine which can reach the remote server, but is not in the same domain, then I get the following exception:
UnauthorizedAccessException
Retrieving the COM class factory for remote component with CLSID
{2B72133B-3F5B-4602-8952-803546CE3344} from machine [***SERVER_HOSTNAME***] failed
due to the following error: 80070005 [***SERVER_HOSTNAME***].
The exception is thrown by the call to GetWebConfiguration
It seems it's a question of my current credentials not being known on the remote server.
Question: How can I open a remote connection with custom credentials that are known remotely?
Code:
var serverManager = ServerManager.OpenRemote(serverName);
Configuration config = serverManager.GetWebConfiguration(locationPath);
ConfigurationSection accessSection = config.GetSection("system.webServer/security/access");

SocketException connecting to SFTP server: name is valid, but no data of the requested type was found

I am trying to connect my sftp server using SharpSsh library, but I'm getting following error:
System.Net.Sockets.SocketException (0x80004005):
The requested name is valid, but no data of the requested type was found
I am using following code for connection
Tamir.SharpSsh.Sftp sftp = new Tamir.SharpSsh.Sftp("ftp.simptr.us", "username", "password");
Why is this exception being thrown?
This error message is associated with the Winsock WSANO_DATA error code. It means, there is some problem with DNS record of the domain name you are trying to connect to.
See also
https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2#WSANO_DATA
It is unlikely this is related to the SharpSsh library.
Try to telnet to verify, you should get the same error:
telnet ftp.simptr.us 22

Wince Socket exception on asynchronous HTTP request

I am writing a WinCE app in C# that makes an HTTP POST to an APACHE server residing on my network. Because of some network issues (I am guessing), I get the following exception in the managed code
System.Net.Sockets.SocketException occurred
Message="A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond"
ErrorCode=10060
NativeErrorCode=10060
StackTrace:
at System.Net.Sockets.Socket.ConnectNoCheck(EndPoint remoteEP)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at System.Net.Connection.doConnect(IPEndPoint ep)
at System.Net.Connection.connect(Object ignored)
at System.Threading.ThreadPool.WorkItem.doWork(Object o)
at System.Threading.Timer.ring()
This exception isn't always thrown, but when it is thrown, my app fails to connect to the server AT ALL. Repeated connection attempts don't help in reconnecting either. The only thing that helps is closing and re-deploying the app.
I can't catch the exception because its inside of managed code. Is there any way to circumvent this and close all socket connections to my server and re-initialize them? Is there something I am doing wrong?
The exception message looks a bit misleading ("connection attempt failed because the connected party") but I think it means your hardware is communicating with the server, but the server is not accepting the connection on the TCP level.
A problem I could think of is "hanging" connections, causing the server to reach the maximum number of concurrent connections and to stop accepting new ones.
Although it's just a guess, you might want to check the apache log if you can to see if you can find out if the server reports anything, and perhaps try restarting apache as soon as the problem occurs again. If that helps, you still need to find the cause of course.

UdpClient Constructor Throwing SocketException

I'm experiencing an exception upon construction of a UdpClient object, specifying the IPv4 family. This is only occuring on one Windows 7 64-bit machine, other machines with the same OS are working fine.
The precise exception is:
System.Net.Sockets.SocketException (0x80004005): An invalid argument was supplied
at System.Net.Sockets.Socket..ctor(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
at System.Net.Sockets.UdpClient.createClientSocket()
SocketException.ErrorCode is WSAEINVAL 10022, InvalidArgument.
The code that's throwing this exception:
this.udpClient = new UdpClient(AddressFamily.InterNetwork);
Can anyone explain what this exception is telling me? How can IPv4 be an invalid argument for a new UDP client?
UPDATE: This is only occurring when running the application from a network drive. Running it locally does not cause this exception.
The docs advise you to check SocketException::ErrorCode in this instance. What's the value of that? Should be instructive. The Family param is fine, I would think, or you would get ArgumentException.
If you receive a SocketException, use
SocketException::ErrorCode to obtain
the specific error code. Once you have
obtained this code, you can refer to
the Windows Sockets version 2 API
error code documentation in MSDN for a
detailed description of the error.
0x80004005 is an access denied, you do not have rights to create a socket, maybe your firewall?
Or your socket is in use, have you killed the program without terminating the socket?

Categories