This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Help request for GitHub sample UsingManagedAssemblies

Hello everyone,

I would like to create an UI extension add-on for M-Files, but I am new to developing for M-Files,
so I decided to start with adjusting the sample code and see where it gets me.

1. I downloaded UsingManagedAssemblies sample from github:
https://github.com/M-Files/MFilesSamplesAndLibraries/tree/master/Samples/UIX%20Applications/UsingManagedAssemblies
2. I zipped the contents of uix folder and installed it to [color=blue]MyVault[/color] using the M-Files Admin tool.
3. Upon entering [color=blue]MyVault[/color] using the M-Files Online explorer, I got a popup window stating: "MyVault says Hello!".
4. I was happy to have successfully installed and ran the sample add-on!

Next, I wanted to add an extra method to the:

Class1.cs file:

public class Class1 {
public void ShowMessage(Int32 parentHWND, string message, dynamic vault) {
// Get a reference to the window from the provided handle.
IWin32Window parentWindow = Control.FromHandle((IntPtr)parentHWND);

// Show the message.
MessageBox.Show(parentWindow, $"{vault.Name} says {message}");
}

public string GetString() {
return "GetString()";
}
}


main.js file:

function getShellFrameStartedHandler(shellFrame) {
return function() {
var clrObject = MFiles.CreateObjectCLR( "MyClassLibrary.dll", "MyClassLibrary.Class1" );
        var myString = clrObject.GetString();
clrObject.ShowMessage( shellFrame.OuterWindow.Handle, "Hello!", shellFrame.ShellUI.Vault );
};
}


So that I can use myString value instead of the hardcoded: "Hello!" string in the line:
[size=12pt]clrObject.ShowMessage( shellFrame.OuterWindow.Handle, "Hello!", shellFrame.ShellUI.Vault );[/size]
(I did not change the "Hello!" string for myString variable yet. I only added the var myString = clrObject.GetString(); into the main.js file)

I zipped the new .dll and main.js together with appdef.xml into a .zip file and installed it onto [color=blue]MyVault[/color] again.

Upon opening [color=blue]MyVault[/color] using the M-Files Online explorer I get the following error message:
https://imgur.com/a/2iIT4zg
(The green text is my translation for you)
With the following details:
CoScriptDelegate_Events.cpp, 396, Objekt nepodporuje t?to vlastnosť alebo met?du (0x80040008)
IDispatchInvocation.cpp, 96, Objekt nepodporuje t?to vlastnosť alebo met?du (0x80040008)
Managed Assemblies: main.js, 49, Objekt nepodporuje t?to vlastnosť alebo met?du (0x80040008)
MErrorHelper.cpp, 2457, Objekt nepodporuje t?to vlastnosť alebo met?du (0x80040008)
(M-Files 20.1.8669.3)


Does anyone know what is the problem?
What am I doing wrong?


The uix.zip can be found in the attachments.
uix.zip
Parents
  • I am a student of Creative Media and Game Technologies degree and two weeks ago I started to work on my graduation internship.
    (Deliverables: written report & meaningful product)

    Which leads me to the reason why I want to use managed assemblies together with M-Files:

    I have a SFML/OpenGL/C++ backend which is going to take care of visualizing M-Files metadata in 3D.
    This backend is wrapped in C++/CLR and imported into a C# project as a .dll.
    Next, I will be building this C# project into a .dll so that I can connect it with M-Files the way we have been discussing in these posts.
    This is the state of my research so far.

    Next to come:
    1. I still have to find out how to properly receive metadata from [color=blue]MyVault[/color] and send it over to the 3D visualizer, so that it can adjust.
    2. Another requested feature is to be able to pass adjusted or new data (documents, reports, relationships) from the 3D environment into [color=blue]MyVault[/color].
    3. Last preferred feature is to have this 3D representation rendered inside of M-Files on one of the tabs.
    (If this is not possible, 3rd party window will do, but if it is possible, but hard, I will give it a go!)

    Please have a look at the 3. one and let me know if this is even possible with what M-Files has to offer, if you will.
    (All I would need is the TAB (window) handle to render to. By TAB I mean a tab such as the Metadata tab in M-Files Desktop Client)

    I am not yet sure if managed assemblies are the way to go in order to assure these two main features, but here I am to find out.
    If you perhaps get what I aim for and see where I could change the track, do not hesitate to give me a pointer.
Reply
  • I am a student of Creative Media and Game Technologies degree and two weeks ago I started to work on my graduation internship.
    (Deliverables: written report & meaningful product)

    Which leads me to the reason why I want to use managed assemblies together with M-Files:

    I have a SFML/OpenGL/C++ backend which is going to take care of visualizing M-Files metadata in 3D.
    This backend is wrapped in C++/CLR and imported into a C# project as a .dll.
    Next, I will be building this C# project into a .dll so that I can connect it with M-Files the way we have been discussing in these posts.
    This is the state of my research so far.

    Next to come:
    1. I still have to find out how to properly receive metadata from [color=blue]MyVault[/color] and send it over to the 3D visualizer, so that it can adjust.
    2. Another requested feature is to be able to pass adjusted or new data (documents, reports, relationships) from the 3D environment into [color=blue]MyVault[/color].
    3. Last preferred feature is to have this 3D representation rendered inside of M-Files on one of the tabs.
    (If this is not possible, 3rd party window will do, but if it is possible, but hard, I will give it a go!)

    Please have a look at the 3. one and let me know if this is even possible with what M-Files has to offer, if you will.
    (All I would need is the TAB (window) handle to render to. By TAB I mean a tab such as the Metadata tab in M-Files Desktop Client)

    I am not yet sure if managed assemblies are the way to go in order to assure these two main features, but here I am to find out.
    If you perhaps get what I aim for and see where I could change the track, do not hesitate to give me a pointer.
Children
No Data