0
votes

I wrote a simple program since my application doesn't work in mono. But even that simple program doesn't work and I understand is the ServiceHost constructor that doens't initialize its member (despite the fact that in mono source code you can see correct instructions).

I use mono/.net 4.0 ('mono --version' says 4.0.1, monodevelop 5.10, ubuntu 14.04.2 lts (32bit). I've tried to add the dll needed (ver 4.0) in the exe path, but nothing change.

That's the easy code I uses (in .Net no errors, in linux "invalid IL code in System.ServiceModel.ServiceHostBase:get_Credentials() : IL_0000 ret").

Imports System.Security.Cryptography.X509Certificates
Imports System.servicemodel

Public Interface IMyService
    Sub DoSomething()
End Interface

Public Class CMyService
    Implements IMyService

    Public Sub DoSomething() Implements IMyService.DoSomething
        Console.WriteLine("-dosomething-")
    End Sub
End Class

Module Module1

    Sub Main()
        Dim h As New ServiceHost(GetType(CMyService), New System.Uri("net.tcp://127.0.0.1/10000"))
    'if you check 'h', you'll see all its member set to Nothing :(
        h.Credentials.ClientCertificate.Authentication.CertificateValidationMode = Security.X509CertificateValidationMode.None
    End Sub

End Module

It is compiled succesfully but it throws an exception if executed. As reported on source code, if you check members of variable 'h' I have all its items set to 'Nothing'.

I've tried using 32bit and 64bit exe compiled on Windows 7 using Xamarin Studio and Visual Studio (they work great on Windows, but same error in mono). I used in ubuntu the dll copied from Windows .net 4.0. Obviously the 64bit version doesn't even start. I even compiled inside linux using monodevelop 5.10 but I get the same runtime error.

I changed "System.Security.Criptography.X509Certificates" in "Mono.Security.Criptography.X509Certificates" changing also the dll, but in linux I have the same error invariably.

What can I do/check?

I'm stuck for 2 days :/

Thank you in advance.

Update 1

I converted the source code in c#, compiled with mcs, which suggests using also System.IdentityModel.dll. The application in c# works this way. I then update the project in monodevelop, it compile and I can do step-by-step in that IDE.

Then I updated the vb.net project, adding the "missing" dll. It compiles again correctly under monodevelop and the step-by-step debug stops again for the same reason.

Then I compiled using vbnc and it works. But I cannot debug inside the IDE. I cannot understand why... I hope I must not convert all my source code to C# to see other "missing dll", and guess strange behavour of monodevelop...

Maybe I try to add the 'missing' dll in Windows 7, compile and see what linux says.

Update 2

Linux doesn't like the program compiled in Windows 7, it must be compiled in linux using vbnc by command line.

1

1 Answers

0
votes

The problem was solved compiling the test program in linux with vbnc called by command line (for some unknown reason, monodevelop compile correctly only the c# version and not the equivalent version in vb.net).

So it's impossible to do a step-by-step debuggin using monodevelop and vb.net, but it works using c#.

During compilation in c# (using msc) a warning about a missing dll (System.Identity.dll) appears. Microsoft exe doesn't need it, mono does, but only msc tell you about it. I find info about it nowhere, so maybe it can be usefull to someone else... I was 3 days stuck on this :/