Login  
Search All Forums
Dart Home | PowerTCP Telnet for .NET | Custom Development Reply | PowerTCP Telnet for .NET Topics | Forums   
AuthorForum: PowerTCP Telnet for .NET
Topic: Length cannot be less than zero
Jason74

From: Brunswick, OH USA
Posts: 2
Member Since: 11/02/10
posted November 2, 2010 10:19 AM

I tried to recreate this in its simplest form but it actually works then. I am working on creating a module type application. Take the telnet.35 sample as is and set the output type as class library. Create a new project using the Form1 that starts it off and use this code.

using System.Reflection;

 Assembly _assembly = Assembly.LoadFrom("TelnetClient.dll");
      Form newModule = (Form)_assembly.CreateInstance("TelnetClient.frmMain");
      newModule.Show();

Now if I take these same code and compiled DLL into my real project it fails but does not give me much to go on. Since it works in the sample I know there must be something in my project killing but I don't have a clue as to what. Here is the error that I get.

System.Reflection.TargetInvocationException was unhandled
 Message="Exception has been thrown by the target of an invocation."
 Source="mscorlib"
 StackTrace:
    at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
    at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
    at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
    at System.Activator.CreateInstance(Type type, Boolean nonPublic)
    at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
    at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
    at System.Reflection.Assembly.CreateInstance(String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
    at System.Reflection.Assembly.CreateInstance(String typeName)
    at CORE.Form1.button1_Click(Object sender, EventArgs e) in Form1.cs:line 23
    at System.Windows.Forms.Control.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ButtonBase.WndProc(Message& m)
    at System.Windows.Forms.Button.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
    at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.Run(Form mainForm)
    at CORE.Program.Main() in Program.cs:line 20
    at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()
 InnerException: System.ArgumentOutOfRangeException
    Message="Length cannot be less than zero.\r\nParameter name: length"
    Source="mscorlib"
    ParamName="length"
    StackTrace:
      at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
      at System.String.Substring(Int32 startIndex, Int32 length)
      at 0.3.1(Object )
      at 0.3.0(String , Object , Environment , Boolean , String )
      at 0.3.2(Object )
      at 0.3.0(Object )
      at Dart.Common.ComponentBase..ctor()
      at Dart.Common.SocketBase..ctor()
      at Dart.Common.TcpBase..ctor()
      at Dart.Common.PtyBase..ctor()
      at Dart.Telnet.Telnet..ctor(IContainer container)
      at TelnetClient.frmMain.InitializeComponent()
      at TelnetClient.frmMain..ctor()
    InnerException:


Jason Farrar (Admin)

From: Oneida, NY USA
Posts: 223
Member Since: 07/24/07

Extra Support Options
Custom Application Development

posted November 2, 2010 2:00 PM

Do you have a correct licenses.licx file in your class library in your application?

I tried to reproduce the issue by doing what you say works, and found that you were right it indeed works. Unfortunately if we can't reproduce this here, we can't track it down, would it be possible to send in a sample demonstrating this problem to support@dart.com?
Jason74

From: Brunswick, OH USA
Posts: 2
Member Since: 11/02/10
posted November 2, 2010 3:44 PM

I can't really send the offending project, that is why I tried to reproduce the sample. When I get the compiled TelnetClient.dll to work in the sample does it have the right licx? Because all I do is move and load it in the main project then it fails.

While I am licensed for some Dart controls this one I am still testing. Do you think if I had a real license if would work?
Reply | PowerTCP Telnet for .NET Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX