Re: [Mono-dev] How to stop and debug native code of a method?

2016-07-12 Thread Robert Jordan

On 12.07.2016 12:39, Pin Cheng wrote:

Hi All,

I am porting mono to a platform,

I wander if I want to trace a method(compiled into native code) how do

You stop the program running when entering into this method? Gdb can

Watch the PC register, but it is very slow, I have wait for tens of minutes.

Is there any efficient way to interrupt some method running?



mono --break namespace.class:methodname  your-assembly.exe

See mono's man page.

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] about appdomain and threads.

2016-07-08 Thread Robert Jordan

On 08.07.2016 05:34, Zhanxing Ding wrote:

Can anyone could tell me about the relationship between appdomain and
threads?

The details are that:



If creating a new appdomian must create a new thread corresponding to it?


It's not required to create a thread for the AppDomain, nor does
the .NET/Mono runtime create one implicitly. Furthermore, AppDomains
do not isolate threads. A thread is readily able to run code from
multiple AppDomains.

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-list] Linux: RunAS with System.Diagnostics.Process fails

2016-07-03 Thread Robert Jordan

On 01.07.2016 01:17, web...@manfbraun.de wrote:

Hello !

I am just trying this:

Process p = new Process();
ProcessStartInfo psi = new ProcessStartInfo();
SecureString password = ReadPassword();
psi.UserName = args[0];
psi.FileName = args[1];
psi.UseShellExecute = false;
psi.Password = password;
.

This works naturally on Linux too - but the required user is NOT the
executing user of that process - it is the same as the starter.

This looks like a bug in the mono classlib/runtime. It is not
a professional solution to run it via a "shell'ed" sudo.
What workarounds are availabe to solve this problem ?


Su/sudo is actually the one and only "professional" approach
under Unix/Linux.

Any other way will eventually end up in reinventing su/sudo, which
is pretty hard (security wise) to be implemented.

For a desktop application you may want to look at kdesu/kdesudo (KDE), 
gksu/gksudo (GNOME), beesu (Red Hat). For a console app: su/sudo.


Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-dev] mono_add_internal_call to mscorlib method

2016-06-10 Thread Robert Jordan

On 09.06.2016 15:37, nicob wrote:

Hi Robert, thanks for the reply. I didn't explain my self correctly. Here's
an example, I have a c# assembly with a method that prints the args to the
console:


I believe I didn't explain the workaround entirely.

Parts of the Mono runtime are expecting that the main entry point
of some assembly has been executed.

Environment.GetCommandLineArgs belongs clearly to this part of
the runtime because, well, it needs data only provided
by executing the main entry point.

The trick is to invoke  mono_jit_exec () on a simple assembly
which does only this:

$ cat < entrypoint.cs
namespace Helper {
   public static class EntryPoint {
public static void Main ()
{
}
   }
}
EOF

$ mcs /target:exe /out:entrypoint.dll entrypoint.cs


Then load entrypoint.dll and pass it to mono_jit_exec.
After this call, almost all parts of the runtime will work
as expected, including Environment.GetCommandLineArgs.
It will return what you've provided to mono_jit_exec ().

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] mono_add_internal_call to mscorlib method

2016-06-09 Thread Robert Jordan

On 08.06.2016 21:26, nicob wrote:

Hi, I'm trying to use the Skype Sdk in mono embedded. I'm able to load the
assemblies but when I try to create a instance of a class that internally
calls System.Environment.GetCommandLineArgs it throws an exception. After
digging a bit I found out the System.Environment.GetCommandLineArgs
internally invokes:

private static extern string[] GetCommandLineArgsNative();

this method is returning null therefore it fails. I'm trying to add an
internal call to the extern method using:

mono_add_internal_call ("System.Environment::GetCommandLineArgsNative",
(void*)GetCommandLine);

I also tried:

mono_add_internal_call
("mscorlib.System.Environment::GetCommandLineArgsNative",
(void*)GetCommandLine);

but neither of them seem to work as my C++ function is never invoked.


You can't override methods which have an IL implementation with icalls.

However, your problem is most likely related to the fact that
you haven't initialized the runtime properly.

You're supposed to invoke a "static void Main () {} " method (which
you can implement in a support assembly) with mono_jit_exec ().

Robert



___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Embedded API: delegate type building

2016-03-04 Thread Robert Jordan

Hi Jonathan,

You may want to have a look at this repo:

https://github.com/robert-j/Mono.Embedding/tree/master/Mono.Embedding

especially at UniversalDelegateServices.

UniversalDelegateServices is able to wrap (almost) all delegate
types with a UniversalDelegate with the following signature:

public delegate object UniversalDelegate(object[] args);

This basically means that you can handle all kind of delegate types
with only one internal call.


Recipe:


Implement an icall with the following signature:


MonoObject*
UniversalDelegateServices_NativeHandler(void *context,
  MonoArray *params)
{
  ...
}


Register it with:

mono_add_internal_call (
  name,
  _NativeHandle);

"name" can be obtained by invoking
UniversalDelegateServices.GetInternalCallName ().


Whenever you need to create a delegate of a given type,
invoke

UniversalDelegateServices.CreateWrapper(type, context);

"context" is a user-defined IntPtr that will be passed
to your icall as the first argument. It can be an
instance ("this" ptr) of a native object, etc.

It's up to you how to handle "context" in the aforementioned
icall.

You could define a native base class "UniversalDelegate"
with a virtual "Handler" method with a signature
more friendly to your framework than
MonoObject*(void *, MonoArray*), etc.


Robert

On 04.03.2016 14:44, Jonathan Mitchell wrote:

Hi

At present I use an InternalCalls for my callbacks and conditional compilation 
(see end) in our cross platform code
In this we assign  a Func directly to an extern static string 
FilePathCallback(string EmployerName);

  In future I would like to support calling methods such as

public CloudClient(Func filePathCallback)

using the Embedded API and cut out the extra plumbing need for InternalCalls.

I have a wooly feel for how I should approach this!
When generating generic types I use a managed helper method.

So I could envisage creating a System.Delegate instance of System.Func.
Then I could set the Target and Method properties - however since I am calling 
back into C there won’t be a Target class.
However System.Delegate is abstract so I would need to sort that out too! - 
presumably this needs to be done dynamically at runtime.

I am aware of the existence of Delegate.CreateDelegate() put that only seems to 
work for instance delegates.

Any insight would be helpful.

Thanks

Jonathan

end
===
public class CloudClient
{
#if TARGET_OSX
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern static string FilePathCallback(string EmployerName);
#endif
public CloudClient(Func filePathCallback) {

_filePathCallback = filePathCallback;

#if TARGET_OSX
if (_filePathCallback == null) {
_filePathCallback = FilePathCallback;
}
#endif
}

}





___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list




___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Embedded API: .ctor method signature query [mono]

2016-03-03 Thread Robert Jordan

Hi Jonathan,

The JIT isn't using these functions for method look-ups.

mono_method_descs are mainly for embedders (and for
trivial method look-ups at some places inside the runtime).

They come handy when you want to get an overloaded
MonoMethod in C/C++:

easy:

desc = mono_method_desc_new (":Method(int, string, int)");
method = mono_method_desc_search_in_class (desc, class);
mono_method_desc_free (desc);

versus hard:

- enum methods with mono_class_get_methods ()
- check method name
- check param count
- check param types
...


If you're generating stubs automatically and don't
have a string description of the methods up front,
the hard way involving mono_class_get_methods () might
be better and faster.

You may want to file a bug, though.

Robert


On 03.03.2016 19:28, Jonathan Mitchell wrote:

HI Robert

Thanks for that.
I think you are right.
I call hundreds of methods that take Obj`1 arguments with out issue but I see that 
I have had to construct a number of helper methods to deal with cases of Obj`2<T, K> 
which failed signature resolution.

I presume that  managed code execution doesn’t involve calls to 
mono_method_desc_new() - are thunks used instead?
One of the difficulties, I find, of working with the embedded API is trying to 
visualise just how a particular managed code statement is implemented within 
the runtime.

I was hoping to be able to call the constructor from C with a pointer to a 
static (MonoString *)fund(MonoString *).
Not sure if that would even fly.

As a work around I will use an internal call.

Shall I log this as a bug and reference this thread?

Thanks a lot for replying.

Jonathan


On 3 Mar 2016, at 18:02, Robert Jordan <robe...@gmx.net> wrote:

On 03.03.2016 14:36, Jonathan Mitchell wrote:

HI

I want to call the following constructor via the embedded API:

public CloudClient(Func<string, string> filePathCallback)

All my other embedded method and constructor calls work okay but there is an issue 
with this one - it is the only place I use a System.Func.
The API reports that a method cannot be found for signature 
.ctor(System.Func`2<string, string>)
When I dump out the class method names I see .ctor(System.Func`2<string, 
string>) listed.

Any ideas on this one?


It looks like a bug in mono_method_desc_new ():

https://github.com/mono/mono/blob/master/mono/metadata/debug-helpers.c#L378

The function is treating

.ctor(System.Func`2<string, string>)

like a method with 2 arguments:

arg0 = System.Func`2

This is obviously wrong :)

The function is then storing the (wrong) argument count
for optimization purposes, and the comparison of methods
is starting to fail:

https://github.com/mono/mono/blob/master/mono/metadata/debug-helpers.c#L447

Robert





___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Embedded API: .ctor method signature query

2016-03-03 Thread Robert Jordan

On 03.03.2016 14:36, Jonathan Mitchell wrote:

HI

I want to call the following constructor via the embedded API:

public CloudClient(Func filePathCallback)

All my other embedded method and constructor calls work okay but there is an issue 
with this one - it is the only place I use a System.Func.
The API reports that a method cannot be found for signature 
.ctor(System.Func`2)
When I dump out the class method names I see .ctor(System.Func`2) listed.

Any ideas on this one?


It looks like a bug in mono_method_desc_new ():

https://github.com/mono/mono/blob/master/mono/metadata/debug-helpers.c#L378

The function is treating

.ctor(System.Func`2)

like a method with 2 arguments:

arg0 = System.Func`2

This is obviously wrong :)

The function is then storing the (wrong) argument count
for optimization purposes, and the comparison of methods
is starting to fail:

https://github.com/mono/mono/blob/master/mono/metadata/debug-helpers.c#L447

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] DllMap default architecture for P/Invoke

2016-01-16 Thread Robert Jordan

On 16.01.2016 14:08, Jason Curl wrote:
>
> How would I handle this scenario within Mono?
>

The dllmap machinery does not probe for target dlls. It performs
a solely textual mapping.

You may want to have different configs with dllmaps for
DEBUG and RELEASE builds.

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-list] Mono, Windows Forms, and Headless operation

2016-01-08 Thread Robert Jordan

On 07.01.2016 22:24, George, Glover E ERDC-RDE-ITL-MS wrote:

Hi all,

We’re currently porting a Windows Forms Application to Mono, and have
generally had great success.  However, we have now hit a critical
decision point, and were hoping for some guidance on the best route
forward.   If we don’t have X11, mono fails to run Windows Forms code
with the following error:

From: System.Windows.Forms, at: Void .ctor(), Error Message: The type
initializer for
'System.Windows.Forms.WindowsFormsSynchronizationContext' threw an
exception.

Question First: The main question I had for the Mono list is this.
Is it possible to have mono run Windows Forms code without trying to
open X11 (I.e. headless mode)?  What triggers mono to request an X11
display? Is it the project type?  Is it the call to an object that
inherits from a Windows Forms control?  I don’t need to see the form,
but if I’m using BackgroundWorkers, I need the form's event handler,
don’t I?



BackgroundWorker does not depend upon System.Windows.Forms, i.e.
it can use it headless.

The exception you're experiencing is caused by the synchronization
context set and used by WinForms.

Supposing that you don't need any kind of synchronization, you
may want to replace the synchronization context with a simple
one.

I don't know if the most simple one 
(System.Threading.SynchronizationContext)

would be enough or if you have to subclass it. Have a look
at its sources and at
System.Windows.Forms.WindowsFormsSynchronizationContext.

Robert

___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Thunk generator

2015-11-14 Thread Robert Jordan

On 14.11.2015 15:31, Evgeny Pirogov wrote:

Hello, Robert Jordan. Thank you for explanation. Is any differences in
mono embedding from mono 2.8 to 4.2?



I don't recall Mono 2.8, but if it has already provided the
Mono 2 Embedded API (check it with "pkg-config --libs mono-2"),
the APIs should be fully backwards compatible.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-dev] Loading AOT output using mono_domain_assembly_open

2015-11-14 Thread Robert Jordan

On 14.11.2015 18:13, zebrajap wrote:

Hi,

I am trying to load the .so file generated by AOT.
When the .dll is passed to mono_domain_assembly_open it returns the
assembly. However when I pass the .so path, it returns NULL. Is there a
different API for AOT assembly loading?


You're still supposed to pass the .dll to mono_assembly_open
or to any other API which expects assembly images.

The AOT machinery will load the .so transparently.

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-list] Thunk generator

2015-11-13 Thread Robert Jordan

On 13.11.2015 13:24, Evgeny Pirogov wrote:

Hello, Robert Jordan.

Look like your utility make c++ code on the fly. Is it only generate .h
files? Where code for C++ generation located in the project?


It generates both C/C++ and H files but not on the fly.
You have to generate the thunks in advance.

The code is in this project:

https://github.com/robert-j/Mono.Embedding/tree/master/Mono.Embedding.ThunkTool

in Program.cs. It's basic reflection stuff.

You can see it in action when you compile the whole solution
and run it on Mono.Embedding.dll [1].


Robert

[1] The Mono.Embedding assembly is providing APIs missing from
Mono's native embedding APIs (generics & implementing
delegates in C/C++).


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] [embedding] "moving from mono_runtime_invoke() to mono_method_get_unmanaged_thunk()" or "how to call class method that takes and returns a string via thunks"

2015-11-12 Thread Robert Jordan

On 11.11.2015 21:41, Jonathan Mitchell wrote:





On 11 Nov 2015, at 20:34, Rodrigo Kumpera  wrote:

How does it crash? Did you try debugging it?

The invocation looks ok.


Is It really?
 From reading the runtime source comments I would have tried something like:

func(NULL, s, );



Rather

func(s, )

because it seems that the method in question is static.


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] [embedding] "moving from mono_runtime_invoke() to mono_method_get_unmanaged_thunk()" or "how to call class method that takes and returns a string via thunks"

2015-11-12 Thread Robert Jordan

On 12.11.2015 13:52, Jonathan Mitchell wrote:



On 12 Nov 2015, at 12:41, Julian Mayer  wrote:

i didn't list any specific crash, because i tried in a million different ways 
and got a different crash each time.

i've solved this now. it seems, a unmanaged thunk takes a hidden additional 
parameter, MonoException ** which can't be NULL. of course this isn't 
documented anywhere.


This I feel is a real problem for the embedded API as it is.
The above is documented in the source, but not in the header.
Source comment documentation is fine for the source authors but it leaves 
consumers out in the cold.
The long and the short of it is that you really need to have the Mono embedded 
source to hand at all times even if you don’t build you own Mono.


In the past, the source code comments were picked up by some
$TOOL and then published under some $URL of mono-project.com
by a $PERSON (with $PERSON == Miguel, IIRC).

However, my thunk docs were never published for some reasons :(
This probably also means that almost nobody is using these
almost 5-8 years old APIs.

If you have questions about this API area, feel free to
ask on this list. I'll do my best to answer them, if I
can recall ;)

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] [embedding] "moving from mono_runtime_invoke() to mono_method_get_unmanaged_thunk()" or "how to call class method that takes and returns a string via thunks"

2015-11-12 Thread Robert Jordan

Hi Jonathan,

On 12.11.2015 14:34, Jonathan Mitchell wrote:



On 12 Nov 2015, at 13:11, Robert Jordan <robe...@gmx.net> wrote:

On 12.11.2015 13:52, Jonathan Mitchell wrote:



On 12 Nov 2015, at 12:41, Julian Mayer <jul...@corecode.at> wrote:

i didn't list any specific crash, because i tried in a million different ways 
and got a different crash each time.

i've solved this now. it seems, a unmanaged thunk takes a hidden additional 
parameter, MonoException ** which can't be NULL. of course this isn't 
documented anywhere.


This I feel is a real problem for the embedded API as it is.
The above is documented in the source, but not in the header.
Source comment documentation is fine for the source authors but it leaves 
consumers out in the cold.
The long and the short of it is that you really need to have the Mono embedded 
source to hand at all times even if you don’t build you own Mono.


In the past, the source code comments were picked up by some
$TOOL and then published under some $URL of mono-project.com
by a $PERSON (with $PERSON == Miguel, IIRC).

Yep, seen those. And as you say, less than complete. Traditional headed 
documentation is hard to beat though.


If you have questions about this API area, feel free to
ask on this list. I'll do my best to answer them, if I
can recall ;)


Okay, here goes!

I use mono_runtime_invoke for Obj-C property and method calls as per:
https://github.com/ThesaurusSoftware/Dubrovnik/blob/329aa5551a393c1dc609185164e35e44ddb27ba0/Framework/XCode/Utility/DBInvoke.m

I use a code generator to produce my embedded API binding code.
I reckon that if I can generate mono_runtime_invoke access code I can figure 
out how to do the same with thunks.

Currently I build a MonoMethodDesc *cache keyed by the method name to feed 
mono_runtime_invoke at the call site.
That part of the code predates your thunking API.
I presume that to use the thunks the best approach would be to build the thunk 
lazily, stash it in an instance var and then use as and when required?

I know this question is like, how long is a piece of linguine , but what sort 
of performance improvement does thunking potentially provide?



You're supposed to use the thunks lazily because:

1) thunks are methods which must be generated and take some
   memory (and CPU cycles during the generation).
   I wouldn't advice to generate thunks for the whole mscorlib
   in advance. This also applies to mono_runtime_invoke.

2) while thunks are also cached, their cache "strategy" is less
   complex than mono_runtime_invoke's wrapper caching.
   The latter is caching by signature while the thunks
   are cached by type + signature.


On performance: about 10^3 speed-up on a micro benchmark
which invokes a simple method like this 100,000,000 times:

public static float Add(float a, float b)
{
return a + b;
}

See attachment.

Robert



thunkbench.tar.gz
Description: GNU Zip compressed data
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] Thunk generator

2015-11-12 Thread Robert Jordan

Hi!

It seems that thunks are seldom used by the community
due to lack of documentation and samples.

They remain cumbersome to consume even when someone has
accidentally found out how to use them ;)

Here is a simple tool which generates C/C++ code from an
assembly whose members were marked with a custom [Thunk] attribute:

https://github.com/robert-j/Mono.Embedding

See README.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Missing some symbols in Windows package.

2015-10-22 Thread Robert Jordan

On 22.10.2015 17:22, donggas90 wrote:

How should I fix it?


This is totally unrelated to Mono.

Please check the docs of Assembly.Load().
AssemblyName is *not* a file name.

Not "FullPath\__Intermediate.dll" and not "__Intermediate.dll".

Just "__Intermediate". This is the (partial) assembly name
of the assembly.


Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Missing some symbols in Windows package.

2015-10-21 Thread Robert Jordan

On 21.10.2015 11:53, donggas90 wrote:

Thanks again, Robert.

I already known about that jit init and cleanup have to call only once.
and I'd tried the scheme what you said.


It's not quite what I wrote. You're not handling domain creation
inside the managed world.

You may want to search the web for this kind of projects.
Try "compile c# on the fly appdomain". If you decide to
use one, you'd just have to add some kind of extension point
(an icall, for example) that gets you back into the unmanaged
world and you're done.

I know that the embedding APIs look appealing because
they might hide some ugly details of cross appdomain marshaling,
but they are also less stable to use than the well-known and
better unit-tested managed APIs.

Concerning your C++ code:

You're unloading the domain while it's still the active domain.
You should mono_domain_set () the root domain first and then
unload the ephemeral domain. Not sure if this would fix the
crash you're experiencing, though.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Missing some symbols in Windows package.

2015-10-20 Thread Robert Jordan

On 20.10.2015 06:37, donggas90 wrote:

Thanks, moljac.

That's reasonable.

Ultimately, my purpose is that edit C#, recompile it and invoke it in C++
runtume with the Mono API.
so I had found some article about it in this forum such as  this
  .
but that article is too abstract to figure out how to do it exactly.
I have tried many ways to recompile and reload a assembly, but always
failed.
Finally, I'm really considering to give up to embed the Mono for my
application.


You have to realize first that embedding Mono won't give you
more `power' than the managed world would do.

I can understand the desire for code like this, although
it looks more like throwing the baby out with the bathwater
in a loop:

for (;;) {
mono_jit_init ();
do work
mono_jit_cleanup ();
}

;)


If I had to attack this problem I'd do it this way:

(1) How do I achieve these tasks using manged code?

- compiling C#
- creating a domain
- loading an assembly
- executing code from this assembly
- unloading a domain

This is pretty basic stuff for .NET hackers and it's runtime-
agnostic (it runs on both Mono and MS.NET).

The next step:

(2) Factor out a managed assembly which performs (1) and
exposes a simple API which can be easily invoked from the
unmanaged world using Mono's embedding API.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Missing some symbols in Windows package.

2015-10-16 Thread Robert Jordan

On 16.10.2015 09:47, donggas90 wrote:

mono_thread_push_appdomain_ref
mono_thread_pop_appdomain_ref
and the other symbols in 'mono/metadata/threads-types.h' are missing in
Windows(4.0.4.4).
beacause the header had not included in the package.
If this exclusion is normal, those symbols had not moved to 'threads.h'.

If declare those symbols as 'extern' at anywhere, it can be link.
however should be fixed to prevent confusion.


This is a private header. You're not supposed to call these functions.

Under Linux you won't be even able to invoke them.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-dev] Problem with custim marshaller on list

2015-10-16 Thread Robert Jordan

Hey,

On 15.10.2015 18:21, Guillaume wrote:


when I call that method, I have this error:
marshaling type 15 not implemented
* Assertion: should not be reached at marshal.c:1952


The error most likely means that Mono's marshaller does not
support generic types in structures supposed to be used
in p/invoke scenarios, even if you have a custom
marshaller for it.

Try "public object b" in place of "public IList b".

You may also want to file a bug it this feature is supported
on MS.NET but not on Mono.

Robert




___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Registry

2015-10-08 Thread Robert Jordan

On 08.10.2015 10:44, psant...@codicesoftware.com wrote:

Hi there,


Are you trying to run "on mono" or do you mean on mono + linux or mac?


Mono's registry implementation is using native Windows APIs
under Windows, so the concurrency issues Neale was speaking
about do not apply here.

Robert



pablo



On 10/6/2015 23:47, Neale Ferguson wrote:

We have a client who is testing the waters with porting some .NET based
applications to mono. However, a couple of these critical applications
rely on the windows registry. The implementation of registry-support in
mono is quite crude and not process-safe and this is holding them back. I
am looking for ideas as to improving this so that apps can share the
registry safely and efficiently.

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
.





___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list




___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-list] Interop - PreserveSig

2015-10-04 Thread Robert Jordan

On 04.10.2015 00:25, lx42 wrote:


So my question is, does mono respect PreserveSig?



DllImportAttribute.PreserveSig = false is not supported.

However, methods of COM interfaces do have "PreserveSig = false"
semantics by default, unless they were marked with

[MethodImp(MethodImplOptions.PreserveSig)]

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] COM Interop

2015-10-04 Thread Robert Jordan

On 03.10.2015 09:19, lx42 wrote:

This is for Linux.

Does Mono support COM interop now (just the base minimum, no things like
dispatch, BSTR etc.)?  The FAQ says no but it was referring to version 1.x.


Have a look at this example:

https://github.com/robert-j/MonoCom

BSTRs are supported as well, either using an oleouto implementation
(which must be made available as liboleauto32.so), or using
Mono's BSTR implementation. I don't have a sample for this yet.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-dev] boehm and pin to sgen and moveable

2015-10-04 Thread Robert Jordan

Hey Jonathan,

On 03.10.2015 16:25, Jonathan Mitchell wrote:

In my ObjC->Mono bridge I have been using the Boehm collector and pinned memory 
(as an expedient).
I now want to move to SGEN and moveable memory.
As a first step I have switched to SGEN and left pinning enabled.

My ObjC code wraps a MonoObject * in an NSObject.
When the MonoObject is set it is pinned.
A simple monoObjectTrace property watches to see if the MonoObject moves.

Under the Boehm collector objects seem to stay pinned as requested.
Under SGEN they don’t i.e.: the exception in the second method below raises 
i.e.:  self.monoObjectTrace != (NSUInteger)monoObject)

What am I doing wrong?


It depends on how your methods are actually used.

In setMonoObject, there is a time frame between

mono_gchandle_free ()
mono_gchandle_new ()

where the GC might regain control and move the object.

Try to ensure that setMonoObject is called only once for
the same obj, such that mono_gchandle_free () followed
by mono_gchandle_new () isn't needed.

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Class built by mono throws FileNotFoundException when run on windows

2015-09-02 Thread Robert Jordan

On 01.09.2015 22:04, Edward Ned Harvey (mono) wrote:

The workaround I've found is to create a wrapper class MonoSpecific,
so the if-clause and the Mono.Posix call are not in the same file.
But this is clearly a hack. Is there a better way?


You're depending on undefined behavior. The workaround is only
working because the JIT compiler is lazily compiling methods,
and won't compile DoChmod() under Windows.

You should mark DoChmod() with

[MethodImpl(MethodImplOptions.NoInlining)]

Otherwise the issue might come back unexpectedly.

However, if .NET 5.0 would start to eagerly compile assemblies
(for whatever reason), the issue will come back as well.


A sane and easy solution is to deploy Mono.Posing on Windows side-by-
side with you app.

Even when running on Mono, Mono.Posix should be picked up
from the GAC. Your copy won't be loaded anyway.

The super-sane solution is to abstract these calls away using a
factory and 2 assemblies, one for Windows and one for Mono
which has Mono.Posix as a reference.

Robert

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Invoking .net interface method from c api

2015-08-21 Thread Robert Jordan

On 21.08.2015 11:43, zebrajap wrote:

Oh. I got your point.

The build output have System.dll in multiple places.

./lib/mono/2.0/System.dll
./lib/mono/4.5/System.dll
*./lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll*
./lib/mono/4.0/System.dll

I was loading it from ./lib/mono/4.0/System.dll. I am loading it as follows.

mono_set_dirs(Build Path/lib, Build Path/etc);
pDomain = mono_jit_init_version(BuildDomain, v4.0.30319 ); // Init 
the
JIT Engine
mono_config_parse(NULL);

MonoAssembly* pSystemAssembly = mono_domain_assembly_open (pDomain, 
Build
Path/lib/mono/4.0/System.dll);
pSystemImage = mono_assembly_get_image (pSystemAssembly);

The file in gac seems to have the implementation.
How to make it load from gac without providing absolute path? Please note
that I cannot install it here.



Use one of the mono_assembly_load_*() functions because they
are obeying the usual CLR assembly binding rules (those rules C#
programmers are used to).


A good start is mono_assembly_load_with_partial_name () which
can be as simple as:

MonoImageOpenStatus status;
asm = mono_assembly_load_with_partial_name(System, status);

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Invoking .net interface method from c api

2015-08-21 Thread Robert Jordan

On 21.08.2015 06:44, zebrajap wrote:

Now I am getting a different error.

104 MonoObject* pIcc = mono_runtime_invoke(pMethodCreateCompiler,
pCodeProvider, NULL, NULL);
(gdb) p pMethodCreateCompiler
$1 = (MonoMethod *) 0x6aa288
(gdb) n

Unhandled Exception:
System.InvalidProgramException: Invalid IL code in
Microsoft.CSharp.CSharpCodeProvider:CreateCompiler (): IL_: ret

[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidProgramException: Invalid
IL code in Microsoft.CSharp.CSharpCodeProvider:CreateCompiler (): IL_:
ret

So I opened mono/4.0/System.dll using ILSpy. There, all the methods seems to
have empty body with single instruction.
http://mono.1490590.n4.nabble.com/file/n4666512/IlSpy.png

What could be the issue ?



It looks like you are tying to execute a reference assembly.
These are stripped off of method bodies.

How do you load System.dll?

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Invoking .net interface method from c api

2015-08-20 Thread Robert Jordan

On 20.08.2015 11:17, zebrajap wrote:

The build machine does not have mono installed. So I have copied the dlls
from another similar machine to
/home/sameeraj/assemblies/mono/1.0/. (I am not sure why I had to copy in to
mono/1.0 but if I don't when the program runs it complains mscorlib should
be in that folder.)

mono_set_dirs(/home/sameeraj/assemblies, .);
pDomain = mono_jit_init (BuildDomain);

MonoAssembly* pSystemAssembly = mono_domain_assembly_open (pDomain,
/home/sameeraj/assemblies/mono/1.0/System.dll);
pSystemImage = mono_assembly_get_image (pSystemAssembly);

MonoAssembly* pMscorlibAssembly = mono_domain_assembly_open (pDomain,
/home/sameeraj/assemblies/mono/1.0/mscorlib.dll);
pMscorlibImage = mono_assembly_get_image (pMscorlibAssembly);

Thanks.



Wow, I'm sensing a couple of issues here :)

1) your Mono is old. The 1.0 profile has been phased out a couple
of years ago.

2) the directory layout you're passing to mono_set_dirs
is most likely incorrect. Both dirs must contain a directory
mono with the contents taken from a full Mono installation
($prefix/lib/mono and $prefix/etc/mono).

3) the CodeDomProvider is necessitating even more of a Mono installation
because it must be able to invoke the C# compiler (mcs). Step (2)
is enough for this, though.

4) for complex things like CodeDomProvider you're supposed to
initially mono_jit_exec() an assembly that implements an entry
point (static void Main()).


Please do yourself a favor and start developing on a machine
with a full (and fresh) Mono.

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Invoking .net interface method from c api

2015-08-20 Thread Robert Jordan

On 19.08.2015 17:31, zebrajap wrote:

Thanks Robert.
It still does not work. Was it working in your case ? Now I begin to wonder
if there are any issues with my system


Please show us the code where you're initializing the runtime.

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Invoking .net interface method from c api

2015-08-19 Thread Robert Jordan

On 19.08.2015 08:39, zebrajap wrote:


This code fails at MonoObject* pIcc =
mono_runtime_invoke(pMethodCreateCompiler, pCodeProvider, NULL, NULL); line.
What am I doing wrong.




You're supposed to call mono_object_get_virtual_method () on the
interface method prior to invoking it on a derived class:

pMethodCreateCompiler = mono_object_get_virtual_method(pCodeProvider,
  pMethodCreateCompiler);
mono_runtime_invoke(pMethodCreateCompiler, pCodeProvider, NULL, NULL);



Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Embedded mono crash on exception

2015-08-06 Thread Robert Jordan

On 06.08.2015 08:12, Trigve wrote:

I'm using embedded mono (using unity) in C++ DLL. I'm calling some managed
functions using mono_runtime_invoke(). The function does throw an exception,
which I caught with the MonoException argument. Then I want to unwind stack
(in C++) so I throw my custom exception. But application crashes at address
 (last function on the stack is ExecuteHandler2@20()). So it looks
like some exception handler is set pointing to the NULL.



I'm pasting this from the Nabble Forum because it didn't make
into the mail:


First-chance exception at 0x7548C42D in Unity.exe: Microsoft C++ exception: 
ExceptionAlreadySet at memory location 0x0028D63C.

First-chance exception at 0x in Unity.exe: 0xC005: Access violation 
executing location 0x.


Not sure about Unity's Mono (it's a customized version) but
First-chance exception at 0x is usually not an error,
at least not in the old Mono version Unity is using.

This exception is an artifact of Mono's NullReferenceException handling.
You are supposed to ignore it.

Robert



___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-list] Monodevelop made application not starting on ubuntu

2015-08-06 Thread Robert Jordan

On 06.08.2015 14:48, Edward Ned Harvey (mono) wrote:

From: mono-list-boun...@lists.ximian.com [mailto:mono-list-
boun...@lists.ximian.com] On Behalf Of Robert Jordan

On 05.08.2015 18:40, Andres G. Aragoneses wrote:

I hope you've considered the licensing implications. In particular,
if you distribute the mono runtime with an application, your
application will need to be GPL.

The runtime is LGPL.


But AFAIU when you use mkbundle you're not linking anymore, you're
joining everything together in one executable. So then the result must
be LGPL as well.


Only if mkbundle's --static option is used. Otherwise (w/out --static),
the bundled app is still dynamically loading the LGPLed runtime
(libmono*.so) = the license of the bundled app does not need
to be LGPL compatible.


This is emphatically a lawyer question. Are you a lawyer?


Which question? No one was asking for legal advice.


The legal implication of static linking files is a fuzzy one - What if you're 
not static linked but then your application gets distributed in a zip file or 
some other package that joins them all into a single file? What if that package 
file is self-executable? Very fuzzy.


I was solely talking about mkbundle's output. Other distribution
methods, like (self-extracting) archives that might by applied
after mkbundle, were not subject of the discussion.


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Monodevelop made application not starting on ubuntu

2015-08-05 Thread Robert Jordan

On 05.08.2015 18:40, Andres G. Aragoneses wrote:

I hope you've considered the licensing implications. In particular,
if you distribute the mono runtime with an application, your
application will need to be GPL.

The runtime is LGPL.


But AFAIU when you use mkbundle you're not linking anymore, you're
joining everything together in one executable. So then the result must
be LGPL as well.


Only if mkbundle's --static option is used. Otherwise (w/out --static),
the bundled app is still dynamically loading the LGPLed runtime
(libmono*.so) = the license of the bundled app does not need
to be LGPL compatible.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Mono Embedding - List enumeration

2015-07-28 Thread Robert Jordan

Hi,

On 27.07.2015 19:53, Henry wrote:

Can anyone shed some light on the best way to enumerate a List using mono
embedding?  I have a managed method that returns a List, I need to
enumerate this list in c code using mono embedding.  I can't seem to find
any documentation or examples on this that provide a definitive answer on
how to do this.  I've tried GetEnumerator and MoveNext, but there appears to
be some kind of issue with the generic implementations.



When it comes to accessing generic objects/classes, it's usually easier 
to implement managed helper methods than doing all the footwork in

C/C++, e.g.:

static void int GetCount(Liststring list)
{
return list.Count;
}

static string GetElementAt(Liststring list, int pos)
{
return list[pos];
}


Manually (in C/C++), you'd need to obtain the method
IEnumerable_GetEnumerator (notice the rule of building
explicit interface method names) from the class of the list
object, something like that:

MonoObject *list = ...
MonoClass *klass = mono_object_get_class (list);
MonoMethod *method = mono_class_get_method_from_name(klass,
IEnumerable_GetEnumerator, 0);

Then invoke the method to obtain the enumerator with
mono_runtime_invoke ().

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Anyone else missing reply-to?

2015-05-12 Thread Robert Jordan

On 12.05.2015 17:16, Maury Markowitz wrote:

When I Reply it goes to the original poster, not the list. Looking at
the headers it seems reply-to isn’t being sent to me.

Is anyone else having this problem?


Yes, but it isn't a problem. It's intentional.

http://www.unicom.com/pw/reply-to-harmful.html

Good Mail User Agents implement a reply-to-list feature.

Robert

___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Embedded API: Getting assembly version via MonoAssemblyName

2015-03-28 Thread Robert Jordan

On 28.03.2015 14:40, Robert Jordan wrote:

There are a couple of *pubic* mono_assembly_name_* functions in


Some public, too. Sorry! :)


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Embedded API: Getting assembly version via MonoAssemblyName

2015-03-28 Thread Robert Jordan

On 27.03.2015 13:44, Jonathan Mitchell wrote:

HI

I want to get the assembly version like so:

MONO_API uint16_t  mono_assembly_name_get_version (MonoAssemblyName 
*aname,
  uint16_t *minor, uint16_t 
*build, uint16_t *revision);

So I need MonoAssemblyName like so:

mono_assembly_fill_assembly_name(MonoImage *image, MonoAssemblyName *);

But MonoAssemblyName is opaque and cannot be statically allocated.
So how do I proceed?


There are a couple of pubic mono_assembly_name_* functions in
assembly.h, including mono_assembly_name_new () which is probably
allocating an opaque MonoAssemblyName struct for you.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Mono Embedding: How can I use a Generic Class from mscorlib.dll

2015-03-23 Thread Robert Jordan

On 23.03.2015 15:13, LinWuxiang wrote:

Hello everybody.

How can I instantiate a generic type, like ListString from mscorlib?

I thought I should use “mono_class_from_generic_parameter”, but not sure
how to use this function.


There used to be no embedding APIs for this in the past, and it
doesn't look that this was changed.

You can achieve this by mono_runtime_invoke()-ing
System.Type.MakeGenericType (see MSDN).

Note that System.Type is represented by MonoReflectionType*
in the embedding world. You can get the MonoReflectionType*
of a MonoType* with mono_type_get_object().

You can get back the MonoType* of a MonoReflectionType* with
mono_reflection_type_get_type().

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-dev] Porting Mono to 'asm.js'

2015-03-15 Thread Robert Jordan

On 15.03.2015 10:59, Nirmal Lankathilaka wrote:

I've been using Mono for developing desktop apps for a couple of years and
would love to contribute to the project. Since I'm still a student, I think
GSoC is a splendid opportunity to start.

Porting Mono to `asm.js`, presented for GSoC, caught my attention
recently. I spent some time researching this and I'd like some
clarification from the community:

Since Mono-LLVM support does exist[mono-llvm]
http://www.mono-project.com/docs/advanced/mono-llvm/, why would the need
arise for a port? I understand that there are limitations
[mono-llvm#limitations]
http://www.mono-project.com/docs/advanced/mono-llvm/#limitations in the
above approach as LLVM doesn't fully support all the needs of Mono; but
since there is no specifications given which would require one to avoid the
above approach (mono-llvm--llvm--emscripten--asm.js), I'm a bit confused.


The proposal assumes a slightly deeper understanding of the Mono
internals.

http://www.mono-project.com/community/google-summer-of-code/projects/#port-mono-to-asmjs

mono runtime is here the part of Mono that provides the OS
abstraction layer (file, network etc.) and GC. It's that minimal
part of Mono that's needed for running static AOT (ahead-of-time
compilation) assemblies that were compiled to native shared objects
or included into the main executable. Basically, it's Mono sans
code generation, suitable to run on the target.

The target is here emscripten/asm.js, so it needs a port.

mono cross compiler that can target emscripten
is a Mono LLVM AOT target that generates LLVM code suitable
for emscripten. This part is supposed to run on the host, i.e.
it has access to a full tool chain etc.



On a different note, could you explain to me whether I should use the
forums instead of the mailing-lists (which I prefer) for communication
regarding GSoC and the `asm.js` port.


The forums are just a mirror of this list.

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-list] Debugging binding Obj-C?

2015-03-11 Thread Robert Jordan

On 11.03.2015 15:46, Michael McGlothlin wrote:

I'm having problems binding a precompiled third party framework. I keep getting 
a dyld error about being unable to find the library but it only shows the error 
after I've done the binding, added the library to a project, compiled the 
project and deployed it to the device, watched it crash, and looked at the 
error log on the device. Is there a way to test the binding as soon as the dll 
is made?

How would I make sure the binary blob is included and adjust the path reference 
internally in the dll to make sure it's correct?



Embedded dynamic frameworks are a PITA even with Xcode.
I'd rather ask somewhere else (Xamarin Forums?) whether and how
this feature is actually supported by Xamarin.iOS.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Generic class and mono_class_from_name

2015-03-11 Thread Robert Jordan

On 10.03.2015 20:24, mimi wrote:


c++
 MonoClass* classDictionary = NULL;
 classDictionary = mono_class_from_name(image, TestDictionary,
Class1);

I compiled TestDictionary.dll and Playstkop.Toolbox.exe. classDictionary
returns NULL. I digged into mono_class_from_name and found that the value of
'name' is 0x0 instead of Class1.



You're passing the wrong `image' to mono_class_from_name.
If you want TestDictionary.Class1 from TestDictionary.dll,
then you must use the image of TestDictionary.dll.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Could not lookup zero argument constructor for class Ninject.StandardKernel

2015-03-06 Thread Robert Jordan

On 05.03.2015 23:18, mimi wrote:

Thanks Robert! It worked out but I got another problem.

classDictionary = mono_class_from_name(mono_get_corlib(),
System.Collections.Generic, Dictionary' 2); NULL


It's Dictionary`2. Notice the backtick.



classDictionary = mono_class_from_name(mono_get_corlib(),
System.Collections.Generic, List' 1); NULL


List`1




___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Could not lookup zero argument constructor for class Ninject.StandardKernel

2015-03-05 Thread Robert Jordan

On 04.03.2015 20:04, mimi wrote:

For Mono, if I insert 'mono_runtime_object_init(instanceStandardKernel)', we
are trying to execute  default argument-less ctor of StandardKernel that
doesn't exist and I got the error which is normal.

Here, how Mono will parse 'new StandardKernel()'? Default ctor or first ctor
without passing anything? Are error messages I got related to this?


The exception is unrelated to how mono is invoking ctors :)

Some parts of the runtime require that mono_jit_exec() was executed.

Implement an empty static void Main() in your entry assembly and
execute it with mono_jit_exec() before doing other work.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Could not lookup zero argument constructor for class Ninject.StandardKernel

2015-03-04 Thread Robert Jordan

On 03.03.2015 21:57, mimi wrote:

I embedded Mono to my c++ code and tested with basic stuffs (invoke c#
methods wiht parameters and from multiple DLLs). I am trying to add Ninject
stuff to my code
(https://github.com/ninject/Ninject/blob/master/src/Ninject/StandardKernel.cs).
The following is the code segmrnt:


[...]


And can't figure out why the mono runtime can't find the default
constructor. I tested with Visual Studio c# project and it works fine.


There isn't a default parameter-less ctor in this class (look at
StandardKernel.cs).

You want to look up and invoke one of the specific ctors and omit
mono_runtime_object_init().

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Open multiple c# dlls inside the same MonoDomain

2015-02-27 Thread Robert Jordan

On 26.02.2015 15:51, mimi wrote:

Hi,

I am trying to embed Mono in my Qt app. In my c++ code, I managed to invoke
the methods of a single c# dll. Right now, I need to invoke the methods from
one c# dll which, in turn, invoke the methods from other c# dll, how can I
implement this in my c++ code? I did some research and didn't find the
answer to my need. I am stuck here. Does anybody have any idea on this?
Sample code, document, relevant post, ..


It's the same as calling methods from the start DLL. Nothing
special there.

Robert



___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Help with embedded mono: mono_runtime_object_init

2015-02-24 Thread Robert Jordan

On 24.02.2015 18:19, mimi wrote:

Hi Rod,

Did you manage to fix the problem? I made some research and it seems to be
fixed already (https://bugzilla.xamarin.com/show_bug.cgi?id=12541). In that
link, it marks PC Linux. I got the same problem here on os x 10.8.5 and
can't figure out why. Any idea? Thanks in advance!


Your issue is probably unrelated to this bxc bug.

You're initializing the runtime with mono_jit_init(Domain), but you're 
supposed to pass the file name of the start assembly in place

of the string Domain. Otherwise, the runtime will be initialized with
a corlib version that might not match the version requested by
your start assembly.

If you're unable to invoke mono_jit_init on an actual file,
use mono_jit_init_version (Domain, v4.0.30319) instead.
This will initialize the 4.5 runtime which is probably what
you want anyway.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-dev] What will happen if Dispose() hangs?

2015-01-27 Thread Robert Jordan

On 27.01.2015 18:56, Edward Ned Harvey (mono) wrote:

From: mono-devel-list-boun...@lists.ximian.com [mailto:mono-devel-list-
boun...@lists.ximian.com] On Behalf Of Robert Jordan

You may want to look up how a sane IDisposable pattern has to be
sensibly implemented in .NET. You'll find out that Dispose()
shouldn't be called from a finalizer.


Uhmm...  You got that wrong.  Here is the recommended pattern:
https://msdn.microsoft.com/en-us/library/b1yfkh5e(v=vs.110).aspx

Basically, *always* call Dispose(false) from the finalizer, if present, but 
avoid having a finalizer unless you need one.


That's Dispose(bool). I was speaking about Dispose().


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] What will happen if Dispose() hangs?

2015-01-27 Thread Robert Jordan

On 27.01.2015 15:46, Edward Ned Harvey (mono) wrote:


The question still stands about what happens if Dispose() hangs during garbage 
collection...



You may want to look up how a sane IDisposable pattern has to be 
sensibly implemented in .NET. You'll find out that Dispose()

shouldn't be called from a finalizer.

A blocking finalizer will hang the GC, but it looks like SslStream is
implementing finalization correctly:

https://github.com/mono/mono/blob/master/mcs/class/System/System.Net.Security/SslStream.cs#L516

https://github.com/mono/mono/blob/master/mcs/class/System/System.Net.Security/AuthenticatedStream.cs#L78

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-list] Specific thread for event?

2015-01-12 Thread Robert Jordan

On 12.01.2015 08:53, Michael McGlothlin wrote:


Obviously something has been done with iOS to make it possible to
access the main thread. Am I missing something or is this pretty much
a deadend?


In iOS (and many other UI frameworks), the main thread runs a
message/event loop which provides callback/synchronization
functionality. Something like that (schematic):

while (HasMessage ()) {
var msg = DequeueMessage ()
if (msg is Callback)
msg.InvokeCallback (msg.Arguments)
...
}

Usually, these UI frameworks also provide an InvokeOnUIThread method
which injects a special message into the event queue.

You'd have to implement (or reuse) a similar event loop approach for
your own threads.

Robert

___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-dev] monolite URL

2014-12-11 Thread Robert Jordan

On 11.12.2014 07:33, Alex J Lennon wrote:

The thing to keep in mind is that the corlib version inside monolite
needs to match the runtime version or bootstrapping the classlib build
won't work, so you can't just keep an old monolite and use it to build
newer Mono (at least that's how I understood it).



This is also news to me and very helpful to know thanks. I am not
disagreeing but I am surprised that we have to have an exactly matching
build of monolite for this, whereas we don't  if using a full-fat
Mono. I wonder why that is? Because monolite is very barebones just for
bootstrapping purposes ?


Monolite (a mcs + basic BCL) does not contain a Mono
runtime. That's the reason why its corlib must match the
runtime that you are about to build.

On the other hand, a full Mono does not have this limitation
because it comes with its own runtime + BCL + mcs. These are
by design always in sync.

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-list] Differences in GetHashCode() of Type between .NET and Mono

2014-12-08 Thread Robert Jordan

On 08.12.2014 09:21, Hüning, Christian wrote:


However I found that Mono and .NET produce different hashcodes for the same
type from the same DLL. On second thought, this is very clear to me, since
up to recently we could have no idea how the GetHashCode() implementation in
.NET looks like.



Now for my algorithm this is a little showstopper. So I’ve got two
questions:

A) Is there another way to achieve my scenario above?



You're not supposed to rely on what GetHashCode () is returning.
Neither in MS.NET (where its result might differ between MS.NET
versions), nor in Mono.

See 
http://msdn.microsoft.com/en-us/library/system.object.gethashcode%28v=vs.110%29.aspx


The only reliable and valid relations are:

Object.ReferenceEquals(a, b)
= a.GetHashCode() == b.GetHashCode()

a.Equals(b)
= a.GetHashCode() == b.GetHashCode()


B)  Are there plans to use .NET’s hashcode implementation in Mono now
that it’s available?


There are no such plans. Changing Object/ValueType.GetHashCode () or
RuntimeHelpers.GetHashCode () won't be enough anyway. Every
overridden GetHashCode () would need a review/change...

And since sane application don't rely on this, there isn't
much motivation for such changes ;)

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-dev] List of cleanup candidates for Mono 4.0

2014-11-27 Thread Robert Jordan

On 27.11.2014 19:19, Alexander Köplinger wrote:

Hey,
* gmcs/dmcs - they just redirect to mcs now and without the 2.0 etc profiles 
it doesn't make sense to still have them


It doesn't make sense to us, but removing them would just break
thinks downstream.

It's really annoying when such changes are done just for the
sake of OCD, so please stop this.


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] .NET Reference source terminology

2014-11-23 Thread Robert Jordan

On 23.11.2014 12:57, Martin Thwaites wrote:

Hi All,

Has anyone got any idea what FEATURE_PAL is?

It's a define, and seems to have a lot of comments around IIS, and that if
it's Enabled, then don't do IIS stuff.  Seems like something that we could
just add in our stuff to exclude alot of windows specific stuff without
having to add our own defines?

e.g.
https://github.com/Microsoft/referencesource/blob/fa352bbcac7dd189f66546297afaffc98f6a7d15/System.Web/HttpRuntime.cs#L139

The best explanation I've seen says it's the Platform Adaptation Layer,
and is to do with compiling it for other architectures such as ARM.  Seems
like something that we would want to enable?



There is a ROTORTODO comment inside a FEATURE_PAL block:

https://github.com/Microsoft/referencesource/blob/fa352bbcac7dd189f66546297afaffc98f6a7d15/System.Web/HttpRuntime.cs#L304

Rotor: 
http://en.wikipedia.org/wiki/Shared_Source_Common_Language_Infrastructure


PAL: Platform Abstraction Layer.

So it probably makes sense to enable (or to look closely at)
FEATURE_PAL when compiling for Mono.

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Webapp stuck with Key duplication when adding: httpModules

2014-10-23 Thread Robert Jordan

On 23.10.2014 13:25, Etienne Champetier wrote:

After some more investigation, reading many lines of code with a collegue,
we came to the conclusion that this exception is impossible :)
(yet the web is stuck on it)


Are you sure that this NameObjectCollection isn't mistakenly accessed
from  multiple threads?

Look System.Web.Configuration.WebConfigurationManager.GetSection
all the way up the stacktrace. There are several scary parts that
deal with locking.

Robert




m_ItemsContainer is an hashtable, and a private field of
NameObjectCollectionBase
class (new HashTable(0,StringComparer.Ordinal)).
The exception tell us that there is already a key 'httpModules' in
m_ItemsContainer.
Reading the code the only way we go from BaseSet to BaseAdd is if
FindFirstMatchedItem('httpModules'), so if (_Item)m_ItemsContainer[
'httpModules'] is null,
so if the value is null (the key exists, we got an exception to prove it :))

if i'm right, we are sure that we have ('httpModules',null) in
m_ItemsContainer.


Now m_ItemsContainer only modifications are:
0) m_ItemsContainer = new Hashtable (m_defCapacity, equality_comparer);

1) m_ItemsContainer.Clear ();

2) _Item newitem=new _Item(name, value);
m_ItemsContainer.Add(name,newitem);

3) m_ItemsContainer.Remove(name);

So there is no way there is ('httpModules',null) in m_ItemsContainer


Please someone tell me where i'm wrong

https://github.com/mono/mono/blob/master/mcs/class/System/System.Collections.Specialized/NameObjectCollectionBase.cs

Thanks
Etienne


2014-10-21 14:54 GMT+02:00 Etienne Champetier champetier.etie...@gmail.com
:


Hi,

At my firm we are running multiple webapplication using mono (nginx +
fastcgi-mono-server2.exe) on a cluster of 4 VM, 2 vcpus.
One of them is restarted every day at 1h45 (small memory leak).
3 weeks ago we went from 8VM with 1vcpu (no restart problem) to 4VM with
2vcpus, and now,
it's the 3rd time in 2 weeks that on one VM, the restart doesn't work well
and we have:

[System.ArgumentException]: Key duplication when adding: httpModules
   at System.Collections.Hashtable.PutImpl (System.Object key,
System.Object value, Boolean overwrite) [0x0] in filename unknown:0
   at System.Collections.Hashtable.Add (System.Object key, System.Object
value) [0x0] in filename unknown:0
   at System.Collections.Specialized.NameObjectCollectionBase.BaseAdd
(System.String name, System.Object value) [0x0] in filename unknown:0
   at System.Collections.Specialized.NameObjectCollectionBase.BaseSet
(System.String name, System.Object value) [0x0] in filename unknown:0
   at System.Configuration.ConfigurationSectionCollection.get_Item
(System.String name) [0x0] in filename unknown:0
   at System.Configuration.Configuration.GetSection (System.String path)
[0x0] in filename unknown:0
   at System.Web.Configuration.WebConfigurationManager.GetSection
(System.String sectionName, System.String path, System.Web.HttpContext
context) [0x0] in filename unknown:0
   at System.Web.Configuration.WebConfigurationManager.GetSection
(System.String sectionName, System.String path) [0x0] in filename
unknown:0
   at
System.Web.Configuration.WebConfigurationManager.GetWebApplicationSection
(System.String sectionName) [0x0] in filename unknown:0
   at System.Web.HttpApplication.InitOnce (Boolean full_init) [0x0] in
filename unknown:0


The really cool stuff is that even if it's a 500 error, the returned http
code is 200 :)

I've already checked and all files are equal (dll, exe, conf), all VM conf
are equal (vcpu, memory, ...), ...

I'm not able to reproduce the bug (restart under high load (ab -c 50 -n
10)) so can't tell if the bug is there in the newest version.

We are using a version of mono before 3.2.7
(92887027be801b012846866208e6b4e362a4fc24) and fastcgi-mono-server2 (xsp)
version 2.10.2-1 (old version build on 14/09/12 by someone at my firm)
I know we are using old version but it seems that the bug is still there:
https://bugzilla.xamarin.com/show_bug.cgi?id=18303

I've run lsof on the processes (the stuck one and one working), and by
comparing the 2, i see that App_global.asax_XXX.dll
is here in both case, but not  App_Web_.dll (only on the working
one) (see attachment)

I have root access on the VM with the stuck process, and i'm on irc right
now (champtar), so if you have some ideas to gather more info to kill this
bug

Thanks in advance

Etienne





___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list




___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Unit Testing process: Community Contributions

2014-10-21 Thread Robert Jordan

On 21.10.2014 13:05, Edward Ned Harvey (mono) wrote:

From: Miguel de Icaza [mailto:mig...@xamarin.com]

There is no need to presume, the actual issue was just articulated
on a thread, please read it.

Pull requests do not work well with Mono.   They need to be
discussed in the mailing list


Did I miss something?  Do you not recognize that there's a problem
here?

What are we supposed to do when we do all that stuff - discuss in
mailing list, pay for Xamarin, contact Xamarin support, file or find
bug in bugzilla, and even write our own patches and submit pull
request to solve our own problems, and then *still* nothing happens?


Please do not intermix the expectations/entitlements you've got for
being a paying customer of Xamarin with their Open Source efforts.

As long as the community isn't moving (or even fork, as a last resort)
things won't change substantially. Miguel has clearly stated
multiple times that there is enough room for involvement in some
areas (e.g. Server Stack), even commercially. I haven't seen anyone
stepping up so far, at least not here.

A few pull requests are not enough to show commitment and to take
ownership over a module/subsystem/whatever. Hackers are coming
and going, code is rotting away, Xamarin is collecting the garbage.
I guess they are tired of this ;)

On pull request discussions on this list: Assuming that core
devs are rather monitoring this list (I hope it's still the case),
I'd prefer this approach anytime to the discussion over at GitHub.
I've given up on reviewing because of this `media switch'.

Robert

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-list] System.IO.Package

2014-10-16 Thread Robert Jordan

On 16.10.2014 15:09, Maury Markowitz wrote:

So does anyone know of a PCL/Mono compatible ZIP library along those lines?


DotNetZip:

http://dotnetzip.codeplex.com/

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-dev] Resx files in Mono

