Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

returning dynamic variables from functions hangs the code #241

Open
muenchris opened this issue Nov 12, 2022 · 4 comments
Open

returning dynamic variables from functions hangs the code #241

muenchris opened this issue Nov 12, 2022 · 4 comments

Comments

@muenchris
Copy link

Describe the bug
I have a function call that returns a dynamic variable:

            dynamic appSettings = GetAppSettingsObject();
            if (appSettings == null) //<- it never reaches this code
            {
                return false;
            }

        static dynamic GetAppSettingsObject()
        {
            dynamic appSettings = null;
            try
            {
                Assembly configManagerAssembly = null;
                try
                {
                    configManagerAssembly = Assembly.Load("System.Configuration.ConfigurationManager, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
                }
                catch { 
                    //intent
                }
                if (configManagerAssembly != null)
                {
                    var configManagerType = configManagerAssembly.GetType("System.Configuration.ConfigurationManager", false);
                    if (configManagerType != null)
                    {
                        try
                        {
                            appSettings = configManagerType.GetProperty("AppSettings")?.GetValue(null);
                        }
                        catch { 
                            //intent
                        }
                    }
                }
                Console.WriteLine($"GASO 3.5 {Assembly.GetEntryAssembly()?.Location}"); //<- here its still alive
                return null; //Either this is not called or 
            }
            catch { 
                //intent
            }
            return appSettings;
        }

even is "null" is supposed to be returned, the function never actually returns.
To Reproduce
Steps to reproduce the behavior:
Compile code above and run it

Expected behavior
at least with null returned the code should continue

Screenshots

Developer tools (please complete the following information as best as you can):

  • Windows 11
  • Visual Studio 2022 17.4
  • VS 2022 Tools for Meadow v0.90.9

Meadow (please complete the following information as best as you can):
Most of these vaues can be found by running meadow device info using the Meadow CLI.

  • Meadow hardware version: F7v1.c
  • Meadow OS version: 0.9 (RC)
@bryancostanich
Copy link
Contributor

Great bug report!

@nealef
Copy link

nealef commented Jul 3, 2023

I created a patch to our mono implementation that addressed dynamic calls as they didn't work at all. They should be part of the current release. Would you be able to give that a test drive?

@adrianstevens
Copy link

For viz - I had to install Microsoft.CSharp in order to compile with the above code

@adrianstevens
Copy link

And hit this error:

GASO 3.5 /meadow0/Meadow.dll
cant resolve internal call to "System.Runtime.InteropServices.Ma
rshal::IsComObject(object)" (tested without signature also)

Your mono runtime and class libraries are out of sync.
The out of sync library is: /meadow0/mscorlib.dll

When you update one from git you need to update, compile and ins
tall
the other too.
Do not report this as a bug unless you're sure you have updated 
correctly:
you probably have a broken mono install.
If you see other errors or faults after this message they are pr
obably related
and you need to fix your mono install first.
cant resolve internal call to "System.Runtime.InteropServices.Ma
rshal::IsComObject(object)" (tested without signature also)

Your mono runtime and class libraries are out of sync.
The out of sync library is: /meadow0/mscorlib.dll

When you update one from git you need to update, compile and ins
tall
the other too.
Do not report this as a bug unless you're sure you have updated 
correctly:
you probably have a broken mono install.
If you see other errors or faults after this message they are pr
obably related
and you need to fix your mono install first.
[core] App Error in App Run:  assembly:<unknown assembly> type:<unknown type> member:(null)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants