ScriptUO

Scripting Resources & Utilities => Stealth Client => Stealth archive => Topic started by: slyone on November 20, 2013, 06:08:35 PM

Title: Anyone else encounter an exception when calling Stealth.Script_GetSelfID()?
Post by: slyone on November 20, 2013, 06:08:35 PM
My project builds fine and the first print statement prints "Begin" to the console but then an exception is thrown when I call:
Code: [Select]
Console.WriteLine("Hex value from ScriptDotNet:  {0:X}", Stealth.Script_GetSelfID());
The exception I get shows the following:
Quote
An unhandled exception of type 'System.TypeInitializationException' occurred in csSteathScripts.exe

Additional information: The type initializer for 'ScriptDotNet.Stealth' threw an exception.

I'm using VS2012 with .NET 4.5 and the latest ScriptDotNet.dll.

Is it something I am doing wrong? Has anyone else encountered this problem?

My Program.cs is below:

Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using ScriptDotNet;
using ScriptAPI;

namespace csSteathScripts
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Begin");
            Console.WriteLine("Hex value from ScriptDotNet:  {0:X}", Stealth.Script_GetSelfID());
            Console.WriteLine("Hex value from ScriptAPI:  {0:X}", Self.ID);
            Console.WriteLine("All done");
        }
    }
}


Title: Re: Anyone else encounter an exception when calling Stealth.Script_GetSelfID()?
Post by: slyone on November 20, 2013, 06:14:52 PM
I also tried using Boydon's py_stealth.py wrapper and Stealth still seems to crash.

I'm using Stealth 6.1.4 in both instances.

I'm using Python 2.7 here.

Code: [Select]
from py_stealth import stealth_dll
print "%x" %(stealth_dll.Script_GetSelfID())


Code: [Select]
from py_stealth import Self
print "%x" %(Self())
Title: Re: Anyone else encounter an exception when calling Stealth.Script_GetSelfID()?
Post by: Orich on November 20, 2013, 08:49:02 PM
I tested... works fine.   Are you running ScriptDotNet.DLL that i uploaded yesterday?  If not, try it.

That exception happens in static classes ... need more information though.

Recommendations :

1.  Wrap the line in a try/catch
2.  Make sure you're running the program in the debugger (hit PLAY button) so you can see what's going on


Code: [Select]
try
{
   Console.WriteLine("Hex value from ScriptDotNet:  {0:X}", Stealth.Script_GetSelfID());
}
catch (TypeInitializationException ex)
{
   Trace.WriteLine(ex.InnerException); // System.Diagnostics
   throw;
}
Title: Re: Anyone else encounter an exception when calling Stealth.Script_GetSelfID()?
Post by: Crome969 on November 21, 2013, 12:58:25 AM
My project builds fine and the first print statement prints "Begin" to the console but then an exception is thrown when I call:
Code: [Select]
Console.WriteLine("Hex value from ScriptDotNet:  {0:X}", Stealth.Script_GetSelfID());
The exception I get shows the following:
Quote
An unhandled exception of type 'System.TypeInitializationException' occurred in csSteathScripts.exe

Additional information: The type initializer for 'ScriptDotNet.Stealth' threw an exception.

I'm using VS2012 with .NET 4.5 and the latest ScriptDotNet.dll.

Is it something I am doing wrong? Has anyone else encountered this problem?

My Program.cs is below:

Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using ScriptDotNet;
using ScriptAPI;

namespace csSteathScripts
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Begin");
            Console.WriteLine("Hex value from ScriptDotNet:  {0:X}", Stealth.Script_GetSelfID());
            Console.WriteLine("Hex value from ScriptAPI:  {0:X}", Self.ID);
            Console.WriteLine("All done");
        }
    }
}




Run Visual Studio as Administrator, if you try to call your application from vs.
I always getting this error, when i forget to run vs2013 without adminrights.
Title: Re: Anyone else encounter an exception when calling Stealth.Script_GetSelfID()?
Post by: slyone on November 21, 2013, 07:09:43 PM
Thanks for the replies.

I tested... works fine.   Are you running ScriptDotNet.DLL that i uploaded yesterday?  If not, try it.

That exception happens in static classes ... need more information though.

Recommendations :

1.  Wrap the line in a try/catch
2.  Make sure you're running the program in the debugger (hit PLAY button) so you can see what's going on


Code: [Select]
try
{
   Console.WriteLine("Hex value from ScriptDotNet:  {0:X}", Stealth.Script_GetSelfID());
}
catch (TypeInitializationException ex)
{
   Trace.WriteLine(ex.InnerException); // System.Diagnostics
   throw;
}

I added in your try catch.  When I debug through the program, the exception doesn't get thrown.  When I try to run the executable from the command prompt, I get the following exception.

Quote
Unhandled Exception: System.TypeInitializationException: The type initializer for 'ScriptDotNet.Stealth' threw an exception. ---> System.TimeoutExcept
ion: The operation has timed out.
   at System.IO.Pipes.NamedPipeClientStream.Connect(Int32 timeout)
   at ScriptDotNet.Stealth..cctor()
   --- End of inner exception stack trace ---
   at ScriptDotNet.Stealth.Script_GetSelfID()
   at csSteathScripts.Program.Main(String[] args) in c:\StealthUOClient\csSteathScripts\csSteathScripts\Program.cs:line 25

In order to not get the exception, I had to run the command prompt as Administrator.

I haven't figured why my Python version crashes...


Is there a way you could compile the ScriptDotNet.dll with .NET 4 instead of .NET 4.5 so that I can run it on my XP machine?
Title: Re: Anyone else encounter an exception when calling Stealth.Script_GetSelfID()?
Post by: Orich on November 21, 2013, 08:03:47 PM
In order to not get the exception, I had to run the command prompt as Administrator.

I haven't figured why my Python version crashes...


Is there a way you could compile the ScriptDotNet.dll with .NET 4 instead of .NET 4.5 so that I can run it on my XP machine?

I tried to simply change the target framework, but very strange things start happening and the DLL does not function correctly.

My time these days is very limited, so I can't promise when, but I'll try again at some point.
Title: Re: Anyone else encounter an exception when calling Stealth.Script_GetSelfID()?
Post by: slyone on November 23, 2013, 04:39:26 AM
In order to not get the exception, I had to run the command prompt as Administrator.

I haven't figured why my Python version crashes...


Is there a way you could compile the ScriptDotNet.dll with .NET 4 instead of .NET 4.5 so that I can run it on my XP machine?

I tried to simply change the target framework, but very strange things start happening and the DLL does not function correctly.

My time these days is very limited, so I can't promise when, but I'll try again at some point.

Thanks for trying.