MailKit - SmtpClient Connect method freezes - c#

I'm developing a Xamarin android app where at some point (after a successful transaction) the app must send an information email to the customer. The whole process of creating the MimeMessage instance as well as the actual sending of it is done through a task. The message (which most of the time contains linked images) is created flawlessly but as soon as I call a method to actually send it the execution freezes at that call and the whole task remains active but frozen at that point.
Here's my SendMail method which, beside of the MimeMessage parameter, receives a MailAccount class with information about the smtp machine, port and sender account. As soon as a call is made to the Connect method of the MailKit's SmtpClient instance I'm having the "frozen" behavior I described. I tried the whole thing many times - not even once the code continued beyond that line.
private static int SendMail(MailAccount account, MimeMessage message)
{
using (var client = new SmtpClient())
{
try
{
client.Connect(account.Server, account.Port, false);
}
catch (SmtpCommandException)
{
return -1;
}
catch (SmtpProtocolException)
{
return -2;
}
client.AuthenticationMechanisms.Remove("XOAUTH2");
if (client.Capabilities.HasFlag(SmtpCapabilities.Authentication))
{
try
{
client.Authenticate(account.User, Decrypt(account.Pass));
}
catch (AuthenticationException)
{
return -3;
}
catch (SmtpCommandException)
{
return -1;
}
catch (SmtpProtocolException)
{
return -2;
}
}
int status = 1; //assume success
try
{
client.Send(message);
}
catch (SmtpCommandException ex)
{
switch (ex.ErrorCode)
{
case SmtpErrorCode.MessageNotAccepted:
status = -6;
break;
case SmtpErrorCode.SenderNotAccepted:
status = -5;
break;
case SmtpErrorCode.RecipientNotAccepted:
status = -4;
break;
default:
status = -7;
break;
}
}
client.Disconnect(true);
return status;
}
}

In general, a hang while calling client.Connect suggests that the host or port that you are trying to connect with is not available. Check that the host and port are correct.
If they are correct, make sure that you are using the latest version of MailKit as some older versions used Socket.BeginConnect (string, int ...) which, on IPv6-enabled OS's, would sometimes try to use IPv4 over IPv6 and hang in some situations (such as when a virus scanner like Avast was used).
Newer versions of MailKit (>= 2.1.4 and pre-2.0 versions) do a DNS lookup of the remote host and manually specify the correct address family to use when instantiating the Socket (IPv4 vs IPv6) so as to avoid this problem.
It's also possible that the hang is caused by SSL/TLS certificate revocation checks with an unresponsive Certificate Authority. You can disable certificate revocation checks using the following code snippet:
client.CheckCertificateRevocation = false;
Just make sure to set that property before making the call to Connect.
It may be worth testing access to your SMTP server by creating a new Console application in Visual Studio and pasting in the following code and checking that it works:
using System;
using System.Threading;
using System.Threading.Tasks;
using MailKit;
using MailKit.Net.Smtp;
namespace ConsoleApp {
public class Program
{
static void Main (string[] args)
{
using (var client = new SmtpClient (new ProtocolLogger ("smtp.log"))) {
using (var cts = new CancellationTokenSource (60000)) {
try {
client.Connect ("your-host.com", 25, false, cts.Token);
client.Disconnect (true);
} catch (Exception ex) {
Console.WriteLine ("Error connecting: {0}", ex.Message);
Console.WriteLine (ex.StackTrace);
}
}
}
}
}
}
It would also be interesting to know if your Android app has problems connecting to smtp.gmail.com on port 465 (useSsl = true).

Related

how to close the Client Connection and return the Call in NETMQ?

I am just Started Using NETMQ REQ/RES pattern to send and receive the request response from both ends. Client is from IIS and server is from windows service. My question is when i had stopped the service and tried a client request. The client went to infinite LOOP and doesnt return.
Server Code
using (var server = new ResponseSocket())
{
server.Bind("tcp://10.150.0.242:5556");
while (true)
{
try
{
// using (var client = ctx.CreateRequestSocket())
{
string fromClientMessage = server.ReceiveString();
string result = DigitalSignInitialization(fromClientMessage);
server.Send(result);
Console.WriteLine("From Client: {0}", fromClientMessage);
}
}
catch(Exception Ex) { server.Send("Failure"); }
}
}
Client Code
using (NetMQContext ctx = NetMQContext.Create())
{
using (var client = ctx.CreateRequestSocket())
{
//try
// {
//client.Connect("tcp://10.150.0.242:5556");
client.Connect(strNCODE_ADDRESS);
client.Send(json);
fromServerMessage = client.ReceiveString(new TimeSpan (0, 0, 0, 30));
if(fromServerMessage != "Success")
{
fromServerMessage="Failure";
return "<RESULT><DIGITAL_SIGNATURE>DIgital Signature Failed</DIGITAL_SIGNATURE></RESULT>";
}
}
}
Code cant able to return .
Please help me thanks in advance
This is normal behavior. 0MQ sockets does not fail if other endpoint disconnects. Instead socket Send method will await until server became available. If it is not desired behavior you should either use dontWait argument of the Send method or redesign entire approach in polling data from server.

HoloLens unable to send or receive data via BT and TCP

