User Tag List

Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 22

Thread: Trying to use the DLL Object to call a C sharp assembly...

  1. #1
    Clicker Multimedia Fusion 2 DeveloperInstall Creator Pro

    Join Date
    May 2010
    Posts
    536
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Trying to use the DLL Object to call a C sharp assembly...

    Hey, folks!

    I'm trying to use a C Sharp assembly which a developer wrote for me which checks which whether the currently logged on user has three particular user right assignments my company's software requires to function properly. The function returns false if it can't retrieve the user rights; otherwise it returns true. If it returns false, an error message is saved in an output string called "errormsg".

    The sample code to call the C Sharp assembly looks like this:

    bool bLogAsBatch = false;
    bool bLogOnAsService = false;
    bool bActAsPartOfOS = false;
    string errormsg = string.Empty;
    bool bRetVal = false;
    bRetVal = InstallerHelper.Helper.CheckUserRights(ref bLogAsBatch, ref bLogOnAsService, ref bActAsPartOfOS, out errormsg);


    When I asked what is the function I need to call in the DLL file, I received this response:

    CheckUserRights(ref bool bLogOnAsBatch, ref bool bLogOnAsService, ref bool bActAsPartOfOS, out string errormsg);


    I also received the following information:

    The return value is of boolean type, i.e. the value is either true or false.
    The four parameters are
    - Boolean type: bLogOnAsBatch
    - Boolean type: bLogOnAsService
    - Boolean type: bActAsPartOfOS
    - String type: erromsg

    When you call it in the code, the syntax will look like or similar to
    Bool bRet = InstallerHelper.Helper.CheckUserRights(ref bLogOnAsBatch, ref bLogOnAsService, ref bActAsPartOfOS, out errormsg);


    Unfortunately, I don't know how to use this information with the DLL Object, and the developer doesn't know how to use MMF2.

    How can I use the DLL object with this DLL file? (I have attached the DLL file to this post.) Alternatively, is there an easier way to determine if the current Windows account user has specific user assignment rights (as specified from Locall Security Policy > Local Policies > User Right Assignment in Administrative Tools)?

    (I post such weird problems, don't I?...)

    Thank you very much in advance for your help!
    Attached files Attached files

  2. #2
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    The DLL object can only call functions written in C or C++. You'll need an in-between DLL that can interface with the C# DLL.
    Working as fast as I can on Fusion 3

  3. #3
    Clicker Multimedia Fusion 2 DeveloperInstall Creator Pro

    Join Date
    May 2010
    Posts
    536
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, thanks, LB! At leas I can stop pursuing this attempt to find a solution to my problem.

  4. #4
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export ModuleXNA Export Module

    Join Date
    Jul 2010
    Location
    Italy
    Posts
    368
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried using the .NET Scripting extension? With that you can call functions of a C# script.

  5. #5
    Clicker Multimedia Fusion 2 DeveloperInstall Creator Pro

    Join Date
    May 2010
    Posts
    536
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, K1kk0z90! I have tried using the .NET Scripting extension, but it always crashes on me (even though I have .NET Framework 3.5 SP1 installed on the computer running MMF2). I'm not sure why that extension isn't working.

  6. #6
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export ModuleXNA Export Module

    Join Date
    Jul 2010
    Location
    Italy
    Posts
    368
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Strange... if I remember correctly it uses .NET Framework 2.0, so you definitely have no problems for that. Have you tried reinstalling that extension? Maybe you're using an old version, or it could be happened an error while copying the extension files in the MMF folders.

  7. #7
    Clicker Multimedia Fusion 2 DeveloperInstall Creator Pro

    Join Date
    May 2010
    Posts
    536
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah ha! I used ExtensionView to download, then re-install the .NET Scripting extension, and found that it didn't crash MM2 once I placed the extension into my project! Progress!...

    So, now that I have this C Sharp DLL file, and my developer offered sample code how it would be called in C Sharp:

    bool bLogAsBatch = false;
    bool bLogOnAsService = false;
    bool bActAsPartOfOS = false;
    string errormsg = string.Empty;
    bool bRetVal = false;
    bRetVal = InstallerHelper.Helper.CheckUserRights(ref bLogAsBatch, ref bLogOnAsService, ref bActAsPartOfOS, out errormsg);


    Would I copy-and-paste this code into the .NET Script extension, then click "Compile"? Or how would I use this DLL file with the .NET Script extension?

    Thanks for your great assistance!

  8. #8
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export ModuleXNA Export Module

    Join Date
    Jul 2010
    Location
    Italy
    Posts
    368
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great that now it works!
    Now, in the .NET Scripting extension window, click on the tab References. You should see some already included dll files like System.dll, System.Data.dll, etc...
    Click on the "..." button below and browse for your dll. When selected click "Add reference".
    Now go to the Code tab, and write a function that calls the DLL:
    Code:
    public class CallDllClass
    {
        public static bool CallDll()
        {
            bool bLogAsBatch = false;
            bool bLogOnAsService = false;
            bool bActAsPartOfOS = false;
            string errormsg = string.Empty;
            bool bRetVal = false;
            bRetVal = InstallerHelper.Helper.CheckUserRights(ref bLogAsBatch, ref bLogOnAsService, ref bActAsPartOfOS, out errormsg);
            return bRetVal;
        }
    }
    In the Startup object textbox above write the name of the class (in this case "CallDllClass").
    Try to compile the code clicking on the "Compile" button: if there are no errors you have no problems.
    In a MMF event, use the "Call function" action of the .NET Scripting object with these parameters:
    Function name: "CallDllClass.CallDll"
    Parameters: ""

    I haven't tried with a DLL, but it should work. Otherwise write here what errors you get.

  9. #9
    Clicker Multimedia Fusion 2 DeveloperInstall Creator Pro

    Join Date
    May 2010
    Posts
    536
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, k1kk0z90! Thank you so much for all your help with this!

    Well, so far so good! I received no compilation errors... Furthermore, when I run the build, it builds correctly. So, more progress!

    Now, as per my developer's instructions, I need to determine whether the three parameters representing the user right assignments pass TRUE or FALSE; and if FALSE, then view the error string (as described below from my developer):

    • The function checks the user rights of the current logged in user on the local machine.
    • The function returns false if it fails to retrieve the user rights, and returns true otherwise.
    • When the function returns false, the error message is saved in the output parameter errormsg.
    • Check for the values of bLogAsBatch, bLogOnAsService, and bActAsPartOfOS in your code. If any of them is false, construct the error msg in your code and display it to the user.


    How would I construct such events?

  10. #10
    Clicker Multimedia Fusion 2 DeveloperInstall Creator Pro

    Join Date
    May 2010
    Posts
    536
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've been working on this with my developer, and while we've made some progress in troubleshooting, we do not seem to be actually calling a function from the C# DLL file...

    As you described I have referenced the DLL file from the .NET Script extension, then successfully compiled the following code:

    public class CallDllClass
    {
    public static bool CallDll()
    {
    bool bLogAsBatch = false;
    bool bLogOnAsService = false;
    bool bActAsPartOfOS = false;
    string errormsg = string.Empty;
    bool bRetVal = false;
    bRetVal = InstallerHelper.Helper.CheckUserRights(ref bLogAsBatch, ref bLogOnAsService, ref bActAsPartOfOS, out errormsg);
    return bRetVal;
    }
    }


    I have "CallDllClass" in the "Startup Object" field.

    Lastly, I have in a Start Frame event, I have the following 2 actions:
    1.) Clear Runtime Errors
    2.) Call function "CallDllClass.CallDll" with no parameters.

    I then set up an event "At Runtime Error" to exit the application as a quick way to determine if the C# runs properly.

    At run-time, it seems there always is an error because the application exits. My developer wanted to see if the function within the DLL file was being called, we ran the free DebugView program to capture what is happening. From DebugView, we don't see the function being called. So, we began wondering if we were doing this correctly, and why there seemed to be an error when the function doesn't seem to be called (unless not properly calling a function is an error).

    So, this leads to a few questions:
    1.) How can I tell if the function is being called?
    2.) How can I specify (or capture) returned values?
    3.) If an error occurs, how can I determine what caused the error? Can error messages be more granular?
    4.) In general what might I be doing wrong?

    Thank you again for all your help!

Page 1 of 3 1 2 3 LastLast

Similar Threads

  1. Replies: 3
    Last Post: 23rd September 2013, 04:39 PM
  2. Make a Call without "Call Phone" permission?!?
    By StingRay in forum Android Export Module Version 2.0
    Replies: 4
    Last Post: 21st April 2013, 09:35 AM
  3. LOAD ON CALL for active object
    By stillhawk in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 14th April 2011, 02:14 AM
  4. Javascript call with JS Object as parameter
    By netninja in forum SWF/Flash Export Module Version 2.0
    Replies: 2
    Last Post: 19th July 2010, 03:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •