Author Topic: Anyone else encounter an exception when calling Stealth.Script_GetSelfID()?  (Read 5549 times)

0 Members and 1 Guest are viewing this topic.

Offline slyoneTopic starter

  • Full Member
  • ***
  • Posts: 135
  • Activity:
    0%
  • Reputation Power: 2
  • slyone has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 1
    • View Profile
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");
        }
    }
}


Started playing back at the Second Age

Offline slyoneTopic starter

  • Full Member
  • ***
  • Posts: 135
  • Activity:
    0%
  • Reputation Power: 2
  • slyone has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 1
    • View Profile
0
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())
Started playing back at the Second Age

Offline Orich

  • Jr. Member
  • **
  • Posts: 77
  • Activity:
    0%
  • Reputation Power: 3
  • Orich has no influence.
  • Respect: +12
  • Referrals: 1
    • View Profile
0
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;
}
Member of the Stealth development team.
Author of Stealth .NET DLL

Offline Crome969

  • Moderator
  • *
  • *****
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
0
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.

Offline slyoneTopic starter

  • Full Member
  • ***
  • Posts: 135
  • Activity:
    0%
  • Reputation Power: 2
  • slyone has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 1
    • View Profile
0
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?
Started playing back at the Second Age

Offline Orich

  • Jr. Member
  • **
  • Posts: 77
  • Activity:
    0%
  • Reputation Power: 3
  • Orich has no influence.
  • Respect: +12
  • Referrals: 1
    • View Profile
0
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.
Member of the Stealth development team.
Author of Stealth .NET DLL

Offline slyoneTopic starter

  • Full Member
  • ***
  • Posts: 135
  • Activity:
    0%
  • Reputation Power: 2
  • slyone has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 1
    • View Profile
0
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.
Started playing back at the Second Age

Tags: