Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I wrote an app and made an exe of it ,run it on my own machine, works fine.
The same app on another machine when clicked to 'play',it says:
C#
See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at ReClient_ServerWinforms.Form1.Ping_all()
   at ReClient_ServerWinforms.Form1.Form1_Load(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
ReClient_ServerWinforms
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Program%20Files%20(x86)/PureTechs%20Ltd/My%20Product%20Name/ReClient_ServerWinforms.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
 


I enabled JIT in my App.config as:

C#
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
  <system.windows.forms jitDebugging="true"/>
</configuration>


But still the same error doesn't let me the app to run.
Why?
Posted
Comments
Richard MacCutchan 25-Mar-15 4:16am    
You need to fix the IndexOutOfRangeException error.
Jeddi khan 25-Mar-15 7:03am    
But it is all right on my machine.....how'd i know the cause of this error while everything on my side works fine!
Andy Lanng 25-Mar-15 5:55am    
Does your other machine have a "JIT debugger registered on the computer"
Jeddi khan 25-Mar-15 7:02am    
On the testing machine i don't have any Visual studio installed.
I then tried by installing it,still it gives the same error
Andy Lanng 25-Mar-15 7:08am    
Hmm - that is odd. Assuming that you have copied all relevant dlls and configs to the exe folder then maybe fall back on tradition and debug the source in VS on the target machine?
I have found that debugging code in VS can hide problems such as race conditions, but you might find a GAC library missing at the same time.
Oh! PS: jit debugging won't work with VS express:
https://msdn.microsoft.com/en-us/library/bdcetka3%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

1 solution

hmm - looking into it. Maybe check hosts file: "C:\Windows\System32\drivers\etc\hosts" (::1 is localhost for eg) or the zeros are compresses so it's actually 0: 0: 0: 0 or the gateway has no true ip address.
The method seems to return an arbitrary gateway. may I suggest some linq:
C#
//Exact copy of your code in linq
    foreach (
        GatewayIPAddressInformation d in
        from f in NetworkInterface.GetAllNetworkInterfaces()
        where f.OperationalStatus == OperationalStatus.Up
        from d in f.GetIPProperties().GatewayAddresses
        select d)
    {
        ip = d.Address.ToString();
    }
    //This also gets all addresses:
    NetworkInterface.GetAllNetworkInterfaces()
        .Where(f => f.OperationalStatus == OperationalStatus.Up)
        .SelectMany(f=>f.GetIPProperties().GatewayAddresses)
        .Select(d=>d.Address)
//You can .First or .Last to get a single address, or check that the IP isn't "::"
 
Share this answer
 
Comments
Andy Lanng 30-Mar-15 5:50am    
Post from OP:
I am not getting ".Select(d=>d.Address)
//You can .First or .Last to get a single address"
Andy Lanng 30-Mar-15 5:53am    
I used this to get by gateway to print out to console:
NetworkInterface.GetAllNetworkInterfaces()
.Where(f => f.OperationalStatus == OperationalStatus.Up)
.SelectMany(f=>f.GetIPProperties().GatewayAddresses)
.Select(d => d.Address).ToList().ForEach(a => Console.WriteLine(string.Format("Network Gateway: {0}", a.ToString())));

If you are not getting anything from that then it looks like that machine has no gateway that matches the criteria

I don't do networks so I don't know why that would happen :S

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900