I am working on HoloLens (Unity-UWP) and trying to make a connection with PC (UWP) or Android phone work (Xamarin). So far I tried client and host with both Bluetooth and TCP (even two versions with different libraries) on Android and UWP. I kept the code entirely separated from user interface, so that it is easier to use, to understand and modular. An Action<string> is used to output results (error logs and sent messages).
Everything that is not on the HoloLens works fine (even though it's exactly the same code). It worked from PC (UWP) to Android with client and host switched. But it doesn't even work between HoloLens and PC (UWP). The behavior ranged from crashes (mostly for Bluetooth) to instant disconnection. The last tests resulted in disconnection once bytes are about to be received. It could even read the first 4 bytes (uint for the length of the following UTF-8 message), but then it was disconnected. The other devices seemed to work fine.
What I know: Capabilities are set, the code works, the issue is likely something that is common for everything that has to do with networking and HoloLens.
So the question is, is Unity or HoloLens incompatible with something I am using? What I used which is worth mentioning: StreamSocket, BinaryWriter, BinaryReader, Task (async, await). Or is HoloLens actively blocking communication with applications on other devices? I know it can connect to devices with Bluetooth and that it can connect via TCP, and it looks like people succeed to get it to work. Are there known issues? Or is there something with Unity that causes this - a bad setting maybe? Do I have to use async methods or only sync? Are there incompatibility issues with Tasks/Threads and Unity? Is this possibly the issue (inability to consent to permissions)?
Another thing to note is that I cannot ping HoloLens via its IP by using the cmd, even though the IP is correct.
I'd appreciate any advice, answer or guess. I can provide more information if requested (see also the comments below). I would suggest to focus on the TCP connection as it seemed to be working better and appears to be more "basic." Here is the code:
using System;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Windows.Networking;
using Windows.Networking.Sockets;
#region Common
public abstract class TcpCore
{
protected StreamSocket Socket;
protected BinaryWriter BWriter;
protected BinaryReader BReader;
protected Task ReadingTask;
public bool DetailedInfos { get; set; } = false;
public bool Listening { get; protected set; }
public ActionSingle<string> MessageOutput { get; protected set; } = new ActionSingle<string> (); // Used for message and debug output. They wrap an Action and allow safer use.
public ActionSingle<string> LogOutput { get; protected set; } = new ActionSingle<string> ();
protected const string USED_PORT = "1337";
protected readonly Encoding USED_ENCODING = Encoding.UTF8;
public abstract void Disconnect ();
protected void StartCommunication ()
{
Stream streamOut = Socket.OutputStream.AsStreamForWrite ();
Stream streamIn = Socket.InputStream.AsStreamForRead ();
BWriter = new BinaryWriter (streamOut); //{ AutoFlush = true };
BReader = new BinaryReader (streamIn);
LogOutput.Trigger ("Connection established.");
ReadingTask = new Task (() => StartReading ());
ReadingTask.Start ();
}
public void SendMessage (string message)
{
// There's no need to send a zero length message.
if (string.IsNullOrEmpty (message)) return;
// Make sure that the connection is still up and there is a message to send.
if (Socket == null || BWriter == null) { LogOutput.Trigger ("Cannot send message: No clients connected."); return; }
uint length = (uint) message.Length;
byte[] countBuffer = BitConverter.GetBytes (length);
byte[] buffer = USED_ENCODING.GetBytes (message);
if (DetailedInfos) LogOutput.Trigger ("Sending: " + message);
BWriter.Write (countBuffer);
BWriter.Write (buffer);
BWriter.Flush ();
}
protected void StartReading ()
{
if (DetailedInfos) LogOutput.Trigger ("Starting to listen for input.");
Listening = true;
while (Listening)
{
try
{
if (DetailedInfos) LogOutput.Trigger ("Starting a listen iteration.");
// Based on the protocol we've defined, the first uint is the size of the message. [UInt (4)] + [Message (1*n)] - The UInt describes the length of the message (=n).
uint length = BReader.ReadUInt32 ();
if (DetailedInfos) LogOutput.Trigger ("ReadLength: " + length.ToString ());
MessageOutput.Trigger ("A");
byte[] messageBuffer = BReader.ReadBytes ((int) length);
MessageOutput.Trigger ("B");
string message = USED_ENCODING.GetString (messageBuffer);
MessageOutput.Trigger ("Received Message: " + message);
}
catch (Exception e)
{
// If this is an unknown status it means that the error is fatal and retry will likely fail.
if (SocketError.GetStatus (e.HResult) == SocketErrorStatus.Unknown)
{
// Seems to occur on disconnects. Let's not throw().
Listening = false;
Disconnect ();
LogOutput.Trigger ("Unknown error occurred: " + e.Message);
break;
}
else
{
Listening = false;
Disconnect ();
break;
}
}
}
LogOutput.Trigger ("Stopped to listen for input.");
}
}
#endregion
#region Client
public class GTcpClient : TcpCore
{
public async void Connect (string target, string port = USED_PORT) // Target is IP address.
{
try
{
Socket = new StreamSocket ();
HostName serverHost = new HostName (target);
await Socket.ConnectAsync (serverHost, port);
LogOutput.Trigger ("Connection successful to: " + target + ":" + port);
StartCommunication ();
}
catch (Exception e)
{
LogOutput.Trigger ("Connection error: " + e.Message);
}
}
public override void Disconnect ()
{
Listening = false;
if (BWriter != null) { BWriter.Dispose (); BWriter.Dispose (); BWriter = null; }
if (BReader != null) { BReader.Dispose (); BReader.Dispose (); BReader = null; }
if (Socket != null) { Socket.Dispose (); Socket = null; }
if (ReadingTask != null) { ReadingTask = null; }
}
}
#endregion
#region Server
public class GTcpServer : TcpCore
{
private StreamSocketListener socketListener;
public bool AutoResponse { get; set; } = false;
public async void StartServer ()
{
try
{
//Create a StreamSocketListener to start listening for TCP connections.
socketListener = new StreamSocketListener ();
//Hook up an event handler to call when connections are received.
socketListener.ConnectionReceived += ConnectionReceived;
//Start listening for incoming TCP connections on the specified port. You can specify any port that's not currently in use.
await socketListener.BindServiceNameAsync (USED_PORT);
}
catch (Exception e)
{
LogOutput.Trigger ("Connection error: " + e.Message);
}
}
private void ConnectionReceived (StreamSocketListener listener, StreamSocketListenerConnectionReceivedEventArgs args)
{
try
{
listener.Dispose ();
Socket = args.Socket;
if (DetailedInfos) LogOutput.Trigger ("Connection received from: " + Socket.Information.RemoteAddress + ":" + Socket.Information.RemotePort);
StartCommunication ();
}
catch (Exception e)
{
LogOutput.Trigger ("Connection Received error: " + e.Message);
}
}
public override void Disconnect ()
{
Listening = false;
if (socketListener != null) { socketListener.Dispose (); socketListener = null; }
if (BWriter != null) { BWriter.Dispose (); BWriter.Dispose (); BWriter = null; }
if (BReader != null) { BReader.Dispose (); BReader.Dispose (); BReader = null; }
if (Socket != null) { Socket.Dispose (); Socket = null; }
if (ReadingTask != null) { ReadingTask = null; }
}
}
#endregion
Coincidentially, I just implemented a BT connection between HoloLens and an UWP app. I followed the sample at https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/BluetoothRfcommChat.
As capabilities, I set "Bluetooth" (of course), "Internet (Client & Server)" and "Private Networks (Client & Server)". The steps on the server side then are:
Create an RfcommServiceProvider for your own or an existing (eg OBEX object push) service ID.
Create a StreamSocketListener and wire its ConnectionReceived Event.
Bind the service Name on the listener: listener.BindServiceNameAsync(provider.ServiceId.AsString(), SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication);
If you have a custom service ID, set its name along with other attributes you may want to configure. See the sample linked above for this. I think, this is mostly optional.
Start advertising the BT service: provider.StartAdvertising(listener, true);
Once a client connects, there is a StreamSocket in the StreamSocketListenerConnectionReceivedEventArgs that you can use to create a DataReader and DataWriter on like on any other stream. If you only want to allow one client, you can also stop advertising now.
On the client side, you would:
Show the DevicePicker and let the user select the peer device. Do not forget setting a filter like picker.Filter.SupportedDeviceSelectors.Add(BluetoothDevice.GetDeviceSelectorFromPairingState(true)); You can also allow unpaired devices, but you need to call PairAsync before you can continue in step 2. Also, I think there is no way to circumvent the user consent dialogue in this case, so I would recommend pairing before. To be honest, I did not check whether the unpaired stuff works on HoloLens.
You get a DeviceInformation instance from the picker, which you can use to obtain a BT device like await BluetoothDevice.FromIdAsync(info.Id);
Get the services from the device like device.GetRfcommServicesAsync(BluetoothCacheMode.Uncached); and select the one you are interested in. Note that I found that the built-in filtering did not behave as expected, so I just enumerated the result and compared the UUIDs manually. I believe that the UWP implementation performs a case-sensitive string comparison at some point, which might lead to the requested service not showing up although it is there.
Once you found your service, which I will call s from now on, create a StreamSocket and connect using socket.ConnectAsync(s.ConnectionHostName, s.ConnectionServiceName, SocketProtectionLevel.PlainSocket);
Again, you can not create the stream readers and writers like on the server side.
The answer is Threading.
For whoever may have similar issues, I found the solution. It was due to Unity itself, not HoloLens specifically. My issue was that I wrote my code separately in an own class instead of commingle it with UI code, which would have made it 1. unreadable and 2. not modular to use. So I tried a better coding approach (in my opinion). Everybody could download it and easily integrate it and have basic code for text messaging. While this was no issue for Xamarin and UWP, it was an issue for Unity itself (and there the Unity-UWP solution as well).
The receiving end of Bluetooth and TCP seemed to create an own thread (maybe even something else, but I didn't do it actively), which was unable to write on the main thread in Unity, which solely handles GameObjects (like the output log). Thus I got weird log outputs when I tested it on HoloLens.
I created a new TCP code which works for Unity but not the Unity-UWP solution, using TcpClient/TcpListener, in order to try another version with TCP connection. Luckily when I ran that in the editor it finally pointed on the issue itself: The main thread could not be accessed, which would have written into the UI - the text box for the log output. In order to solve that, I just had to use Unity's Update() method in order to set the text to the output. The variables themselves still could be accessed, but not the GameObjects.

"The handle is invalid" execption recevied while creating the object of MQ Queue Manager

Please find the below code:
MQEnvironment.Hostname = HostName;
MQEnvironment.Channel = Channel;
if (!string.IsNullOrEmpty(SSLKeyRepository))
{
MQEnvironment.SSLCipherSpec = SSLCipherSpec;
MQEnvironment.SSLKeyRepository = SSLKeyRepository;
}
if (Port > 0)
MQEnvironment.Port = Port;
try
{
MQManager = new MQQueueManager(QueueManager);
try
{
MQRequestQueue = MQManager.AccessQueue(QueueNameGet, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);
MQResponseQueue = MQManager.AccessQueue(QueueNameGet, MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING);
return true;
}
catch (IBM.WMQ.MQException exIBM)
{
CloseConnection();
ErrorCode = exIBM.Reason;
ErrorDescription = exIBM.Message;
}
}
catch (IBM.WMQ.MQException exIBM)
{
CloseConnection();
ErrorCode = exIBM.Reason;
ErrorDescription = exIBM.Message;
}
catch (Exception ex)
{
CloseConnection();
ErrorCode = Constants.SYSTEMEXCEPTION;
ErrorDescription = ex.Message;
}
return false;
Issue: I am not getting the issue when I run it for single or 2-3 times. But I get the issue when it runs in a loop for multiple times.
Also, I have tried to run the same piece of code for 10,000 times from the IIS server and it ran successfully.
I am getting the issue only when I have this code on IIS webservice and that webservice is getting called multiple times.
IBM MQ client 7.5.0.0 installed on the IIS server and I am using the dll of the same version.
UPDATE
Error description:
Error Message The handle is invalid
StackTrace at System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolean firstModuleOnly) at System.Diagnostics.Process.get_Modules() at IBM.WMQ.CommonServices.TraceEnvironment() at IBM.WMQ.CommonServices.CreateCommonServices() at IBM.WMQ.CommonServices.TraceEnabled() at IBM.WMQ.MQBase..ctor() at IBM.WMQ.MQManagedObject..ctor()
Thanks for providing the call stack. The issue you mention is very similar to the one fixed here in MQ version 7.5.0.2. As you are at MQ v7.5.0.0, I suggest you to upgrade your MQ client to the latest level, MQ v7.5.0.7 and try.
I have said this many times here and it applies to both Java and .NET, the MQEnvironment class is NOT thread safe. By using it, you are shooting yourself in the foot.
Put the values (channel, hostname & port #) into a HashTable and pass the HashTable to the MQQueueManager class.
Hashtable qMgrHT = new Hashtable();
qMgrHT.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
qMgrHT.Add(MQC.HOST_NAME_PROPERTY, "10.10.10.10");
qMgrHT.Add(MQC.CHANNEL_PROPERTY, "TEST.CHL");
qMgrHT.Add(MQC.PORT_PROPERTY, 1414);
qMgrHT.Add(MQC.USER_ID_PROPERTY, "myUserID");
qMgrHT.Add(MQC.PASSWORD_PROPERTY, "myPwd");
MQQueueManager qMgr = new MQQueueManager(qManager, qMgrHT);
Finally, write your code so that it maintains a connection rather than connecting and disconnecting over and over. Very, VERY bad form.

testing internet connection on a cellular network

I have an application that was written for remote trucks to use on cell service. Before I do anything, I am checking the internet with this class:
using System.Net;
namespace SSS.ServicesConfig.MiscClasses
{
public class VerifyInternetAccess
{
public static bool HasInternet()
{
try
{
using (var client = new WebClient())
using (var stream = client.OpenRead("http://www.google.com"))
{
return true;
}
}
catch
{
return false;
}
}
}
}
In some cases, the light on the external cellular device has a green light as if it has internet. My test class comes back false so it thinks it does not have internet.
The driver can then open up internet explorer, close internet explorer, promptly run my application and it passes the test above.
The users are saying that IE is 'waking up' the internet so that it can transfer.
Doesn't my class do essentially the same thing? If not, how can I 'wake up' the internet connection as IE does?
You didn't state if you're restricted to a certain mobile OS but this works on a normal box.
I try to leverage two features of the System.Net.NetworkInformation namespace.
I start with registering for the NetworkChangedEvent. By calling GetIsNetworkAvailable you get an idea if there is at least one other NIC present that is not the loopback interface.
If there is no connection I try to wake-up the network layer by getting pinging a host.
I use the Dns.GetHostEntry to obtain all IP Adresses known for a host. Next I try to Ping the address one by one.
Be aware that not all hosts allow ICMP traffic which would lead to timeouts in all circumstances. If however in the meantime the network becomes available the NetworkChanged event should have been fired and set the HasConnection to true
public class VerifyInternetAccess
{
private static bool HasConnection = false;
static VerifyInternetAccess()
{
NetworkChange.NetworkAvailabilityChanged += (o, ca) =>
{
HasConnection = ca.IsAvailable;
};
HasConnection = NetworkInterface.GetIsNetworkAvailable();
}
public static bool HasInternet()
{
bool hasEnded = false;
if (!HasConnection)
{
// let's try to wake up...
using (var ping = new Ping())
{
var iphost = Dns.GetHostEntry("www.google.com");
foreach (var addr in iphost.AddressList)
{
var reply = ping.Send(addr);
if (reply.Status == IPStatus.Success)
{
HasConnection = true;
break;
}
}
}
}
return HasConnection;
}
}

debugging sockets and DLL's

First question now answered if you want to skip to the bottom..
I'm developing comms between PDA's on .net 2.0 and our servers. Can't use WCF or I would have.
The comms model is like this:
And fortunately i've found working code form http://aviadezra.blogspot.com/2008/07/code-sample-net-sockets-multiple.html - that's where the image above comes from too.
The example app has messages from each client being broadcast to all other clients. I would like to be able to send a message from one client to another specific client. To do this i've modified the client app to have a from-ID and To-ID which is sent as part of the message.
Note: At this stage i'm doing proof of concept - i'll work on things like message headers (lengths, versions etc later).
From the project each client connection is handled by:
private void OnClientConnection(IAsyncResult asyn)
{
if (m_Closed)
{
return;
}
try
{
Socket clientSocket = m_socket.EndAccept(asyn);
RaiseClientConnected(clientSocket);
ConnectedClient connectedClient = new ConnectedClient(clientSocket);
connectedClient.MessageRecived += OnMessageRecived;
connectedClient.Disconnected += OnClientDisconnection;
connectedClient.StartListen();
long key = clientSocket.Handle.ToInt64();
if (m_clients.ContainsKey(key))
{
Debug.Fail(string.Format(
"Client with handle key '{0}' already exist!", key));
}
m_clients[key] = connectedClient;
// create the call back for any client connections...
m_socket.BeginAccept(new AsyncCallback(OnClientConnection), null);
}
catch (ObjectDisposedException odex)
{
Debug.Fail(odex.ToString(),
"OnClientConnection: Socket has been closed");
}
catch (Exception sex)
{
Debug.Fail(sex.ToString(),
"OnClientConnection: Socket failed");
}
}
Class connectedClient holds the socket for that client.
When I send a message from client I do a lookup to see if that's in my list of sockets:
if (ListIDSocket.ContainsKey(ToID))
{
PublishMessage(listLog, "ToID Found");
SendAll = false;
}
ListIDSocket is:
private Dictionary<string, Socket> ListIDSocket = new Dictionary<string, Socket>();
Then..
if (SendAll)
m_ServerTerminal.DistributeMessage(buffer);
else
m_ServerTerminal.SendToSocket(ToID, socket, buffer);
So if message is to anyone, call DistributeMessage; if to single user, call SendToSocket.
The code in m_ServerTerminal is:
public void DistributeMessage(byte[] buffer)
{
try
{
foreach (ConnectedClient connectedClient in m_clients.Values)
{
connectedClient.Send(buffer);
}
}
catch (SocketException se)
{
Debug.Fail(se.ToString(), string.Format(
"Buffer could not be sent"));
}
}
public void SendToSocket(string ToID, Socket DestSocket, byte[] buffer)
{
DistributeMessage(buffer); // This line works
ConnectedClient ToClient;
long keyval = DestSocket.Handle.ToInt64();
if (m_clients.ContainsKey(keyval))
{
ToClient = (ConnectedClient)m_clients[keyval];
try
{
ToClient.Send(buffer); // Nothing is received
}
catch (SocketException se)
{
Debug.Fail(se.ToString(), se.Message);
}
// DistributeMessage(buffer); // This code here doesn't work
}
}
DistributeMessage works fine. For debugging purposes i've included a call to DistributeMessage in my SendToSocket and this works if it's at the top.
If I move it down after I try writing to to the socket, it doesn't.
I don't get an exception on either way.
As it stands now, client gets one message when it should get two - one from DistributeMessage and one from SendToSocket.
The code for connectedclient.Send is:
public void Send(byte[] buffer)
{
if (m_clientSocket == null)
{
throw new Exception("Can't send data. ConnectedClient is Closed!");
}
m_clientSocket.Send(buffer);
}
Questions:
I can't see anything that i'm doing substantially different with my new code to existing but the socket isn't being written to. Can anyone spot anything obvious ? Is this something to do with sockets, handles and references to them ?
EDIT: Bug found, whilst I was looking up to see if the socket existed, I was passing in the socket of the sender not receiver. I'll fix this.
Debugging DLL's I'd still like to know about though..
Secondly, the project is setup with the socket handling in it's own DLL called Communication.Sockets.Core. I've never built DLL's before and i'm having trouble debugging. Can't use normal debug points in code - I resorted to creating a form to display instead.
Any tips on how to debug DLL's ?
I'm still fairly new to C#; just on 1 year.
TIA,
Andrew

Categories

Resources