Exception thrown after trying to get access to a network drive - c#

At the moment I'm setting up a new project on my TeamCity server, which should simply build and execute a C# application.
The application needs access to a network drive for the execution, so the path to the network drive is passed as argument.
The build step works well, but I get a 'System.UnauthorizedAccessException' according to the path of the network drive, after executing it.
The TeamCity account has administrative priviliges and everything works well if I start it manually.
So, I assume my user account or the build agent still does not posses administrative priviliges? Do I have to set more specific settings at my TeamCity server?
Sorry if this post is a repetition, but among others, this post [0] does not worked for me.
Any ideas? Thx a lot in advance!
[0] how to run visual studio or nunit as administrator from teamcity

The solution of my question is the same as in this question:
Trying to get a Windows Service to run an executable on a shared drive

Related

Determine if process started as admin is already running in C#

I've been trying to determine if process A, that I installed, is already running on the machine. Process A requires admin priviliges, it is installed in C:\ProgramData and it is usually started as a service. There are many processes on the machine, that are named A. To find out, if this is my process, I inspected the path to exe file.
You can do this with process.MainModule.FileName or more elaborate setup that is documented in this question
Unfortunately, you cannot inspect the path of executable started as administrator without having administrator priviliges your self.
Is there another way to determine if the process with the name A is indeed the one you are looking for? What else can be checked beside path to executable? What workaround do you recommend?
UPDATE:
I misinterpreted the observations. If the process is started as a service, it is run as a SYSTEM user. Because of that, you cannot determine the executable path without having the admin priviliges your self.

Why is my C# web project looking for a local file once it is uploaded to remote server (with code behind)? [duplicate]

I am using C#.net for application development.
To log and debug exceptions, I use the stacktrace.
I executed my application on another machine, but when errors occur it refers to the path of my development machine.
Ex: D:\Projects\xyz.CS line no :12 _Error_message_here.
Why does it trace to the path on my development machine path even though I am running the application on another machine?
The original compiled path is stored in the debug information within the PDB files.
Because it's telling you where to find the problem in your source code. So when you see this, you can go to your machine and open the file reported (e.g. "D:\Projects\xyz.cs"), go to the reported line (e.g. 12) and fix the problem.
Explanation
When you do a Debug build, it includes source information in the compiled files to enable debugging, e.g. pause, step over, etc.
Solution
If you don't want the source information to be included perform a Release build and deploy that to the other machine.

Changing virtual directories in IIS 7

I just got a new pc running Windows 7. My old box had XP. I copied all of my files to a newtwork directory, then copied them down to the new pc.
I have an application built in Visual Studio 2003 that I'm trying to do maintenance on. When I try to open it I get the following error message:
Unable to open Web project 'EDIWebFormsUI_1'. The file path 'c:\inetpub\wwwroot\EDIWebFormsUI_1' does not correspond to the URL 'http://Localhost:/EDIWebFormsUI_1'. The two need to map to the same server location.
I found an article on Microsoft TechNet telling how to change the mapping of a virtual directory at http://technet.microsoft.com/en-us/library/cc754640(WS.10).aspx.
However, it says "5. In the Actions panel, click Basic Settings."
I don't have a Basic Settings option in my Actions panel.
I also tried appcmd from the command line, but I get the message "appcmd is not recognized as an internal or external command."
Do you know of another way to change the virtual directory mapping for my application?
VS2003 is a bit old, but there should be a plaintext file somewhere in the project directory that points to the virtual directory location hosting the web project.
To use Appcmd, you may need to change your directory before you try to run the command. At the command prompt, type cd %windir%\system32\inetsrv then run your command. That should solve the issue.

SQL Compact Edition 3.5 - Access to the database file is not allowed

I developed an application (100% local, no access to servers) using SQL Server Compact 3.5, and it works fine on my computer. However, when I deployed it on another computer, it shows this error:
Access to the database file is not allowed. [ File name = data\BDApepucCE.sdf ]
I deployed on a Windows XP computer. It shows this error whenever I try to write on the database, however, it works when I read.
I did a test on a Windows 7 computer, and it worked 100%, except when the file was accessed through the homegroup (that is, local network), on which it failed on both read/write.
Platform: Windows 7, Visual Studio 2010, and .NET 4 Client Profile
Make sure you use |DataDirectory| in your connection string.
Here is an example
connectionString="Data Source=|DataDirectory|MyDB.sdf"
I had the exact same problem ay you and I managed to fix it by adding the |DataDirectory| to my connection string.
Good luck.
This worked for me: http://solutionevangelist.com/community/discussion/20/access-to-the-database-file-is-not-allowed.-system.data.sqlserverce.sqlceexception/p1
It it usually a permissions issue. I give "Everyone" full permissions to the .sdf file in App_Data, either via the GUI, or using
icacls database.sdf /grant Everyone:F
I also had this same problem. My solution was in TFS/SourceControl at the time when I deployed it and the sdf file was checked-in (ie read-only) and this caused me the exact same error as above. When I checked out the sdf file and deployed again, everything was fine. Thought I'd share that in case other TFS users experience the same issue.
Here are a two other suggestions:
Try to run your Visual Studio as administrator
Check if the 'readonly' attribute is set on the sdf file
Also you may want to check and see if your Application Pool is using Network Service (not Application Pool) and the Network Service Permissions are set to full control under your AppData folder. This was my problem awhile ago and I forgot how I did it, but this question reminded me of how I did it.
You just need to make 'Server Side Includes" allowed under the IIS menu 'Web Services Extensions'
that fixed all my problems.
The following solution worked for me:
"Program Files" in Windows is protected, so normal users cannot write
there, your applications will probably work only with an administrator
user.
Change the data folder path for your database to somewhere where all
users have permission to write.
This would not be the typical cause, but I ran into this error message when my connection string had the incorrect path to the CE SDF file. Once I fixed that the error went away.
Just run your application as administrator. I solved my problem using this.

Create a Setup File Windows.Net C#

I have created a windows application setup program, it needs to have a text file in the application folder. The file is also included while creating the setup.
Once the setup successfully completes and my program tries to modify the file based on user input, its simple throwing an exception.
I am using Windows 7 Home Premium OS.
Any suggestion/help will be great to overcome this issue.
This is normal on a Vista or Win7 machine. Or a properly secured XP machine for that matter. The normal install location for programs, like c:\program files\your company\your app, is read only for most users. UAC is a counter-measure to malware messing with programs.
You'll need to store the text file into a writable location, the AppData folder. In the Setup project, right-click "File system on target machine" and select User's Application Data Folder. Find that file back at runtime through Environment.GetFolderPath, passing Environment.SpecialFolder.ApplicationData. Or use "User's Personal Data Folder" if the user should be able to find it back easily through the Documents folder.
What exception is being thrown? It could be a UAC issue.

Categories