HOW TO: Work Around "Sharing Violation" when Deploying a Smart Device Application from Visual Studio .NET 2003
Applies to:
Microsoft® .NET Compact Framework 1.0
Microsoft® Visual Studio® .NET 2003
IN THIS TASK
SUMMARY
More Information
Terminating an instance of an Application on Pocket PC
Forcing an application to exit on close
Debug, Don’t Run the Application
REFERENCES
SUMMARY
This article illustrates the cause of a sharing violation that prevents the deployment of your application from Visual Studio .NET 2003, and how to work around it.
More Information
A “sharing violation” prevents the deployment of a Smart Device Application, when attempting to deploy, run or debug a Smart Device Application from Visual Studio .NET.
------ Deploy started: Project: SmartDeviceApplication1, Configuration: Debug Pocket PC ------
Connected to Pocket PC 2002 Emulator (Pocket PC) running on X86.
Copying files from 'C:\projects\SmartDeviceApplication1\bin\Debug' to '\Program Files\SmartDeviceApplication1'
Copying SmartDeviceApplication1.exe
Could not write to output file 'SmartDeviceApplication1.exe' - Sharing violation
Error: The operation could not be completed
---------------------- Done ----------------------
Build: 1 succeeded, 0 failed, 0 skipped
Deploy: 0 succeeded, 1 failed, 0 skipped
The most likely cause of this “sharing violation” is a previously running instance of the application on the target device or emulator. The default behavior for Pocket PC applications when closed is to minimize and remain in memory.
Terminating an instance of an Application on Pocket PC
- Open the Control Panel on the device or in emulator; Start | Settings.
- Create a new Visual Basic Smart Device Application project named DetermineSender.
- Launch the Memory item from the System tab.
- Select the Running Programs tab.
- Select the application from the list and tap the Stop button.
Forcing an application to exit on close
- Setting the main form’s ControlBox property to False will cause the application to unload from memory when the form’s “X” button is tapped.
Debug, Don’t Run the Application
A debugged application instance is terminated when Stop Debugging is select from the Debug menu.
REFERENCES
The Visual Studio .NET 2003 online help.