The step-by-step article describes how to deploy an application that is built on the Microsoft .NET Framework to run from a network drive.back to the topRequirements
This article assumes that you are familiar with the following topic:
Programming by using Microsoft Visual Basic .NET
The following list outlines the recommended hardware, software, network infrastructure, and service packs that you need:
back to the topDetermine the trust level
- Microsoft Windows XP or Microsoft Windows 2000
- Microsoft Visual Studio .NET 2003 or Microsoft Visual Studio .NET 2002
Security is an important concern when you build an application. The common language runtime grants different levels of trust to code based on specific attributes (named evidences) that the code possesses.
When the common language runtime determines that code has a specific level of trust, the common language runtime permits the code to access resources that are protected by that level of trust. By default, a .NET Framework application that runs from the Internet does not have the same level of trust as a .NET Framework application that runs from your local computer. An application that runs from your local computer can access resources such as the file system. However, an application that runs from the Internet or from a local intranet cannot access the file system on your local computer.
Typically, the default security policy is sufficient for your application. Microsoft recommends that you change this security policy only if you must. You can use the .NET Framework configuration tool (Mscorcfg.msc) to change the security policy.
In the .NET Framework, code access security controls access to resources by controlling how code runs. When a user runs an application, the common language runtime assigns the application to any one of the following five zones:
- My Computer - The application code is hosted directly on the user's computer.
- Local Intranet - The application code runs from a file share on the user's intranet.
- Internet - The application code runs from the Internet.
- Trusted Sites - The application code runs from a Web site that is defined as "Trusted" in Internet Explorer.
- Untrusted Sites - The application code runs from a Web site that is defined as "Restricted" in Internet Explorer.
You can set the security level for each zone to High, Medium, Medium-low, or Low.
Trust levels define the resources that the application can access. The zone, together with other security evidence, such as the publisher, the strong name, the Web site, and the URL of the code, determines the permissions that the common language runtime grants to the code at run time.
Because, you cannot control the security settings on a user's computer, your application must work within the existing settings. Therefore, some resources may not be available to your application. For example, your application may have to write data to a file. However, the user's computer may raise an exception at run time to deny write access for your application.back to the topGrant permission to the application
An application that is hosted on a network drive can run on your local computer. To run the application, you must grant a level of trust to the assembly that corresponds to the application. The trust level setting ranges from None
to Full Trust
. To run the application on your local computer, you must grant Full Trust
permission to the assembly.back to the topCreate a console application
back to the topMap the network drive and deploy the compiled application
- Start Visual Studio .NET.
- On the File menu, point to New, and then click Project. The New Project dialog box appears.
- Under Project Types, click Visual Basic Projects.
- Under Templates, click Console Application.
- Click OK. By default, the ConsoleApplication1 project and the Module1.vb file are created.
- On the Project menu, click Add Reference.
- In the Add Reference dialog box, click the .NET tab.
- On the .NET tab, click adodb, click Select, and then click OK.
- Replace the existing code in the Module1.vb file with the following code.
Module Module1 Sub Main() Dim i As Integer Dim intMaxConnections As Integer Dim Conn As ADODB.Connection intMaxConnections = 63 Dim IntArray(intMaxConnections) As Object Console.WriteLine("Starting test...") For i = 0 To intMaxConnections Conn = CreateObject("ADODB.Connection") Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" _ & "Data Source=C:\Program Files\Microsoft " _ & "Office\Office10\Samples\Northwind.mdb;" Conn.Open() Console.WriteLine("Open connection is " & i) IntArray(i) = Conn Next End SubEnd Module
- On the Build menu, click Build Solution.
- Quit Visual Studio .NET.
back to the topAssign Full Trust permission
- Do the following, depending on your operating system:
The My Documents window appears.
- On Windows XP, click Start, point to All Programs, point to Accessories, and then click Windows Explorer.
- On Windows 2000, click Start, point to Programs, point to Accessories, and then click Windows Explorer.
- On the Tools menu, click Map Network Drive. The Map Network Drive dialog box appears.
- In the Drive box, select any disk drive other than your local disk drives. For example, select any disk drive between D and Z.
- Click Browse. The Browse For Folder dialog box appears.
- Locate and then click the folder that you want to map as a network drive, and then click OK.
Note To make sure that this step works correctly, share the network folder that you want to map as a network drive.
- In the Map Network Drive dialog box, click Finish.
- In Windows Explorer, copy the executable file that you created in the "Create a console application" section from the Bin folder in your console application folder to the mapped network drive.
back to the top
- Do the following, depending on your operating system:
- On Windows XP, click Start, and then click Control Panel.
- On Windows 2000, click Start, point to Settings, and then click Control Panel.
- Do the following, depending on the version of the .NET Framework that you are using:
The .NET Wizards window appears.
- If you are using the .NET Framework 1.1, double-click Administrative Tools, and then double-click Microsoft .NET Framework 1.1 Wizards.
- If you are using the .NET Framework 1.0, double-click Administrative Tools, and then double-click Microsoft .NET Framework Wizards.
- In the .NET Wizards window, click Trust an Assembly. The Trust an Assembly dialog box appears.
- Click to select the Make changes to this computer option, and then click Next.
- Click Browse. The Choose Assembly dialog box appears.
- In the Choose Assembly dialog box, locate the executable file on the mapped network drive, and then click Open.
- In the Trust an Assembly dialog box, click Next.
- In the Trust an Assembly dialog box, move the slider to Full Trust, and then click Next.
- Click Finish.
- To run the executable file from the mapped network drive, double-click the file in Windows Explorer.