Can't send email on Ubuntu server - c#

I'm having an issue with my little app. App is able to send an email when it's running on Windows, but not when it's on Ubuntu 15.10.
C# code:
public bool sendMail(string subject, string msg, string[] emailTo)
{
MailMessage mail = new MailMessage();
SmtpClient client = new SmtpClient();
MailAddress from = new MailAddress("noreply#someserver.com", "Someserver - No Reply");
// client settings
client.EnableSsl = true;
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("noreply#someserver.com", "someserverPassword");
client.Host = "smtp.office365.com";
//main settings
mail.IsBodyHtml = true;
mail.Body = msg + footer;
mail.Subject = subject;
mail.From = from;
foreach (string mailTo in emailTo)
{
mail.To.Add(mailTo);
}
client.Send(mail);
return true;
}
and here is the error i get:
Unhandled Exception:
System.Net.Mail.SmtpException: Message could not be sent. ---> System.IO.IOException: The authentication or decryption has failed. ---> System.IO.IOException: The authentication or decryption has failed. ---> System.InvalidOperationException: SSL authentication error: RemoteCertificateNotAvailable
at Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (IAsyncResult asyncResult) <0x41d12100 + 0x000ff> in <filename unknown>:0
at Mono.Security.Protocol.Tls.SslClientStream.SafeEndReceiveRecord (IAsyncResult ar, Boolean ignoreEmpty) <0x41d12040 + 0x0002b> in <filename unknown>:0
at Mono.Security.Protocol.Tls.SslClientStream.NegotiateAsyncWorker (IAsyncResult result) <0x41cf64c0 + 0x00213> in <filename unknown>:0
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslClientStream.EndNegotiateHandshake (IAsyncResult result) <0x41d12d70 + 0x000bf> in <filename unknown>:0
at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) <0x41d12b10 + 0x0007f> in <filename unknown>:0
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslStreamBase.EndRead (IAsyncResult asyncResult) <0x41cf4090 + 0x00153> in <filename unknown>:0
at System.Net.Security.SslStream.EndAuthenticateAsClient (IAsyncResult asyncResult) <0x41cf3ec0 + 0x0003e> in <filename unknown>:0
at System.Net.Security.SslStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation) <0x41ced140 + 0x00055> in <filename unknown>:0
at System.Net.Mail.SmtpClient.InitiateSecureConnection () <0x41cecc70 + 0x000df> in <filename unknown>:0
at System.Net.Mail.SmtpClient.SendCore (System.Net.Mail.MailMessage message) <0x41cea260 + 0x0020f> in <filename unknown>:0
at System.Net.Mail.SmtpClient.SendInternal (System.Net.Mail.MailMessage message) <0x41ce3120 + 0x00207> in <filename unknown>:0
at System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message) <0x41ce2d90 + 0x00113> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message) <0x41ce2d90 + 0x001c7> in <filename unknown>:0
at Chillblast_ERP.MailingSystem.sendMail (System.String subject, System.String msg, System.String[] emailTo) <0x41cc8c80 + 0x00273> in <filename unknown>:0
at erptesting.Program.Main (System.String[] args) <0x41c72800 + 0x001f3> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.Net.Mail.SmtpException: Message could not be sent. ---> System.IO.IOException: The authentication or decryption has failed. ---> System.IO.IOException: The authentication or decryption has failed. ---> System.InvalidOperationException: SSL authentication error: RemoteCertificateNotAvailable
at Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (IAsyncResult asyncResult) <0x41d12100 + 0x000ff> in <filename unknown>:0
at Mono.Security.Protocol.Tls.SslClientStream.SafeEndReceiveRecord (IAsyncResult ar, Boolean ignoreEmpty) <0x41d12040 + 0x0002b> in <filename unknown>:0
at Mono.Security.Protocol.Tls.SslClientStream.NegotiateAsyncWorker (IAsyncResult result) <0x41cf64c0 + 0x00213> in <filename unknown>:0
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslClientStream.EndNegotiateHandshake (IAsyncResult result) <0x41d12d70 + 0x000bf> in <filename unknown>:0
at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) <0x41d12b10 + 0x0007f> in <filename unknown>:0
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslStreamBase.EndRead (IAsyncResult asyncResult) <0x41cf4090 + 0x00153> in <filename unknown>:0
at System.Net.Security.SslStream.EndAuthenticateAsClient (IAsyncResult asyncResult) <0x41cf3ec0 + 0x0003e> in <filename unknown>:0
at System.Net.Security.SslStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation) <0x41ced140 + 0x00055> in <filename unknown>:0
at System.Net.Mail.SmtpClient.InitiateSecureConnection () <0x41cecc70 + 0x000df> in <filename unknown>:0
at System.Net.Mail.SmtpClient.SendCore (System.Net.Mail.MailMessage message) <0x41cea260 + 0x0020f> in <filename unknown>:0
at System.Net.Mail.SmtpClient.SendInternal (System.Net.Mail.MailMessage message) <0x41ce3120 + 0x00207> in <filename unknown>:0
at System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message) <0x41ce2d90 + 0x00113> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message) <0x41ce2d90 + 0x001c7> in <filename unknown>:0
at Chillblast_ERP.MailingSystem.sendMail (System.String subject, System.String msg, System.String[] emailTo) <0x41cc8c80 + 0x00273> in <filename unknown>:0
at erptesting.Program.Main (System.String[] args) <0x41c72800 + 0x001f3> in <filename unknown>:0

Found necessary certificates:
sudo certmgr -ssl -m https://go.microsoft.com
sudo certmgr -ssl -m https://nugetgallery.blob.core.windows.net
sudo certmgr -ssl -m https://nuget.org
mozroots –-import -–sync

Related

PING ERROR C# - Parameter name: hostName

I need help.. I checking for if user of PC connected to Internet..
It works for me.. and for many people.. But for someone no
and it's writing this into output_log.txt
ERROR:
ArgumentNullException: Argument cannot be null.
Parameter name: hostName
at System.Net.Dns.GetHostByName (System.String hostName) [0x00000] in <filename unknown>:0
at System.Net.NetworkInformation.Ping.GetNonLoopbackIP () [0x00000] in <filename unknown>:0
at System.Net.NetworkInformation.Ping.SendPrivileged (System.Net.IPAddress address, Int32 timeout, System.Byte[] buffer, System.Net.NetworkInformation.PingOptions options) [0x00000] in <filename unknown>:0
at System.Net.NetworkInformation.Ping.Send (System.Net.IPAddress address, Int32 timeout, System.Byte[] buffer, System.Net.NetworkInformation.PingOptions options) [0x00000] in <filename unknown>:0
at System.Net.NetworkInformation.Ping.Send (System.String hostNameOrAddress, Int32 timeout, System.Byte[] buffer, System.Net.NetworkInformation.PingOptions options) [0x00000] in <filename unknown>:0
at System.Net.NetworkInformation.Ping.Send (System.String hostNameOrAddress, Int32 timeout, System.Byte[] buffer) [0x00000] in <filename unknown>:0
at System.Net.NetworkInformation.Ping.Send (System.String hostNameOrAddress, Int32 timeout) [0x00000] in <filename unknown>:0
at System.Net.NetworkInformation.Ping.Send (System.String hostNameOrAddress) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Net.NetworkInformation.Ping:Send (string)
at Internet.Connection.Check () [0x00000] in <filename unknown>:0
at MyGame.Load.Loader.StartLoading () [0x00000] in <filename unknown>:0
at Loader+<Start>c__IteratorA.MoveNext () [0x00000] in <filename unknown>:0
(Filename: Line: -1)
Code:
namespace Internet
{
using System;
using System.Net.NetworkInformation;
using UnityEngine;
public class Connection
{
public static void Check()
{
System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
if (ping.Send("89.203.249.74").Status != IPStatus.Success)
{
Debug.Log("NO INTERNET CONNECTION");
Application.Quit();
}
}
}
}
So Please help

Strange UriFormatException when using mono

I'm currently working on a project which has to run on mono.
Normally, everything works just fine. But when I try to run it in a separate screen on my ubuntu 14.04 server, it won't start after crashing once. The error that occurs is the following:
System.UriFormatException: Invalid URI: The URI scheme is not valid.
at System.Uri.Parse (UriKind kind, System.String uriString) <0x40141e70 + 0x000b3> in <filename unknown>:0
at System.Uri.ParseUri (UriKind kind) <0x40141d50 + 0x00023> in <filename unknown>:0
at System.Uri..ctor (System.String uriString, Boolean dontEscape) <0x401459e0 + 0x001b7> in <filename unknown>:0
at System.Uri..ctor (System.String uriString) <0x401459b0 + 0x00013> in <filename unknown>:0
at System.Xml.XmlResolver.ResolveUri (System.Uri baseUri, System.String relativeUri) <0x401403f0 + 0x0010b> in <filename unknown>:0
at System.Xml.XmlUrlResolver.ResolveUri (System.Uri baseUri, System.String relativeUri) <0x401403c0 + 0x00017> in <filename unknown>:0
at System.Xml.XmlTextReaderImpl..ctor (System.String uriStr, System.Xml.XmlReaderSettings settings, System.Xml.XmlParserContext context, System.Xml.XmlResolver uriResolver) <0x4013e610 + 0x00060> in <filename unknown>:0
at System.Xml.XmlReaderSettings.CreateReader (System.String inputUri, System.Xml.XmlParserContext inputContext) <0x4013e4a0 + 0x0008f> in <filename unknown>:0
at System.Xml.XmlReader.Create (System.String inputUri, System.Xml.XmlReaderSettings settings, System.Xml.XmlParserContext inputContext) <0x4013e420 + 0x0005f> in <filename unknown>:0
at System.Xml.XmlReader.Create (System.String inputUri, System.Xml.XmlReaderSettings settings) <0x4013e3c0 + 0x00013> in <filename unknown>:0
at Project.Server.Settings..ctor () <0x4013c1f0 + 0x0006f> in <filename unknown>:0
This seems very strange to me, as the code that produces the error is the following:
private XDocument configFile;
public Settings()
{
var readerSettings = new XmlReaderSettings { CheckCharacters = false };
using (var reader = XmlReader.Create("config.xml", readerSettings))
{
configFile = XDocument.Load(reader);
}
}
As mentioned before, everything works just fine when run the first time. But after it crashed once, it won't start and crashes with this error. More strangely, I can fix the problem by terminating the screen and making a new one and running the exact same command.
Has anybody encountered something like this before? Is this something that can be prevented?

How to I catch SSL exceptions in a Mono HTTPListener server?

I'm trying to add HTTPS support to my simple Mono HTTP server. It works perfectly most of the time, but the application crashes when an SSL exception occurs, such as the client canceling the handshake. Obviously something like that shouldn't completely crash it, so I need to catch that exception somehow.
Code:
static void Main(string[] args)
{
try
{
var listener = new HttpListener();
string prefix = "https://*:8443/";
listener.Prefixes.Add(prefix);
Console.WriteLine("Starting HTTP server at " + prefix);
listener.Start();
while (true)
{
try
{
var context = listener.GetContext();
Console.WriteLine(context.Request.Url);
}
catch (Exception e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Exception processing request: " + e);
Console.ResetColor();
}
}
}
catch (Exception e)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Exception caught! " + e);
}
}
Here's the log when I get a wonky client trying to connect:
Starting HTTP server at https://*:8443/
Unhandled Exception:
System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: The client stopped the handshake.
at Mono.Security.Protocol.Tls.SslServerStream.EndNegotiateHandshake (IAsyncResult asyncResult) <0x41e581b0 + 0x0022b> in <filename unknown>:0
at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) <0x41e57d20 + 0x00086> in <filename unknown>:0
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslStreamBase.EndRead (IAsyncResult asyncResult) <0x41e50110 + 0x0015f> in <filename unknown>:0
at Mono.Net.Security.Private.LegacySslStream.EndAuthenticateAsServer (IAsyncResult asyncResult) <0x41e50000 + 0x0003e> in <filename unknown>:0
at Mono.Net.Security.Private.LegacySslStream.AuthenticateAsServer (System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, Boolean clientCertificateRequired, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation) <0x41e40990 + 0x00055> in <filename unknown>:0
at System.Net.HttpConnection.Init () <0x41e3e0e0 + 0x0005f> in <filename unknown>:0
at System.Net.HttpConnection..ctor (System.Net.Sockets.Socket sock, System.Net.EndPointListener epl, Boolean secure, System.Security.Cryptography.X509Certificates.X509Certificate cert) <0x41e3b670 + 0x003e7> in <filename unknown>:0
at System.Net.EndPointListener.OnAccept (System.Object sender, System.EventArgs e) <0x41e3b210 + 0x002a7> in <filename unknown>:0
at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted (System.Net.Sockets.SocketAsyncEventArgs e) <0x41e3b1d0 + 0x0002e> in <filename unknown>:0
at System.Net.Sockets.SocketAsyncEventArgs.Complete () <0x41e3b1b0 + 0x00013> in <filename unknown>:0
at System.Net.Sockets.Socket.<AcceptAsyncCallback>m__0 (IAsyncResult ares) <0x41e3aa70 + 0x0037f> in <filename unknown>:0
at System.Net.Sockets.SocketAsyncResult+<Complete>c__AnonStorey0.<>m__0 (System.Object _) <0x41e3a980 + 0x0001d> in <filename unknown>:0
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () <0x7f22cac25460 + 0x0002f> in <filename unknown>:0
at System.Threading.ThreadPoolWorkQueue.Dispatch () <0x7f22cac239e0 + 0x001d6> in <filename unknown>:0
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () <0x7f22cac252e0 + 0x00008> in <filename unknown>:0
Not quite a solution, but I was able to work around the problem by creating a local reverse proxy with nginx, and setting the mono server to only listen on 127.0.0.1
https://www.nginx.com/resources/admin-guide/reverse-proxy/

Google API-change, results in a MONO error: Invalid IL code in System.Net.Http.HttpClientHandler:.ctor (): method body is empty

I had to change the auth system behind the Google Analytics API following the old auth system becoming defunct. As a result of a SO post, my auth file went from:
protected override void Load(ContainerBuilder builder)
{
builder.Register(c =>
{
var service = new AnalyticsService("mrfreeman.com");
service.setUserCredentials("robot#mrfreeman.com", "jellyfish");
return service;
});
builder.RegisterType<AnalyticsNewsletterTrackingSource>().As<INewsletterTrackingSource>();
builder.RegisterType<AnalyticsSearchTrackingSource>().As<ISearchTrackingSource>();
builder.RegisterType<AnalyticsEmailLinkTracker>().As<IEmailLinkTracker>();
}
To:
private const string ServiceAccountEmail = "blabla#developer.gserviceaccount.com";
private static readonly string KeyPath = System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.PrivateBinPath ?? AppDomain.CurrentDomain.BaseDirectory, "Key.p12");
private static readonly X509Certificate2 Certificate = new X509Certificate2(KeyPath, "notasecret", X509KeyStorageFlags.Exportable);
private readonly ServiceAccountCredential _credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(ServiceAccountEmail)
{
Scopes = new[] { "https://www.googleapis.com/auth/analytics" }
}.FromCertificate(Certificate));
protected override void Load(ContainerBuilder builder)
{
builder.Register(c =>
{
_credential.RequestAccessTokenAsync(System.Threading.CancellationToken.None).Wait();
var service = new AnalyticsService("mrfreeman.com");
var requestFactory = new GDataRequestFactory("shazbot2.0");
requestFactory.CustomHeaders.Add(string.Format("Authorization: Bearer {0}", _credential.Token.AccessToken));
service.RequestFactory = requestFactory;
return service;
});
builder.RegisterType<AnalyticsNewsletterTrackingSource>().As<INewsletterTrackingSource>();
builder.RegisterType<AnalyticsSearchTrackingSource>().As<ISearchTrackingSource>();
builder.RegisterType<AnalyticsEmailLinkTracker>().As<IEmailLinkTracker>();
}
Doing all the necessary boiler plate of copying the generated developer email address and P12 key into the project.
The problem is this: It works on Windows but throws problems with the services running on mono and are dependant on the Analytics module. Currently using 4.0.2 version of Mono.
What I've tried:
Using old and new versions of mono - 3.10 and 4.2.0 pre-release to run the service (which is itself built by Visual Studio) and check if exception is produced.
Import System.Net.Http and copy to local (currently not referenced in service) - still produces same exception
At this stage I'm cornered into learning the new Google Analytics API and re-writing everything from scratch as I tried to use the old API but update the Auth API with little luck, but feel this a blunt-instrument type solution.
The stack trace is the same on any version and is:
FATAL Unhandled exception occurred.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidProgramException: Invalid IL code in System.Net.Http.HttpClientHandler:.ctor (): method body is empty.
at Google.Apis.Http.HttpClientFactory.CreateHandler (Google.Apis.Http.CreateHttpClientArgs args) <0x40280100 + 0x0003b> in <filename unknown>:0
at Google.Apis.Http.HttpClientFactory.CreateHttpClient (Google.Apis.Http.CreateHttpClientArgs args) <0x4027ff90 + 0x0002d> in <filename unknown>:0
at Google.Apis.Auth.OAuth2.ServiceAccountCredential..ctor (Google.Apis.Auth.OAuth2.Initializer initializer) <0x4027f6d0 + 0x00438> in <filename unknown>:0
at jellyfish.Analytics.AnalyticsModule..ctor () <0x4027ed00 + 0x00103> in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) <0x7f8257b94780 + 0x0003f> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) <0x7f8257b94780 + 0x00079> in <filename unknown>:0
at System.RuntimeType.CreateInstanceMono (Boolean nonPublic) <0x7f82579c1ec0 + 0x00116> in <filename unknown>:0
at System.RuntimeType.CreateInstanceSlow (Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, System.Threading.StackCrawlMark& stackMark) <0x7f82579c1e70 + 0x00049> in <filename unknown>:0
at System.RuntimeType.CreateInstanceDefaultCtor (Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, System.Threading.StackCrawlMark& stackMark) <0x7f82579c1c10 + 0x0005c> in <filename unknown>:0
at System.Activator.CreateInstance[T] () <0x7f82578dfb70 + 0x0008a> in <filename unknown>:0
at Autofac.ModuleRegistrationExtensions.RegisterModule[TModule] (IModuleRegistrar registrar) <0x40273470 + 0x0004f> in <filename unknown>:0
at Autofac.ModuleRegistrationExtensions.RegisterModule[TModule] (Autofac.ContainerBuilder builder) <0x40273330 + 0x0006b> in <filename unknown>:0
at jellyfish.Cron.Program.BuildContainer (ILog log) <0x402730e0 + 0x0005f> in <filename unknown>:0
at jellyfish.Cron.Program.ExecuteJob (System.Type jobType) <0x4021abe0 + 0x0007b> in <filename unknown>:0
Unknown errno: Protocol error
Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidProgramException: Invalid IL code in System.Net.Http.HttpClientHandler:.ctor (): method body is empty.
at Google.Apis.Http.HttpClientFactory.CreateHandler (Google.Apis.Http.CreateHttpClientArgs args) <0x40280100 + 0x0003b> in <filename unknown>:0
at Google.Apis.Http.HttpClientFactory.CreateHttpClient (Google.Apis.Http.CreateHttpClientArgs args) <0x4027ff90 + 0x0002d> in <filename unknown>:0
at Google.Apis.Auth.OAuth2.ServiceAccountCredential..ctor (Google.Apis.Auth.OAuth2.Initializer initializer) <0x4027f6d0 + 0x00438> in <filename unknown>:0
at jellyfish.Analytics.AnalyticsModule..ctor () <0x4027ed00 + 0x00103> in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) <0x7f8257b94780 + 0x0003f> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) <0x7f8257b94780 + 0x00079> in <filename unknown>:0
at System.RuntimeType.CreateInstanceMono (Boolean nonPublic) <0x7f82579c1ec0 + 0x00116> in <filename unknown>:0
at System.RuntimeType.CreateInstanceSlow (Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, System.Threading.StackCrawlMark& stackMark) <0x7f82579c1e70 + 0x00049> in <filename unknown>:0
at System.RuntimeType.CreateInstanceDefaultCtor (Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, System.Threading.StackCrawlMark& stackMark) <0x7f82579c1c10 + 0x0005c> in <filename unknown>:0
at System.Activator.CreateInstance[T] () <0x7f82578dfb70 + 0x0008a> in <filename unknown>:0
at Autofac.ModuleRegistrationExtensions.RegisterModule[TModule] (IModuleRegistrar registrar) <0x40273470 + 0x0004f> in <filename unknown>:0
at Autofac.ModuleRegistrationExtensions.RegisterModule[TModule] (Autofac.ContainerBuilder builder) <0x40273330 + 0x0006b> in <filename unknown>:0
at jellyfish.Cron.Program.BuildContainer (ILog log) <0x402730e0 + 0x0005f> in <filename unknown>:0
at jellyfish.Cron.Program.ExecuteJob (System.Type jobType) <0x4021abe0 + 0x0007b> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidProgramException: Invalid IL code in System.Net.Http.HttpClientHandler:.ctor (): method body is empty.
at Google.Apis.Http.HttpClientFactory.CreateHandler (Google.Apis.Http.CreateHttpClientArgs args) <0x40280100 + 0x0003b> in <filename unknown>:0
at Google.Apis.Http.HttpClientFactory.CreateHttpClient (Google.Apis.Http.CreateHttpClientArgs args) <0x4027ff90 + 0x0002d> in <filename unknown>:0
at Google.Apis.Auth.OAuth2.ServiceAccountCredential..ctor (Google.Apis.Auth.OAuth2.Initializer initializer) <0x4027f6d0 + 0x00438> in <filename unknown>:0
at jellyfish.Analytics.AnalyticsModule..ctor () <0x4027ed00 + 0x00103> in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) <0x7f8257b94780 + 0x0003f> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) <0x7f8257b94780 + 0x00079> in <filename unknown>:0
at System.RuntimeType.CreateInstanceMono (Boolean nonPublic) <0x7f82579c1ec0 + 0x00116> in <filename unknown>:0
at System.RuntimeType.CreateInstanceSlow (Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, System.Threading.StackCrawlMark& stackMark) <0x7f82579c1e70 + 0x00049> in <filename unknown>:0
at System.RuntimeType.CreateInstanceDefaultCtor (Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, System.Threading.StackCrawlMark& stackMark) <0x7f82579c1c10 + 0x0005c> in <filename unknown>:0
at System.Activator.CreateInstance[T] () <0x7f82578dfb70 + 0x0008a> in <filename unknown>:0
at Autofac.ModuleRegistrationExtensions.RegisterModule[TModule] (IModuleRegistrar registrar) <0x40273470 + 0x0004f> in <filename unknown>:0
at Autofac.ModuleRegistrationExtensions.RegisterModule[TModule] (Autofac.ContainerBuilder builder) <0x40273330 + 0x0006b> in <filename unknown>:0
at jellyfish.Cron.Program.BuildContainer (ILog log) <0x402730e0 + 0x0005f> in <filename unknown>:0
at jellyfish.Cron.Program.ExecuteJob (System.Type jobType) <0x4021abe0 + 0x0007b> in <filename unknown>:0
I was having similar issue, So thought try removing and adding the following DLLS to fix it.
Removed System.net.http, OkHttp, ModernClient. Found the issue was with ModernClientHttp and OkHttp dlls added under references.
I have removed OkHttp and ModernClientHttp and added the ModernClientHttp via Nuget and that works for me.
Give a try if that helps.

Mono on Ubuntu MySqlConnection.Open resulting in System.OverflowException

I am trying to get the demo from http://www.mono-project.com/MySQL working on Ubuntu 11.10, using Mono 2.10.5.
Installed MySQL v2 drivers (after renaming) to the gac. Added provider a line to the machine.config.
Hello World demo compiles and runs fine. The following code executes and connects on MSVS fine.
The compile cmd works: mcs TestMysqlConnect.cs -r:System.Data.dll -r:/home/steve/MONO/Assemblies/Mysql/v2/MySql.Data.dll
using System;
using System.Data;
using MySql.Data.MySqlClient;
public class Test
{
public static void Main(string[] args)
{
string connectionString =
"Server=192.168.111.4;" +
"Database=LOADTRACKER;" +
"Port=3306;" +
"User ID=oec;" +
"Password=oec;" +
"Pooling=false";
Console.WriteLine("Create MySqlConnection");
IDbConnection dbcon;
dbcon = new MySqlConnection(connectionString);
Console.WriteLine("dbcon.Open();");
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();
Console.WriteLine("dbcon.CreateCommand();");
// requires a table to be created named employee
// with columns firstname and lastname
// such as,
// CREATE TABLE employee (
// firstname varchar(32),
// lastname varchar(32));
string sql =
"SELECT Account, Security " +
"FROM accesslist";
dbcmd.CommandText = sql;
IDataReader reader = dbcmd.ExecuteReader();
while(reader.Read()) {
string acct = (string) reader["Account"];
string sec = (string) reader["Security"];
Console.WriteLine("Acct: " + acct + " (" + sec + ")");
}
// clean up
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
}
Executing this code produces:
$mono ./TestMysqlConnect.exe
Create MySqlConnection
dbcon.Open();
Unhandled Exception: System.OverflowException: Number overflow.
at (wrapper managed-to-native) object:__icall_wrapper_mono_array_new_specific (intptr,int)
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.HandleAuthChange (MySql.Data.MySqlClient.MySqlPacket packet) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.Authenticate (Boolean reset) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.NativeDriver.Authenticate (System.String authMethod, Boolean reset) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.NativeDriver.Open () [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.Driver.Open () [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.OverflowException: Number overflow.
at (wrapper managed-to-native) object:__icall_wrapper_mono_array_new_specific (intptr,int)
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.HandleAuthChange (MySql.Data.MySqlClient.MySqlPacket packet) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.Authenticate (Boolean reset) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.NativeDriver.Authenticate (System.String authMethod, Boolean reset) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.NativeDriver.Open () [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.Driver.Open () [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00000] in <filename unknown>:0
Interestingly, if I provide a bad user/password, I get the expected exception of:
[ERROR] FATAL UNHANDLED EXCEPTION: MySql.Data.MySqlClient.MySqlException: Authentication to host '192.168.111.4' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user 'root'#'linux' (using password: YES) ---> MySql.Data.MySqlClient.MySqlException: Access denied for user 'root'#'linux' (using password: YES)
Any help is greatly appreciated. Thank you.

Categories