How to Invoke ICorDebug - clr

In "MDbg Sample.zip" projects, invoke the function from COM Module as:
[ComImport, Guid("3D6F5F61-7538-11D3-8D5B-00104B35E7EF"), InterfaceType((short) 1)] public interface ICorDebug { ... } The question is where to find the Guid("3D6F5F61-7538-11D3-8D5B-00104B35E7EF"), i can not find it in the regedit, but how to connect the ICoreDebug interface with the COM module?

It's not in the registry. That guid is the IID, ICorDebug doesn't support remote access so there is no reason to register a stub/proxy against the interface.
How you get an instance depends on what versions of the runtime are installed, but these days "everyone" has CLRv4 installed, so you access via the ICLRMetaHost.
Use CLRCreateInstance to get an implementation of ICLRMetaHost
Use ICLRMetaHost to find the ICLRRuntimeInfo for the desired version of the runtime.
Use ICLRRuntimeInfo.GetInterface to request an implementation of ICorDebug using CLSID_CLRDebuggingLegacy.

Related

How do I subscribe to an event implemented in F# from a C# client?

How do I subscribe to an event implemented in F# from a C# client?
I have the following code:
_dispatcher.SignInRequested += StartActivity(typeof(SignInActivity));
This line results in the following error:
Error CS0012 The type 'FSharpHandler<>' is defined in an assembly that
is not referenced. You must add a reference to assembly 'FSharp.Core,
Version=3.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
I attempted to troubleshoot and found this:
However, I do not understand the answer. My events are defined under a namespace and not a module. Hence, me not understanding the reasoning of that discussion.
I then tried adding the following reference to my C# project:
FSharp.Core 4.0.0.1
and
FSharp.Core 3.1.2.5
However, I still receive the same error.
When managing Nuget packages, I do not see the version "3.3.1.0" listed as an option.
Implementation Details:
The signature of the signin event from the C# client is the following:
public event FSharpHandler<Unit> SignInRequested;
I actually declare the event as the following:
let signInRequested = new Event<_>()
Any suggestions?
You need to have a look at the CLIEventAttribute . Events declared from F# cannot be used from C# unless they are declared with this attribute.

StackExchange.Redis.IDatabase exists in two dlls

I installed Redis StackExchange nuget and things worked fine. But then I installed RedisSessionStateProvider nuget, which installed StackExchange.Redis.StrongName along with it.
Now I am getting the following error,
Error 107 The type 'StackExchange.Redis.IDatabase' exists in both
'e:\Source\packages\StackExchange.Redis.1.0.481\lib\net45\StackExchange.Redis.dll'
and
'e:\Source\packages\StackExchange.Redis.StrongName.1.0.481\lib\net45\StackExchange.Redis.StrongName.dll' E:\Source\MyApp\Helpers\RedisHelper\StackExchangeRedisExtensions.cs 13 37 MyApp
Why is this?
There's a lot of confusion between the strong-named dll and the non-strong-named dll namespaces.
You can easily solve this by using extern alias.
Right click on project references and pick the dll you want to refer, go to properties window. Then, change the Aliases field value to anything you want. E.g: "Redis".
Then go to your consumer source-file and add:
extern alias Redis;
using System;
// ... other references
using Redis::StackExchange.Redis;
namespace Foo
{
public class Program
{
public static void Main(string[] args)
{
using (ConnectionMultiplexer connection = ConnectionMultiplexer.Connect("myConn"))
{
// use StackExchange API here.
}
}
}
}
There's also an issue on StackExchange's repository explaining more about StrongName vs Non-StrongName.
Some methods/properties/interfaces are duplicated in above 2 dlls.
Remove StackExchange.Redis reference to resolve errors.
I faced this issue in an ASP.NET Core app, and this answer solved my issue quickly.

Failed to resolve type Cirrious.MvvmCross.Plugins.File.IMvxFileStore in iOS

