Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Problem with nullable property of object

$
0
0
Null in .NET and Null in VbScript are not similar things.
Suppose you have code that concatenate strings and one of them is null.
In case of VBScript the result string is null (because ClearScript instead of VT_EMPTY return VT_NULL) and in .NET is not.
Marshall behaviour of ClearScript is different to default marshaller of .NET and other languages like Delphi. For legacy application that is critical.
Maybe MarshalNullAsDispatch flag need to replace to the new one like MarshalNullAsNetDefault and marshal values as .NET runtime or expose marshal API that allows override default ClearScript marshaling.
I don't know maybe I have these troubles because I have big legacy application, anyway It's not very critical for me like memory leaks that you fixed.
I use modificated version of ClearScript and have my own marshaling, because our objects exposed as COM both to VBScript and Delphi.

Sorry for my bad english
using System;
using Microsoft.ClearScript.Windows;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var person = new Person { FirstName = "Igor"};
            Console.WriteLine("C# full name is '{0}'", person.FirstName + "," + person.LastName);
            using (var scriptEngine = new VBScriptEngine())
            {
                var script = @"
                    function getFullName
                        getFullName = person.FirstName + "","" + person.LastName
                    end function
                ";
                scriptEngine.Execute(script);
                scriptEngine.Script.person = new Person { FirstName = "Igor"};
                Console.WriteLine("VBScript full name is '{0}'", scriptEngine.Script.getFullName());
                Console.ReadKey();
            }
        }
    }

    public class Person
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }

    }
}

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles



Latest Images