Running C# (.NET Framework 2.0) Application from long path (>127)crashes!

S

Stefan Pascal

Hello.

I have a very strange problem on my system with running C#
applications from a longer than usual (>127 chars) path. I was able to
reproduce the following 2 cases:
1. Socket s = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp); // <-- crashes here #1

2. SqlConnection con = new SqlConnection("Persist Security
Info=False;server=MyServer\\MyInstance;database=MyDataBase;Connect
Timeout=30;Trusted_Connection=True;");
con.Open(); // <-- crashes here #2

#1 crash shows the message: "WSAStartup cannot function at this time
because the underlying system it uses to provide network services is
currently unavailable."
#2 crash shows the message: "An error has occurred while establishing
a connection to the server. When connecting to SQL Server 2005, this
failure may be caused by the fact that under the default settings SQL
Server does not allow remote connections. (provider: SQL Network
Interfaces, error: 26 - Error Locating Server/Instance Specified)"

My workstation settings:
Operating System: Windows XP SP2
Programming Environment: Microsoft Visual Studio 2005 Team Edition for
Software Developers (8.0.50727.42 RTM.050727-4200)
..NET Framework: .NET Framework 1.1, .NET Framework 2.0 Service Pack 1

If i run *any C# application* from a path that exeeds 127 characters
(including the file name) - it crashes. For example: C:\Documents and
Settings\user123.xCOMPANY\Local Settings\Apps\2.0\HMTCX95T.RXV
\9CKLQ85R.AXB
\appl..tion_6e98555c88572fe0_0001.0002_47eaa25a8a47e226\TestSPExecTestSPExecTestSPExecTestSPExec.exe
If i change the file name and/or the path to make it less or equal to
127 characters, everything works fine! For example: C:\Documents and
Settings\user123.xCOMPANY\Local Settings\Apps\2.0\HMTCX95T.RXV
\9CKLQ85R.AXB\TestSPExecTestSPExecTestSPExec.exe

Does anyone have any clue about what the problem might be? I wouldn't
like to reinstall my workstation since i have a lot of SDKs installed
and configured, and it would take a lot of time to reconfigure
everything from scratch.

Thank you!
 

My Computer

S

Stefan Pascal

On Jun 5, 5:31 pm, Stefan Pascal <[email protected]> wrote:

> Hello.
>
> I have a very strange problem on my system with running C#
> applications from a longer than usual (>127 chars) path. I was able to
> reproduce the following 2 cases:
> 1. Socket s = new Socket(AddressFamily.InterNetwork,
> SocketType.Stream, ProtocolType.Tcp); // <-- crashes here #1
>
> 2. SqlConnection con = new SqlConnection("Persist Security
> Info=False;server=MyServer\\MyInstance;database=MyDataBase;Connect
> Timeout=30;Trusted_Connection=True;");
> con.Open(); // <-- crashes here #2
>
> #1 crash shows the message: "WSAStartup cannot function at this time
> because the underlying system it uses to provide network services is
> currently unavailable."
> #2 crash shows the message: "An error has occurred while establishing
> a connection to the server.  When connecting to SQL Server 2005, this
> failure may be caused by the fact that under the default settings SQL
> Server does not allow remote connections. (provider: SQL Network
> Interfaces, error: 26 - Error Locating Server/Instance Specified)"
>
> My workstation settings:
> Operating System: Windows XP SP2
> Programming Environment: Microsoft Visual Studio 2005 Team Edition for
> Software Developers (8.0.50727.42 RTM.050727-4200)
> .NET Framework: .NET Framework 1.1, .NET Framework 2.0 Service Pack 1
>
> If i run *any C# application* from a path that exeeds 127 characters
> (including the file name) - it crashes. For example: C:\Documents and
> Settings\user123.xCOMPANY\Local Settings\Apps\2.0\HMTCX95T.RXV
> \9CKLQ85R.AXB
> \appl..tion_6e98555c88572fe0_0001.0002_47eaa25a8a47e226\TestSPExecTestSPExe­cTestSPExecTestSPExec.exe
> If i change the file name and/or the path to make it less or equal to
> 127 characters, everything works fine! For example: C:\Documents and
> Settings\user123.xCOMPANY\Local Settings\Apps\2.0\HMTCX95T.RXV
> \9CKLQ85R.AXB\TestSPExecTestSPExecTestSPExec.exe
>
> Does anyone have any clue about what the problem might be? I wouldn't
> like to reinstall my workstation since i have a lot of SDKs installed
> and configured, and it would take a lot of time to reconfigure
> everything from scratch.
>
> Thank you!
I forgot to mention that for the second case (SQLConnection exception)
the connection string is perfectly ok. As i said, the same EXE moved
(copied) to another (shorter) directory (path) or renamed in the same
directory runs without any problem! So it is a problem related to the
executable full path lenght.

Any ideas? Thank you.
 

My Computer

Top