After registering File and Json plugins I get "Failed to resolve type Cirrious.MvvmCross.Plugins.File.IMvxFileStore." I am not registering a custom MvxFileStore, but the default implementations.
Reading the documentation once those two plugins are loaded I should get a registered implementation for IMvxFileStore (https://github.com/MvvmCross/MvvmCross/wiki/MvvmCross-plugins#file)
My registration of the plugins is the following:
Bootstrap folder
public class FilePluginBootstrap :
MvxLoaderPluginBootstrapAction<PluginLoader, Plugin>{}
public class JsonPluginBootstrap :
MvxPluginBootstrapAction<PluginLoader>{}
Is there anything I can do to confirm the plugins are loaded? Application Output doesn't show any errors trying to load plugins.
Small but important detail is not to forget to call base.PerformBootstrapActions() in Setup.cs.

java.io.InvalidObjectException with JMX MXBean with CompositeData

I am trying to publish an MXBean to JMX but I am getting the following stack when I start the program and the bean is being published:
Caused by: java.io.InvalidObjectException: Do not know how to make a javax.management.openmbean.CompositeType from a CompositeData: no method from(CompositeData); no constructor has #ConstructorProperties annotation; does not have a public no-arg constructor; not an interface
at com.sun.jmx.mbeanserver.OpenConverter.invalidObjectException(OpenConverter.java:1403)
at com.sun.jmx.mbeanserver.OpenConverter$CompositeConverter.makeCompositeBuilder(OpenConverter.java:891)
at com.sun.jmx.mbeanserver.OpenConverter$CompositeConverter.checkReconstructible(OpenConverter.java:897)
at com.sun.jmx.mbeanserver.OpenConverter$CompositeBuilderCheckGetters.applicable(OpenConverter.java:1034)
at com.sun.jmx.mbeanserver.OpenConverter$CompositeConverter.makeCompositeBuilder(OpenConverter.java:868)
... 48 more
Now I now that MXBeans are only supposed use OpenMbean types as per the documentation but my class is only using java.lang.String and javax.management.openmbean.CompositeData, so I do not know why it is failing. The interface is:
import javax.management.MXBean;
import javax.management.openmbean.CompositeData;
#MXBean
public interface JmxAdministrationApi {
String synchronize(CompositeData clientInfo);
}
It is worth noting that the bean was being published correctly until I added the CompositeData parameter (i.e. with no parameters), and only then did this error occur.
Any help with this would be greatly appreciated.
Thanks in advance,
Rob
Edit: also, we are using Spring JMX
You shouldn't be using CompositeData directly even though the documentation sounds like you should. The MXBean will take care of converting a proprietary data type into a CompositeData instance and back automatically.
Take a look at the samples provided in the documentation to see how you should use #ConstructorProperties annotation to make your data type play nicely with composite data and MXBeans.
-JB-

F# AsyncWaitOne and AsyncReadToEnd

I am working ti old F# code from Expert F#. However, the example doesn't build anymore.
The following two calls don't seem to exist:
semaphore.AsyncWaitOne(?millisecondsTimeout=timeout)
and
reader.ReadToEndAsync()
Does anyone know what these have been replaced with or if I am just missing a reference?
It's now called Async.AwaitWaitHandle.
AsyncReadToEnd is in the F# PowerPack.
By now, FSharp PowerPack project has been broken up into smaller modules for any further development.
Specifically, the AsyncStreamReader class and the extension methods for the reading from a StreamReader, WebClient, etc. the new project is FSharpx.Async.
1) AsyncWaitOne is now called Async.AwaitWaitHandle.
2) AsyncReadToEnd() extension method does not exists anymore in the FSharp.PowerPack.
It has been replaced with the AsyncStreamReader dedicated type that contains proper asynchronous implementation of stream reading (like ReadToEnd, ReadLine, etc.)
It can be used like that:
async {
use asyncReader = new AsyncStreamReader(stream)
return! asyncReader.ReadToEnd() }
Note: Once you have installed FSharp.PowerPack, the AsyncStreamReader type will be 'injected' in the Microsoft.FSharp.Control namespace

Resources