Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't run from a mapped network drive 2

Status
Not open for further replies.

RadioActiveLamb

IS-IT--Management
Aug 14, 2002
30
US
We've developed an application with VB.NET that we can't get to run from a network share/mapped drive. The application runs queries against a SQL 7 server and displays the information in various ways on-screen and in Crystal 9 reports. The full text of the error is at the end of this post. Since the program will be updated FREQUENTLY, and there are many users, we need to run it from a shared EXE from a mapped network drive. Installing updates on a huge number of computers is out of the question. Here are the various scenarios that we've tried, and their outcomes:

Drive C: is the local drive. Drive S: is the mapped network drive.

Ran the installer, and installed to S:. Exception error when running.
Ran the installer, and installed to C:. Runs just fine.
Ran the installer, and installed to C:. Copied the EXE to S: and tried to run from S:. Exception error when running.

The client machine is running Windows 2000 Pro SP4 with .NET framework 1.1. The server is Windows NT Server 4.0 SP6a. Since the server is only acting as a file server in this instance, the framework shouldn’t need to be on the server, but we installed 1.1 anyway. The SQL server is running on a third machine. It is Windows 2000 Server SP4 with SQL 7 SP4. All the machines are running MDAC 2.7.

Here’s the text of the error:
Common Language Runtime Debugging Services
Application has generated an exception that could not be handled.
Process id=0x6cc (1740), Thread id=0x840 (2112).
Click OK to terminate the application
Click CANCEL to debug the application.

We’ve been beating our heads on this for several weeks, and desperately need a solution. Some suggestions have been to use the .NET framework configuration utility to change the security on the application to run from a network share, but we can’t get detailed information on how, or which computer to do this on.

Thank you.
- Jeff Lamb
 
Not sure if this will help but here is my thought. I tried running a test application that I created ,to read eventlogs, via a drive mapped to my dev box. The client machine also has .net installed on it.

My application generated an error on startup and I found the line generating the error was with the call "Sysytem.Environment.MachineName". Do you have any code such as that in your app that might not work over a netowrk?

Why not create a small test app with limited functionality and start testing that over the network being sure to record all exceptions.

As for the install failing. Try running the install locally on your server and it should work fine.

Let me know if this helps.
 
The installer never fails. I'm sorry I wasn't clear on that point. The installer always works, and the application always works when installing to ANY computer's C: drive. The only thing giving the exception error is the application after installation, only when running from a network drive.

I'll investigate the Sysytem.Environment.MachineName issue and the other points you brought up.

- Jeff
 
hmmm, the error message you're getting is different than one i had encountered, so perhaps a different issue, but for what it's worth, there is definitely an issue with running .net applications over a mapped drive.

basically, .net has built-in security to control what .net applications can and cannot do. if you just go with the default settings, there's a good chance that a .net program will not run over a mapped drive, as a mapped drive is considered part of your intranet and has tighter security than your local computer.

you can adjust this, for either a zone as a whole, increasing or decreasing permissions for .net programs, or you can set permissions on a per program level. you'll want to go to admin tools and then .net framework configuration to make changes.

hope that helps. i got very frustrated on this issue before someone else finally let me in on this feature.

glenn
 
oops, just read your last paragraph in your first post. as far as i know, you'll have to adjust the security settings for each computer. not really a sys admin guy though, so perhaps there's another way. have you tried adjusting the settings on a single computer? did that make a difference?

glenn
 
We're not sure how to adjust the settings. We've tried fooling around in the .NET Configuration, but couldn't find a definite place to adjust the permissions. We've added our program to the "Applications" node, but there's nothing obvious (to us) about security settings. Can you provide a "for dummies" step-by-step approach to adjusting the security settings?

Thank you.
 
I have written a very simple vb.net application called Test1.exe. Test1.exe just reads a MS SQL Server table and displays one field on the Test1 form.

When I run Test1.exe from any local workstation, it works correctly, however, when I try to run it from a mapped network drive, I get the following error: "An exceptioin 'System.Security.SecurityException' has occurred in Test1.exe".