2014-10-09 Thread Robert Jordan

On 08.10.2014 23:05, Martin Thwaites wrote:


I've tried adding a reference to it, and I can't find that assembly, even
in the mono directories.

So the question is, does compiling Resx files work in mono?



It does.

The long story: Microsoft has implemented the ResX support in
the System.Windows.Forms assembly (a GUI library) and reused
it from System.Web.

For compatibility reasons, Mono did the same (Mono's
System.Windows.Forms can be found in the Native.Windows.Forms
directory side-by-side with System.Web inside mcs/class).

However, since System.Windows.Forms is kinda unsupported
and deprecated under Mono, the team has begun including
the ResX source code directly into System.Web:

https://github.com/mono/mono/blob/master/mcs/class/System.Web/System.Web.dll.sources


What you can do is:

- install System.Windows.Forms. It's usually part of Mono
but your disto might have split it into its own package.

- build your aspnet update inside Mono mcs/class tree while
reusing the build infrastructure. Look at how Mono's System.Web
is built.

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-list] mono_runtime_invoke crash

2014-09-14 Thread Robert Jordan

On 13.09.2014 22:30, tbrooks wrote:

I've broken everything down to an extremely simple test, this crashes for me
about every other run with an access violation 0x0C (so a null pointer
somewhere in mono_runtime_invoke). It seems related to Console.WriteLine; if
it is removed the crashing stops.


You did not show us how you're initializing the runtime.

Maybe you didn't call mono_set_dirs () (it's likely required
under Windows, where you seem to test on) or
mono_config_parse (NULL) which initializes the DLL mapping.

Under Windows you could also end up with compiling your app
for the Windows subsystem which doesn't have a console.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-dev] mono_fntptr_to_delegate

2014-08-08 Thread Robert Jordan

Bruno,

Marshal.GetDelegateFromFunctionPointer() and mono_ftnptr_to_delegate
only work on functions with p/invoke-compatible signatures.

This means that you can't pass MonoObjects* to these functions.
You can only declare and pass p/invoke-compatible arguments.
There is also no *this* pointer available.

If you want a signature like this

MonoBoolean testMethod(MonoString *arg2)

then you must declare a C# helper for it:

namespace EmbeddingHelpers
{
class DelegateHelper
{
public static Funcstring, bool CreateDelegate()
{
return TestMethod;
}

[MethodImpl(MethodImplOptions.InternalCall)]
static bool extern TestMethod(string arg);
}
}

C++:

MonoBoolean TestMethodInternal(MonoString* arg)
{
return TRUE;
}

mono_add_internal_call(EmbeddingHelpers.DelegateHelper::TestMethod);



The delegate can be finally obtained from the static method
EmbeddingHelpers.DelegateHelper.CreateDelegate();

There might be better/elegant ways to do this, but they all
need an InternalCall declaration. There is no other way to tell
mono to wrap a native function to support native (embedded mono)
calls.


Robert

On 08.08.2014 19:29, Bruno Lauze wrote:

Hi,



I am sure someone can help me out. At one point this code did work. I
changed something and/or I just reinstalled latest trunk and it broke.

I am trying to pass C delegate to C#. Everything is working C# is calling
back the method but the parameters seems to be invalid pointers.

The C delegate was returning the delegate object, and the parameters.



I did put mono_ftnptr_to_delegate to external removing MONO_INTERNAL and
placing it under MONO_API.

One could use Marshal.GetDelegateFromPointer with mono_runtime_invoke
(Adding that way too at the bottom.)





Consider the following code:





DelegateHelper.dll: MyClass.cs:



using System;



namespace DelegateHelper

{

 public delegate bool TestDelegate(string arg1);



 public class MyClass

 {

 public static bool Test(TestDelegate predicate)

 {

 return predicate(TEST);

 }

 }

}





main.c:





#include stdio.h

#include glib.h

#include mono/jit/jit.h

#include mono/metadata/object.h

#include mono/metadata/reflection.h

#include mono/metadata/assembly.h

#include mono/metadata/threads.h

#include mono/metadata/mono-config.h



MONO_API MonoDelegate*

mono_ftnptr_to_delegate (MonoClass *klass, gpointer ftn);



MonoBoolean testMethod(MonoObject *arg1, MonoObject *arg2)

{

 printf(Calling delegate!);

 MonoString *str = mono_object_to_string(arg2, NULL); //crash

 return TRUE;

}



int main (int argc, char *argv[])

{

 printf (Delegate Test!\n);



 MonoDomain *domain = mono_jit_init_version(DelegateTest,
v4.0.30319);

 mono_config_parse(NULL);

 void *__parameters__[1];

 MonoAssembly *ass = mono_assembly_open(DelegateHelper.dll, NULL);

 MonoImage *image = mono_assembly_get_image(ass);

 MonoClass *delegateClass = mono_class_from_name(image,
DelegateHelper, TestDelegate);

 mono_class_init(delegateClass);

 MonoClass *testClass = mono_class_from_name(image, DelegateHelper,
MyClass);

 mono_class_init(testClass);

 gpointer ptr = (gpointer)testMethod;

 MonoDelegate *delegateObj = mono_ftnptr_to_delegate(delegateClass,
ptr); //Short way to call Marshal.GetDelegateFromFunctionPointer()

 MonoMethod *testMethod = mono_class_get_method_from_name(testClass,
Test, 1);

 __parameters__[0] = delegateObj;

 MonoObject *result = mono_runtime_invoke(testMethod, NULL,
__parameters__, NULL);

 return 0;

}





Result:



Delegate Test!

Calling delegate!

Stacktrace:



   at unknown 0x

   at (wrapper managed-to-native) object.wrapper_native_0x40ea40 ()
0x

   at DelegateHelper.MyClass.Test (System.Func`2string, bool) 0x00018

   at (wrapper runtime-invoke) Module.runtime_invoke_bool_object
(object,intptr,intptr,intptr) 0x



=

Got a SIGSEGV while executing native code. This usually indicates

a fatal error in the mono runtime or one of the native libraries

used by your application.

=



Abort





This code could be used instead of mono_ftnptr_to_delegate which is normally
internal



 /*

 MonoImage *mscorlib =
mono_assembly_get_image(mono_domain_assembly_open(domain, mscorlib));

 MonoClass *marshal = mono_class_from_name(mscorlib,
System.Runtime.InteropServices, Marshal);

 MonoMethod *getDelegate = mono_class_get_method_from_name(marshal,
GetDelegateForFunctionPointer, 2);

 void *marshal_params[2];

 marshal_params[0] = ptr;

  

Re: [Mono-list] Embedded API: calling explicit interface properties

2014-07-15 Thread Robert Jordan

On 15.07.2014 13:24, Jonathan Mitchell wrote:

Hi

I have a class that implements the following two interfaces and I am having 
trouble accessing explicit interface properties via the embedded API.
My unit tests fail (see below).

The explicit interface properties are found okay but the property assignment 
fails in a way which makes me think there is a parameter type problem.
Is there anything I should be aware of with regard to constructing the property 
access signature?
If I log the mono class method info it looks okay - again this is listed below.


IIRC, the name of properties (and methods) of explicit interfaces
must be prefixed with the interface name, e.g.:

[self getMonoProperty:IReferenceObject2_ExIntTestProperty]

I'm not sure about the delimiter, but I believe it's _.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-dev] Developing Mono

2014-05-13 Thread Robert Jordan

On 14.05.2014 00:55, Martin Thwaites wrote:

So I've given in, and I'm now looking at using linux (ubuntu 14.04) to try
and add some things to mono.

I have the same issues with loading the net_4_5.sln file in MD as I do in
VS, in that it won't compile.  I'm assuming that the solution itself is
just broken.

The main issue though is I've not found anything that could show me some
simple steps to how I should go about building and running tests.


http://www.mono-project.com/Test_Suite

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-list] The assembly mscorlib.dll was not found or could not be loaded

2014-05-13 Thread Robert Jordan

On 13.05.2014 11:28, cocowalla wrote:

I've discovered that mono is using mscorlib from `\lib\mono\4.5`, rather than
`\lib\mono\4.0`.

Now, `xbuild` is in `\lib\mono\4.5`, but my project targets .NET 4.0. Any
ideas as to what is going on here?



Try to preset a specific runtime version while running on the
slimmed down Mono:

mono --runtime=v4.0.30128 ...

or

mono --runtime=v4.0.20506 ...

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] The assembly mscorlib.dll was not found or could not be loaded

2014-05-13 Thread Robert Jordan

On 13.05.2014 14:56, cocowalla wrote:

I should have said I was using `--runtime=v4.0` when trying to run it.

I tried the 2 difference versions you suggested, but get this for both:

System.IO.FileNotFoundException: Could not load file or assembly
'System.Core, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' or one of its dependencies.
File name: 'System.Core, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'



Does it exist? Try

gacutil -l System.Core

and paste the output.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Get binary directory in an mkbundle'd app

2014-05-12 Thread Robert Jordan

On 10.05.2014 23:35, cocowalla wrote:

Yes, I'm afraid it's another mkbundle question :)

I have an mkbundle'd app, and I need to get the directory of the binary (on
Linux, if it matters).

`Assembly.GetExecutingAssembly().CodeBase` doesn't work - it gives the path
from where the binary was started, not the path in which the binary resides.

`AppDomain.CurrentDomain.BaseDirectory` doesn't work - it gives the path
from where the binary was started, not the path in which the binary resides.

`Assembly.GetExecutingAssembly().Location` doesn't work - it just gives the
binary name, rather than the path in which it resides.

How can I get the directory in which the binary actually resides?


On Linux, resolve the symlink /proc/self/exe either via p/invoke
of readlink(2), or using Mono.Posix.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Get binary directory in an mkbundle'd app

2014-05-12 Thread Robert Jordan

On 12.05.2014 11:25, cocowalla wrote:

Great, I'll give this a try!

Any idea how to achieve the same on Solaris?



Hmm, IIRC it's /proc/$pid/path/a.out where $pid
is the output of getpid(2).


BTW, I wonder how long it takes to figure out that mkbundle
is not suitable for complex applications :)

Did you consider the deployment of a slimmed down
version of Mono?

Robert



___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Creating a new AppDomain with mkbundle'd app

2014-05-07 Thread Robert Jordan

On 06.05.2014 23:15, cocowalla wrote:


Is it possible to create a new AppDomain with an mkbundle'd app?



In this particular case it's enough if the original assembly
exists in the file system. A 0 bytes file will do the trick.

You might want to file a bug stating that

System.Security.Policy.Hash.GetData()

is trying to access the assembly by its file name w/out
taking into account that assemblies might not have a
file representation.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] How to use SSL with HttpListener with an mkbundle'd Mono app

2014-04-23 Thread Robert Jordan

On 23.04.2014 13:40, cocowalla wrote:

I have a .NET application built with Mono, that I've bundled into a native
(Linux) executable using `mkbundle`. This is so that end users don't need to
mess around and install Mono themselves.

The application uses ServiceStack, which under the hood uses `HttpListener`.
I need the web services to be exposed over an SSL-enabled HTTP endpoint.

Normally, you would run something like `httpcfg -add -port 1234 -p12
MyCert.pfx -pwd MyPass` during configuration (all this really does is copy
the certificate to a specific path), and `HttpListener` would automatically
bind the certificate to the port.

So `HttpListener` loads certificates from a particular path at runtime.

Is that path hard-coded? Or is there some way I can tell it to use a
certificate from another location, since the end user will not have Mono
installed?


The path is hard-coded as ~/.mono/httplistener/

See https://github.com/mono/mono/blob/master/mcs/tools/security/httpcfg.cs


Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] mono-service for mkbundle'd apps?

2014-04-22 Thread Robert Jordan

On 20.04.2014 15:00, cocowalla wrote:

I have a Windows service that I want to run with Mono on Linux. I can run it
as a service using mono-service, and this works fine.

I also want to mkbundle the application to ease deployment for end-users, so
they don't need to faff about installing Mono themselves.

What is the recommended way to run the resulting native binaries as a
service on Linux?


You may want to try to bundle mono-service.exe together with
your service assemblies and provide a launcher script similar to
mono-service.

However, mkbundle was not designed for such (rather complex)
use cases, so your mileage might vary.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] mkbundle and reference assemblies

2014-04-22 Thread Robert Jordan

On 22.04.2014 17:01, Chris Tacke wrote:

I'm trying to mkbundle a pretty complex application that has a lot of reference 
assemblies, but mkbundle is having trouble finding those assemblies.

For example, here's part of the output:

--
root@WR-IntelligentDevice:/opt/SF# mkbundle SolutionEngine.exe --deps -o Engine 
-L /opt/SF


Try this as a workaround:

cd /opt/SF
mkbundle --deps -o Engine SolutionEngine.exe *.dll

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] How to pass an object as ref or out

2014-04-17 Thread Robert Jordan

On 17.04.2014 06:26, carmack2000 wrote:

Hi Robert,
Thanks for your tips but I still don't understand how to unbox a ref-type.
It looks mono_object_unbox only can handle valuetype, not ref-type.

So could you please write more lines of code of implementation for an
example for this void SetPosition(MonoString* ms, MonoObject** mo) ?


Well, I need more info to be able to do this. Right now,
you're declaring a managed ref object argument on your
InternalCall. This forces boxing on every value type
passed as an argument.

The naive implementation would look like this:

void SetPosition(MonoString* ms, MonoObject** mo)
{
Vector2 pos = *(Vector2*)mono_object_unbox(*mo);
}

This is no better than the former non-ref version.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] How to pass an object as ref or out

2014-04-17 Thread Robert Jordan

On 17.04.2014 16:55, carmack2000 wrote:

After I followed your code I got this error:
Unhandled exception at 0x100b8c87 in MonoScriptingTest.exe: 0xC005:
Access violation reading location 0x.
I'll look into this.

You said 'This is no better than the former non-ref version.' If I want to
use ref-object to return values (GetPosition), how can I get it ?

C#
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern void GetPosition(string name, ref Vector2 o)

C++: still doing like this ?
void GetPosition(MonoString* ms, MonoObject** mo)
{
 Vector2 pos = *(Vector2*)mono_object_unbox(*mo);
 pos.x = ; // Returned to the caller
 pos.y = ;
}


void GetPosition(MonoString* ms, Vector2 *vector)
{
vector-x = ...
}

It assumes that you have a C/C++ Vector2 declaration
that is fully layout-compatible with the managed version.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] How to pass an object as ref or out

2014-04-17 Thread Robert Jordan

On 17.04.2014 18:33, Robert Jordan wrote:

On 17.04.2014 16:55, carmack2000 wrote:

After I followed your code I got this error:
Unhandled exception at 0x100b8c87 in MonoScriptingTest.exe: 0xC005:
Access violation reading location 0x.
I'll look into this.

You said 'This is no better than the former non-ref version.' If I
want to
use ref-object to return values (GetPosition), how can I get it ?

C#
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern void GetPosition(string name, ref Vector2 o)

C++: still doing like this ?
void GetPosition(MonoString* ms, MonoObject** mo)
{
 Vector2 pos = *(Vector2*)mono_object_unbox(*mo);
 pos.x = ; // Returned to the caller
 pos.y = ;
}


void GetPosition(MonoString* ms, Vector2 *vector)
{
 vector-x = ...
}

It assumes that you have a C/C++ Vector2 declaration
that is fully layout-compatible with the managed version.

Robert


Additionally, to make this work Vector2 must be a value type,
but it seems to be one because otherwise you won't call
mono_object_unbox on it.

However, the thread's subject might imply that the above code
were suitable for object arguments. Of course it's not,
so caveat emptor.


Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Mono on wikipedia

2014-04-17 Thread Robert Jordan

On 17.04.2014 10:29, BrayanA wrote:

Hi,
in Companies Using Mono page of mono-project website
http://mono-project.com/Companies_Using_Mono

Wikipedia is listed under Web Projects Using Mono. This is the exact text:
WikiPedia uses Mono for its search facilities. The indexing and the actual
searching is done by Mono-based applications.

I want to ask is this still the case? If yes, does anyone know were I can
find the code of this Mono-based applications. Are they written in C#?


No idea where this code is, but odds are that they were using
Lucene.Net[1], an OSS search framework ported from Java.

Certain versions used to work under Mono w/out changes.

Robert

[1] https://lucenenet.apache.org/

___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] How to pass an object as ref or out

2014-04-16 Thread Robert Jordan

On 16.04.2014 22:31, carmack2000 wrote:

I use mono_object_unbox to get an object instance (Vector2) passed from C# to
C++.
C++
__declspec(dllexport) void SetPosition(MonoString* ms, MonoObject* mo)
{
Vector2 pos = *(Vector2*)mono_object_unbox(mo);
}

C#
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern void SetPosition(string name, object o)

If I need to pass an object as ref or out instead of value, how can I
implement it in C++ side ?

Like this sample, I want to pass object o as ref.
C#
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern void SetPosition(string name, ref object o)


void SetPosition(MonoString* ms, MonoObject** mo)
{
}

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-dev] .exe referencing itself ...

2014-04-10 Thread Robert Jordan

On 10.04.2014 13:59, etienne.champet...@free.fr wrote:


It's looking for itself ...
If I put it in the gac, it works, but is there a way to not put it in the gac?

I'm building it with xbuild /p:Configuration=Release /target:rebuild,
but it's the same with the Makefile (make install install it in the gac)


This is by design of System.Web. All assemblies a web app is referencing
must be either located in the GAC or in the bin directory of the
web app.

So you can copy (not move, as it must exit twice) this DLL into
bin directory of the web app.

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] .exe referencing itself ...

2014-04-10 Thread Robert Jordan

On 10.04.2014 15:03, Robert Jordan wrote:

On 10.04.2014 13:59, etienne.champet...@free.fr wrote:


It's looking for itself ...
If I put it in the gac, it works, but is there a way to not put it in
the gac?

I'm building it with xbuild /p:Configuration=Release /target:rebuild,
but it's the same with the Makefile (make install install it in the gac)


This is by design of System.Web. All assemblies a web app is referencing
must be either located in the GAC or in the bin directory of the
web app.

So you can copy (not move, as it must exit twice) this DLL into
bin directory of the web app.


s/DLL/exe/

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] ***UNCHECKED*** Re: Ongoing Mono development / Mono roadmap

2014-04-09 Thread Robert Jordan

On 09.04.2014 23:17, Alex J Lennon wrote:


A key component of what I was told toay is that Xamarin are unable to
work on Mono due to contractual obligations to Attachmate. As a
result they are (I am told) abandoning Mono and doing something
else which is the (presumably) VM underneath the Xamarin tooling.

I guess I'm looking for confirmation that either this is true, or
is some strange new form of FUD :) This comes from a discussion which
was originally about Microsoft open sourcing (ish, bits of) .Net.


The story you were told is incomplete. It turned out well:

http://tirania.org/blog/archive/2011/Dec-21.html
http://www.itworld.com/mobile-wireless/184215/xamarin-attachmate-band-together-mono

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-list] Regression in WinForms support

2014-04-09 Thread Robert Jordan

On 08.04.2014 11:40, Baltasar García Perez-Schofield wrote:

Hi, there.

While trying to execute my app using WinForms (created with Mono and
MonoDevelop, and working just right up until now), I have stumbled with
this, using Windows 7:

==
Unhandled exception:
...snip...
missing \tmp\lib\libgdiplus.so
==

I've installed the last version of Mono (3.2.3) from the mono webpage for
Windows. I've looked for help and found:

http://www.mono-project.com/DllNotFoundException

However, this only seems to apply to Linux distributions, not for Windows.
I suppose the DLL is not missing, since it should be using the one provided
by Windows.
Can I have some help?
Why did this work transparently in previous versions of Mono and now it
does not?


Because bugs happen :)


Locate $mono-prefix/etc/mono/config and add an os=!windows attribute
to all gdiplus  gdi32 DLL mapps.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Fun and games with Sqlite and System.Reflection

2014-04-09 Thread Robert Jordan

How about checking whether the IgnoreAttribute is applied to
the property?

for (int i = 0; i  properties.Length - 1; i++) {
// ignore props marked with [Ignore]
	if (properties[i].GetCustomAttributes(typeof(IgnoreAttribute), 
false).Length  0)

next;
}

Robert


On 09.04.2014 14:38, Paul Johnson wrote:

Hi,

I have a very simple SQLite database class which I'm using
System.Reflection to serialise and use within my DBManager class.

My class looks like this (it's a test case to try and get things working
before I integrate it)

public class dbclass
{
 [PrimaryKey]
 public string Id { get; set; }

 public string Test { get; set; }

 public DateTime Today { get; set; }

 [Ignore]
 public Liststring ListTest { get; set; }

 public override string ToString()
 {
 return string.Format([dbclass: Id={0}, Test={1},
ListTest={2}], Id, Test, ListTest);
 }
}
When I serialise this class, the Ignore attribute used for Sqlite is
ignored as it's not a System.Reflection attribute. Without it, the
ListT tries to be processed and causes the code to crash as it has
nothing in the database for it (and Lists are supported under SQlite
anyway!)

I've checked on MSDN and there doesn't seem to be an equivalent of the
Ignore attribute which is a bit of a pain.

Within my dbclass, is it possible to set the reflection attribute to
something so I can intercept and ignore the property I need to ignore
(in this case the List)?

My code that does the processing looks like this (no giggling at the back!)

using System;
using System.Collections.Generic;
using System.Reflection;
using System.Linq.Expressions;
using System.Text;
using SQLite;

public class dbclass
 {
 [PrimaryKey]
 public string Id { get; set; }

 public string Test { get; set; }

 public DateTime Today { get; set; }

 [Ignore]
 public Liststring ListTest { get; set; }

 public override string ToString()
 {
 return string.Format([dbclass: Id={0}, Test={1},
ListTest={2}], Id, Test, ListTest);
 }
 }

 class TestClass
 {
 public TestClass()
 {
 var db = new dbclass()
 {
 Id = Guid.NewGuid().ToString(),
 Test = Hello,
 Today = DateTime.Now
 };
 Console.WriteLine({0}, GetInsertQuery(db));
 }

 private readonly DictionaryType, FuncObject, String
queryBuilders = new DictionaryType, Funcobject, string();

 public string GetInsertQuery(Object entity)
 {
 var type = entity.GetType();
 if (!queryBuilders.ContainsKey(type))
 {
 var param = Expression.Parameter(typeof(Object),
entity);
 var typedObject = Expression.Variable(type, obj);
 var stringBuilder =
Expression.Variable(typeof(StringBuilder), sb);

 var appendString =
typeof(StringBuilder).GetMethod(Append, new[] { typeof(String) });
 var objectToString = typeof(Object).GetMethod(ToString);

 var code = new ListExpression();
 code.Add(Expression.Assign(typedObject,
Expression.Convert(param, type)));
 code.Add(Expression.Assign(stringBuilder,
Expression.New(typeof(StringBuilder;

 code.Add(Expression.Call(stringBuilder, appendString,
Expression.Constant(string.Format(INSERT INTO {0} (, type.Name;

 var properties = type.GetProperties();

 for (int i = 0; i  properties.Length - 1; i++)
 {
 code.Add(Expression.Call(stringBuilder,
appendString, Expression.Constant(properties[i].Name)));
 code.Add(Expression.Call(stringBuilder,
appendString, Expression.Constant(, )));
 }

 code.Add(Expression.Call(stringBuilder, appendString,
Expression.Constant(properties[properties.Length - 1].Name)));

 code.Add(Expression.Call(stringBuilder, appendString,
Expression.Constant() VALUES ()));

 for (int i = 0; i  properties.Length - 1; i++)
 {
 code.Add(Expression.Call(stringBuilder,
appendString, Expression.Constant(')));
 code.Add(Expression.Call(stringBuilder,
appendString, Expression.Call(Expression.Property(typedObject,
properties[i]), objectToString)));
 code.Add(Expression.Call(stringBuilder,
appendString, Expression.Constant(', )));
 }

 code.Add(Expression.Call(stringBuilder, appendString,
Expression.Constant(')));
 code.Add(Expression.Call(stringBuilder, appendString,
Expression.Call(Expression.Property(typedObject,
properties[properties.Length - 1]), objectToString)));
 code.Add(Expression.Call(stringBuilder, appendString,
Expression.Constant(', )));


Re: [Mono-list] Embedding Mono - A question about mono.dll

2014-03-10 Thread Robert Jordan

On 10.03.2014 06:34, KareemErgawy wrote:

Hi,
I want to use Mono as a scripting engine in a project (game engine) I am
working on. I started reading the guide at:
http://www.mono-project.com/Embedding_Mono. Starting with the first step
Compiling and Linking, I created the mono.lib file as instructed for the
Windows platform. My problem is that I can't find mono.dll. I downloaded and
installed Mono-3.2.3 and tried searching for the dll file but couldn't find
it. Sorry if this sound naive but I don't know what to do :(.


mono.dll was renamed to

libmonoboehm-2.0.dll  (Boehm Garbage Collector)

and

libmonosgen-2.0.dll(SGen Collector)

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-dev] Library path bug in Makefile?

2014-03-05 Thread Robert Jordan

On 05.03.2014 15:31, Edward Ned Harvey (mono) wrote:

It is a safe conclusion to draw, that *whatever* is specified by
--libdir=DIR, the binary should be linked against libraries in that
directory.  (If not specified, libdir is derived from
--exec-prefix=EPREFIX, which is derived from --prefix=PREFIX)


Non-default Mono installations still need LD_LIBRARY_PATH, otherwise
p/invoke of Mono libraries (libgdiplus, libMonoPosixHelper) won't
work because p/invoke is obeying the CLR rules of library look-up
that know nothing about ELF RPATH attributes.

Moreover, things like pkg-config need to be configured as well,
because they also know nothing about mono's executable RPATH.

The only thing you'd achieve by setting the RPATH attribute:
you won't be able to safely relocate Mono anymore, as RPATH
takes precedence over LD_LIBRARY_PATH.

Robert

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-list] Embedded API. Numeric Boxing and GC

2014-02-25 Thread Robert Jordan

On 25.02.2014 11:20, jonat...@mugginsoft.com wrote:

I box my numeric primitives using a macro:

#define DB_BOX_INT64( x ) ( mono_value_box(mono_domain_get(), 
mono_get_int64_class(), x) )


And use it like so:

1.

- (void)box
{
MonoObject *monoObject = DB_BOX_INT64(value);
}

I save the MonoObject * into a local variable. The collector will see the 
object on the stack and collect it only when the enclosing function completes.

2.
- (void)box:(long long)value
{
self.monoObject = DB_BOX_INT64(value);
self.gcHandle = mono_gchandle_new(self.monoObject, FALSE);
}

- (void)dealloc
{
mono_gchandle_free(self.gcHandle);
}

I save the MonoObject * into an instance variable. The collector will free the 
MonoObject after the call to mono_gchandle_free().

Is the above correct?


Not quite. Look at this line:

self.monoObject = DB_BOX_INT64(value);

There is a chance that the MonoObject* remains only reachable
from self.monoObject. This means that it might be GCed before
a handle could be taken from it.

Something along these lines should be safe:

MonoObject *obj = DB_BOX_INT64(value);
self.gcHandle = mono_gchandle_new(obj, FALSE);
self.monoObject = obj;


For the paranoid:

self.gcHandle = mono_gchandle_new(DB_BOX_INT64(value), FALSE);
self.monoObject = mono_gchandle_get_target(self.gcHandle);

:)

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-dev] Strange Crash with mono-3.2.3 + Qt-5.2.1

2014-02-17 Thread Robert Jordan

On 14.02.2014 21:35, Frank Fuchs wrote:

I first noticed with my Qt based application and a 64 bit build of
mono-3.2.3. However, I confirmed the very same problem with the offical
binary releases fo Qt-5.2.1 (mingw) and mono-3.2.3.

An application which embedds mono and initializes the runtime (which passes
without problems) like

mono_set_dirs(libs,etc);
domain = mono_jit_init (test);  

will crash upon opening a Qt file dialog. gdb reports the crash to occur in
rpcrt4.dll RpcCompleteAndFree (32 bit) and RpcEpRegisterNoReplaceW (64bit).
I'm not sure if this is any helpfull.

If there's something more you need to trace this problem, let me know how I
can help.


This looks like a COM problem to me (rpcrt4.dll does COM marshaling).

Odds are that Qt's file dialog is needing an STA (single thread
apartment) because it's somehow interacting with the Windows shell.

By default, Mono (and MS.NET) is initializing COM for multithreaded
concurrency (MTA) which may interact badly with STA COM objects
used by the Windows shell.

You may want to try to add an [STAThread] attribute to your Main
C# method.

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-aspnet-list] Mono keeps running old version, why?

2014-02-11 Thread Robert Jordan

On 11.02.2014 00:53, patrykmoura wrote:

After installed via whm (mono 2), ive installed mono via this post here (1st
answer):
http://stackoverflow.com/questions/13184384/mono-3-0-0-build-on-centos-6

But when i ran a .net 3.5 script, ive seen that the error cames up, and in
the footer i have this:

Version Information: 3.0.2 (tarball Wed Oct 2 21:25:24 EDT 2013); ASP.NET
Version: 2.0.50727.1433

Version ASP.NET 2.0... why???


Because .NET 3.5 is just an update of the stock .NET 2.0 runtime.

Robert


___
Mono-aspnet-list mailing list
Mono-aspnet-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-aspnet-list


Re: [Mono-dev] Windows.Forms broken on Windows

2014-02-02 Thread Robert Jordan

On 01.02.2014 20:27, Frank Fuchs wrote:

The offical mono-package (32 bit for Windows) from mono-project.com seem
broken when it comes to Windows.Form apps. I tested the following for
mono-3.0.10 and mono-3.2.3, with Windows 7 Professional 64bit.


using System;
using System.Windows.Forms;
class Hello{
static public void Main(){
MessageBox.Show(Hello World);
  }
}


and build  run it like:

./bin/mono.exe lib/mono/4.5/mcs.exe test.cs
-r:lib/mono/4.5/System.Windows.Forms.dll
./bin/mono.exe test.exe


This is caused by a wrong dll-map:

dllmap dll=gdiplus target=@prefix@/lib/libgdiplus@libsuffix@ /
dllmap dll=gdiplus.dll target=@prefix@/lib/libgdiplus@libsuffix@ /

in $prefix/etc/mono/config.

It should read

dllmap dll=gdiplus target=@prefix@/lib/libgdiplus@libsuffix@ 
os=!windows /
dllmap dll=gdiplus.dll target=@prefix@/lib/libgdiplus@libsuffix@ 
os=!windows  /


Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Windows.Forms broken on Windows

2014-02-02 Thread Robert Jordan

On 02.02.2014 15:12, Robert Jordan wrote:

This is caused by a wrong dll-map:

dllmap dll=gdiplus target=@prefix@/lib/libgdiplus@libsuffix@ /
dllmap dll=gdiplus.dll target=@prefix@/lib/libgdiplus@libsuffix@ /

in $prefix/etc/mono/config.

It should read

dllmap dll=gdiplus target=@prefix@/lib/libgdiplus@libsuffix@
os=!windows /
dllmap dll=gdiplus.dll target=@prefix@/lib/libgdiplus@libsuffix@
os=!windows  /


And it's already fixed on master:

https://github.com/mono/mono/blob/master/data/config.in

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-list] PDF generation

2014-01-10 Thread Robert Jordan

On 10.01.2014 13:21, jonat...@mugginsoft.com wrote:

What PDF manipulation libraries are currently used by the Mono community?

I have turned up:

1. itextsharp
2. pdfjet

The popular pdfsharp is, it would seem, .NET only.


iTextSharp can be used w/out any modifications under Mono. It just
works.

It's probably not surprising because it's a straight port of the
already platform-neutral Java iText.

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-dev] DllImport(__Internal) and libMonoPosixHelper static build

2014-01-03 Thread Robert Jordan

On 31.12.2013 10:34, mobin.seven wrote:

Same here! Did you solve it?

ralphbariz wrote

Hi,

I'm trying to compile a static one binary mono(Because the target system
has an incompatible loader).
First I got mono to build statically, but without libMonoPosixHelper in
the archive. After a few tries, I got also this, changed all
DllImport(MPH) calls in Mono.Posix.dll to DllImport(__Internal), it
still gives me a TypeInitializationexception when I try to access the stat
symbol of the libMonoPosixHelper. With objdump I looked inside, the
symbols of libMonoPosixHelper are all inside the archive, so what am I
doing wrong?


Your custom loader is supposed to support dlopen(NULL) and
your linker must be able to export public symbols.
See ld's --export-dynamic option.


Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-list] Data Protection

2014-01-03 Thread Robert Jordan

On 02.01.2014 15:15, Edward Ned Harvey (mono) wrote:

In Windows, it's well documented what and how the DPAPI works.  You
can protect (encrypt) data to a specific user account (or machine)...
And it's protected by the user's login credentials.

How does this work in mono?  If you use the ProtectedData class, how
secure is your data?  (Regular users, with linux or mac OSX)

Follow up question.  If you write a daemon or service (to run on
linux or windows server), which doesn't have clearly defined login
credentials etc, and you want to securely store some information,
would you use ProtectedData, or something else?


It depends on what kind of protection do you want to ensure.

Mono's ProtectedData implementation for Unix is storing the
involved keypairs in user's profile (~/.config/.mono/keypairs).
This means that at least the superuser will be able to access
these keys.

It also means that the current user must have a home directory,
unless you're working at machine scope where /usr/share/.mono/keypairs 
will be used.



Robert

___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] Mod_Mono crash * is not a valid virtual path - PLEASE help!

2013-12-19 Thread Robert Jordan

On 19.12.2013 03:56, acrym wrote:

Please help! I will take any advice or suggestions!


See https://bugzilla.novell.com/show_bug.cgi?id=509163

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] MKBundle and dllmaps

2013-12-18 Thread Robert Jordan

On 18.12.2013 13:10, James Nugent wrote:

Hi All,

I’m trying to build a package with mono statically linked - so far so good, I 
have an executable which works without mono being installed, but to achieve 
this I still need a dllmap for System.dll - currently that file looks like this:

$ cat System.dll.config
?xml version=1.0?
configuration
dllmap dll=libc target=libc.so.6 os=!windows/
/configuration


Is it possible to compile this in so that the file is unnecessary, accepting 
that the end result might not be portable across distributions or versions?



Yes. Use the --config option and pass in the system's default config
(it's usually $monoprefix/etc/mono/config).

Robert



___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] crash in mono_jit_cleanup

2013-11-17 Thread Robert Jordan

On 16.11.2013 17:26, jonat...@mugginsoft.com wrote:

My work around is to not call mono_jit_cleanup() at all.

I terminate Mono when I terminate my app so I presume that nothing untoward can 
occur.


If your app is depending on finalizers being executed at shutdown,
then in place of mono_jit_cleanup() you should call a managed method
that triggers a collection as a workaround:

GC.Collect ();
GC.WaitForPendingFinalizers();

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-dev] Socket.IsBound wrong behavior

2013-11-12 Thread Robert Jordan

On 12.11.2013 11:29, Stifu wrote:

Yeah, sometimes classes are in unexpected folders.
Socket isn't under System.Net, but just System, for some reason.


The reason is that Socket is implemented in the System assembly.

$(Assembly)/$(Namespace)/$(Class).cs

=

System/System.Net.Sockets/Socket.cs

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] mono mkbundle made file is Not working

2013-11-05 Thread Robert Jordan

On 03.11.2013 08:58, mobin.seven wrote:

I tried to bundle my app with mkbundle command due to this help:

http://www.mono-project.com/Guide:Running_Mono_Applications#Bundles
http://www.mono-project.com/Guide:Running_Mono_Applications#Bundles

but I don't understand this part of this doc:
With -c, the further option --nomain will generate the host.c file without
a main method so that you can embed it as a library in an existing native
application in which you are embedding the Mono runtime yourself. Just call
mono_mkbundle_init() before initializing the JIT to make the bundled
assemblies available.


This option is only useful if you want to link the bundle
with your own native application. Do you want this?


I have bundled an exe with all of its deps in Ubuntu via 'mkbundle' and it
works well there but when I move the bundle to lubuntu it won't work! when
executes nothing happens!
What should I do?


Mkbundle does not bundle native deps, e.g. GTK#, libgdiplus + its
myriad of deps. What kind of application are you trying to bundle?
GUI? Console?


Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] why does DateTime.Now.IsDaylightSavingTime() returns false when it should be true.

2013-10-28 Thread Robert Jordan

On 28.10.2013 07:35, Alistair Bush wrote:

I am trying to figure out why exactly running
DateTime.Now.IsDaylightSavingTIme() returns false.
I live in the Auckland/Pacific timezone and pretty much everywhere I
look it confirms that yes it is daylight saving time.


Unfortunately, I don't remember the details, but I'm pretty
sure that ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData
has a bug w/ respect to the Southern Hemisphere.

The code assumes that a year always begins outside a DST zone,
and this is obviously incorrect for the Southern Hemisphere.

To fix this, the local var is_daylight must be properly
initialized. Currently, it's always 0 at start, but it must
be initialized with 1 when January, 1st is inside a DST
zone.

Maybe this:

is_daylight = start.tm_isdst  0;

just before

/* For each day of the year, calculate the tm_gmtoff. */
for (day = 0; day  365; day++) {

Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-list] Embedded API: create System.NullableT

2013-10-24 Thread Robert Jordan

Jonathan,

On 23.10.2013 17:37, jonat...@mugginsoft.com wrote:

What is the recommended way to create an instance of a nullable type, such as 
System.Nullableint64?

I would prefer a method that used the embedded API as opposed to a C# helper 
method.



There is still no API for this, AFAIK, so you must resort to
using System.Type.MakeGenericType().

This is pretty much the same procedure as discussed here:

http://www.mail-archive.com/mono-list@lists.ximian.com/msg37275.html

Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-dev] Embedded API: mono_array_element_size issue

2013-10-02 Thread Robert Jordan

Jonathan,

On 02.10.2013 12:21, jonat...@mugginsoft.com wrote:

The following raises so I presume that I have used it incorrectly:

 MonoClass *arrayClass = mono_get_byte_class();
 int32_t elementSize = mono_array_element_size(arrayClass);

* Assertion at class.c:8201, condition `ac-rank' not met



This is because arrayClass is not the MonoClass of a MonoArray.

You need something like that:

// assign the mono array
uintptr_t byteLength = [self length];
MonoArray *monoArray = mono_array_new(mono_domain_get(), 
mono_get_byte_class(), byteLength);
int32_t elementSize = 
mono_array_element_size(mono_object_get_class((MonoObject*)monoArray);


Robert


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-list] [Mono-dev] Embedded API: mono_array_element_size issue

2013-10-02 Thread Robert Jordan

Jonathan,

On 02.10.2013 15:34, jonat...@mugginsoft.com wrote:


I am vaguely confused by the usage of the MonoClass here and elsewhere.
I have an object, monoArray, yet to query it I require a class reference.
This sort of logic wouldn't generally apply in an OOP environment (certainly 
not in Obj-C).
Generally, instances have a many to one relationship to their class.


This applies to Mono as well.



In the above example do all byte arrays share a MonoClass or is the class 
merely a struct configured for that particular array instance?


They do. You could use a slightly different approach to create arrays
that is more orthogonal to the MonoObject creation APIs:

1) obtain the MonoClass of an array with mono_array_class_get

2) create an instance of this array class with mono_array_new_full


Robert


___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


  1   2   3   4   5   6   7   8   9   10   >