Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6908679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:35:36+00:00 2026-05-27T08:35:36+00:00

yes I know, this seems to be the same question as asked thousands of

  • 0

yes I know, this seems to be the same question as asked thousands of times before.
But no, it’s not really – at least I think so.

I use IronPython and want to call a C# method:

bool GetClassInstance<T>(out T myClassInstance)

Calling this function via python would look like:

myClassInstance = None
myInstance.GetClassInstance[ClassType](myClassInstance)

The problem is following error message:

expected StrongBox[ClassType], got NoneType (ArgumentTypeException)

Now I do have two questions:

  • Is it possible to get this to run?
  • How???

Thanks a lot!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:35:37+00:00Added an answer on May 27, 2026 at 8:35 am

    To call methods that have out parameters, just omit the argument (as you’re not really passing a value) and its return value will be a tuple with the result of the function (if it was non-void) and the out values in the order they are defined.

    In the case of ref parameters, pass in the argument and it will still be returned in the tuple. Any mutations on the object will work as expected.

    e.g.,

    >>> from System import Int32
    >>> Int32.TryParse('12345')
    (True, 12345)
    >>> Int32.TryParse('12345x')
    (False, 0)
    

    Here’s a test I did so you could see how to call the different variations.

    namespace TestLibrary
    {
        public class Test
        {
            public static void Test1(out int b)
            {
                b = 1;
            }
    
            public static bool Test2(out int b)
            {
                b = 2;
                return b == 2;
            }
    
            public static void Test3(int a, out int b, int c)
            {
                b = a + c;
            }
    
            public static bool Test4(int a, out int b, int c)
            {
                b = a + c;
                return b == 4;
            }
    
            public static void Test5(int a, out int b, int c, out int d)
            {
                b = a + c;
                d = a * c;
            }
    
            public static bool Test6(int a, out int b, int c, out int d)
            {
                b = a + c;
                d = a * c;
                return b == 6 || d == 6;
            }
    
            public static void Test7(int a, out int b, int c, out int d, ref int e)
            {
                b = a + c;
                d = a * c;
                int oldE = e++;
                Console.WriteLine("\"{0}\" -> \"{1}\"", oldE, e);
            }
    
            public static bool Test8(int a, out int b, int c, out int d, ref int e)
            {
                b = a + c;
                d = a * c;
                int oldE = e++;
                Console.WriteLine("\"{0}\" -> \"{1}\"", oldE, e);
                return b == 8 || d == 8 || oldE == 8;
            }
    
            public static bool Test9(int a, out int b, int c, out int d, ref int e, ref int[] f)
            {
                b = a + c;
                d = a * c;
                int oldE = e++;
                Console.WriteLine("\"{0}\" -> \"{1}\"", oldE, e);
                f = f ?? new int[0];
                for (int i = 0; i < f.Length; i++)
                    f[i] = i;
                return b == 8 || d == 8 || oldE == 8;
            }
        }
    }
    
    >>> from TestLibrary import Test
    >>> Test.Test1()
    1
    >>> Test.Test2()
    (True, 2)
    >>> Test.Test3(1, 3)
    4
    >>> Test.Test4(1, 3)
    (True, 4)
    >>> Test.Test5(1, 3)
    (4, 3)
    >>> Test.Test6(1, 3)
    (False, 4, 3)
    >>> Test.Test7(1, 3, 5)
    "5" -> "6"
    (4, 3, 6)
    >>> Test.Test8(1, 3, 5)
    "5" -> "6"
    (False, 4, 3, 6)
    >>> from System import Array
    >>> array = Array.CreateInstance(int, 10)
    >>> array
    Array[int]((0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
    >>> Test.Test9(1, 3, 5, array)
    "5" -> "6"
    (False, 4, 3, 6, Array[int]((0, 1, 2, 3, 4, 5, 6, 7, 8, 9)))
    >>> array
    Array[int]((0, 1, 2, 3, 4, 5, 6, 7, 8, 9))
    

    Alternatively if you wanted to use the C# style call, you need to pass in a clr.Reference[T] object in place of the out/ref parameter to hold the value. You can access that value through the Value property.

    >>> outval = clr.Reference[int]()
    >>> Test.Test1(outval)
    >>> outval
    <System.Int32 object at 0x000000000000002B [1]>
    >>> outval.Value
    1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Yes, I know this seems like the same question yet again, but give me
First, yes I know about this question , but I'm looking for a bit
I know the Sales pitch answer is yes to this question, but is it
Before you tell me that there is already a similar question, yes, i know,
I'm working with a large (270+ project) VS.Net solution. Yes, I know this is
I can't find a straightforward yes or no answer to this! I know I
(Yes I know I can call Java code from Scala; but that is pointless;
This has to be a dumb question, but I can't seem to find the
I'm not sure exactly what went wrong here, but ReSharper 4.5 RTM seems to
I figure this is a straight forward question, and I think there is a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.