When I pull out all references to SQL Server, the error goes away and Test1.exe runs correctly from both the local computers and the mapped network drive. So it looks like a mapped network drive requires different security than does a local machine.

Here is the code for Test1.exe:
==========================================================
Imports System.Data
Imports System.Data.SqlClient

Public Class Form1
Inherits System.Windows.Forms.Form

Dim mDataReader As SqlDataReader
Dim mSqlConnection As SqlConnection = New SqlConnection("Data Source=SV03;Integrated Security=False;Initial Catalog=AAA_Test;User ID=Eric;Password=1234;")
Dim mSqlCommand As New SqlCommand("Select Field1 from Table1 ", mSqlConnection)

#Region " Windows Form Designer generated code "

Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStart.Click
mSqlConnection.Open()
mDataReader = mSqlCommand.ExecuteReader

mDataReader.Read()
lblResults.Text = mDataReader("Field1")

mDataReader.Close()
mSqlConnection.Close()
End Sub

Private Sub cmdQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdQuit.Click
Close()
End Sub

End Class
=========================================================

I have tried changing the permissions for Test1.exe using the .net configuration program. It looks like the permissions are unlimited for the application but the error message still occurs.
 
How about creating a system DSN that resides on each client machine. Could you use that instead of a connect string to work around the issue?

I have not tried this but it is a possible resolution as long as the DSN exists on the server as well.

- Keith
 
I suspect the problem has to do with permissions not being set properly for the program. Permissions are more restricted on a mapped network drive than they are on a local drive under .net framework.

I have tried several different ways to change the permissons for the program using the .net framework configuration program, but nothing seems to make a difference. The System.Security.SystemException error continues to occur. When I use the config program, I give the program unlimited access to "Everything". So not sure what the problem is.
 
To run the VB.Net EXE from the network drive, try this.

dim objShell
dim mapPath

mapPath = "\\VBNet\VBNet.exe"
set objShell = CreateObject("Shell.Application")

objShell.ShellExecute mapPath, "", "", "open", 1
set objShell = nothing
 
See if you can put the EXE app onto the shared mapped network drive and use the above code to lauch the EXE from the client side. I have done the same and it work on my machine. Good luck. S.
 
santosh1 - per my previous post, I did what you suggested and the same error occurred. Even if it worked, that would defeat the purpose of what I am trying to accomplish, namely creating an app that anyone can run from a mapped/shared network drive. Thanks anyway. If you want more info on this issue, see link I posted to Experts-Exchange above. Experts-Exchange is a free service like Tek-Tips.

Regards :)
 
OK, I found the answer. We have been running .Net Framework 1.0 and later installed .Net Framework 1.1. Thus both versions were running our our computers at the same time. When I uninstalled version 1.0, then did what liebrand suggested, the application ran correctly from everyone's computes.

To recap:

To run a vb.net application from a mapped network drive, do the following:

1. Be sure you are running one version of .net framework. I suspect version 1.0 or 1.1 will both work but we use 1.1 and 1.0 was uninstalled.

2. Per liebrand: "Go into Control Panel / Administrative Tools / Microsoft Framework Wizards / Adjust Security. Modify your Intranet security to a more trusted level and everything should work fine."

These two steps need to be done on each computer that will be running the application from the shared network drive.
 
I do not know how to do this from code, but have had no problems running code from a mapped drive once I'd done the following.

go to;
Control panel
Administrative Tool
.Net Framework Configuration
Adjust Security Zone
Select The local itranet
Give the Zone Full Trust.

Remember only do this if you are sure that the .Net apps on your mapped drives will try to damage your registry, or attack your local hard drive.

I use this method so that I can do all of my development work on a network drive, so that my work is backed up with the rest of the system.

Regards
 
I use another solution for the your situation. I have a starter program that copy the newer version from the server and the starts it. Shortcut is on the starter program. Starter program check the date of local exe and server exe and if the servers one is newer than it copy it and at the and start it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top