How can I copy Dll's to Program Files folder in Windows 2008 Server using C# - uac

We already have a C# application for Deploying Dll's to different environments(DEV/QA/PROD). This application when asked copies the required Dll's to Program Files folder. This was working fine in Windows 2003 server. But now we migrated our server environments to Windows Server 2008 which brings UAC into picture.
Now when we try to copy the Dll's from local desktop to Server Program files using our application the application is failing.
Can any one suggest me what is the C# code that can make my application to elevate it privileges which allows me to copy the Dll's to remote server.
Regards
Masthan

Add an application assembly manifest that includes requestedExecutionLevel of requireAdministrator.
That way your update program will be run as an administrator.
You could also change your installer to give all users Full Control to your application folder; that way any user could modify your application.

Related

Is there a way to password protect a SQL LocalDB .mdf file in C# application?

I am creating a C# WinForms desktop application along with a SQL Server LocalDB database. I have a setup installer to install the application on desktop. Since it is not on the web server, I have to put the db.mdf file on the customer's computer. But then the user may try to attach this database to SQL Server installed in their own PC and access the data from outside the application. Is there any way I can password protect the file so that it can only be accessed from the application?
I tried to change the extension of file so that it won't be oblivious that its an .mdf file but it does not work without .mdf extension.
Please help me if there is any way I can find a solution to this or any other database I can use for the purpose.

Where did setup install my WinForm application?

I recently developed an WinForm application that I wanted to run on my local SQL server using SQL Agent. I published the WinForm app via Visual Studio and copied the files (three listed below) over to my SQL Server where I ran the setup.exe program.
Application Files (directory)
MyApplicationName.application
setup.exe
My application installed and started up automatically.
Now that I have to schedule the job with SQL Server Agent I cannot find where the application was installed to on the filesystem. I can see the shortcut on the Start menu but it just points to a shortcut. The shortcut does not seem to have any indication as to where the actual application file exists.
I tried to point to the shortcut as the application SQL Agent should start but all I get is "junk text" in the path.
Visual Studio uses ClickOnce deployment to publish WinForms applications. The installation folder varies by Windows version. For example on Windows XP it is
C:\Documents and Settings\USERNAME\LocalSettings\Apps\2.0\
and on Vista and above it is
C:\users\USERNAME\AppData\Local\Apps\2.0\

Visual Basic 2010 Application with SQL Server CE, database not accessible on Windows XP

I was developing an Application that requires a database to store and retrieve data. I am developing the applcation on Visual Basic 2010 Express Edition and using SQL Server Compact Edition for database, on a Windows 7 PC. The Application works perfectly on Windows 7 on my PC. The problem arises on the system of my client who is using Windows XP.
I asked him to install .NET Framework 4.0 and SQL Server CE and send him a copy of the build Application. But when he executed the application and reached a form where database was being used, he encountered and error saying "Access to the database file is not allowed. [ File name = D:\prototype\app\master.sdf ]" and on clicking on continue the form loads but data from the database is not loaded, since it's not connected.
The same problem occurs on windows 7 if i copy the app folder to Program Files directory on Windows 7. But It doesnt occur if i execute the application as "Run as Administrator"
So I require your help to figure out what might be going on and why can't the application access the database simply as it is working on windows 7 (except in the program files directory).
Thanks in advance,
Best Regards
"The user need read-write access to the database file, so you must put it in an suitable location, and change your connection string accordingly."
http://erikej.blogspot.dk/2011/02/using-sql-server-compact-40-with.html
By EricEJ

How to deploy a windows form application including database to another PC?

All
I have built a windows form application using VS 2005 Standard edition which uses SQL Express as the database.
I'd now like to deploy my application to another PC that has .NET framework and SQL Server already installed.
The bit I am unclear about is what do I need to do to ensure that my database is also deployed with my application?
I have spent most of the day reading various articles from msdn to other blogs and I can't get a clear understanding on what is the best way to deploy my application. Some of the varying advice includes:
Add a 'setup' project and create a setup.exe file
Use a custom action to create a database during installation (uses installer class)
Manually detach .mdf and .ldf from database and use command line on target PC to reattach to database
Amend .config file to get new connection string (from target machine) and then reference that in my ado.net code
etc. etc.
Can anybody cut through the confusion for me and help me out?
Thanks
Here’s the simplest way I can think of:
Build the application
Copy the
executable (in the Bin directory) and
the app.config file to the other
machine. The executable and
app.config need to be in the same
folder
Backup the database on your
machine and restore it on the other
machine
Change app.config to point to
the restored database

SQL Server Compact error: Unable to load DLL 'sqlceme35.dll'. The specified module could not be found

I'm developing a Windows Forms application using Visual Studio 2008 C# that uses an SQL Server Compact 3.5 database on the client. The client will most likely be 32 bit Windows XP or Windows Vista machines. I'm using a standard Windows Installer project that creates an MSI file and setup.exe to install the application on a client machine. I'm new to SQL Server Compact, so I haven't had to distribute a client database like this before now. When I run the setup.exe (on new Windows XP 32 bit with SP2 and Internet Explorer 7) it installs fine, but when I run the application I get this error:
Unable to load DLL 'sqlceme35.dll'. The specified module could not be found
I spent a few hours searching for this error already, but all I could find were issues relating to installing on 64 bit Windows and none relating to normal 32 bit that I'm using.
The install application copies the all the dependent files that it found into the specified install directory, including the System.Data.SqlServerCe.dll file (assembly version 3.5.1.0). The database file is in a directory called 'data' off the application directory, and the connection string for it is
<add name="Tickets.ieOutlet.Properties.Settings.TicketsLocalConnectionString" connectionString="Data Source=|DataDirectory|\data\TicketsLocal.sdf" providerName="Microsoft.SqlServerCe.Client.3.5" />
Some questions I have:
Should the application be able to find the DLL file if it's in the same directory, that is, local to the application, or do I need to install it in the GAC? (If so, can I use the Windows Installer to install a DLL file in the GAC?)
Is there anything else I need to distribute with the application in order to use a SQL Server Compact database?
There are other DLL files also, such as MS interop for exporting data to Excel on the client. Do these need to be installed in the GAC or will locating them in the application directory suffice?
You don't need it to be in the GAC for SQL Server Compact to run, and it will pick them up from the application directory. There are several ways to deploy an SQL Server Compact project. The two main ways are:
Deploying the SQL Server Compact redistributable installer with your project, but this way is painful and also can be unistalled by the end user, or upgraded by Windows updates and breaking your application.
Including the DLL files in your application folder. Depending on the features of SQL Server Compact you are using (replication or whatever), there is a handful of DLL files to deploy in your application folder.
If you have SQL Server Compact installed on your machine, they are most likely located at "C:\Program Files\Microsoft SQL Server Compact Edition\v3.5". They can be added to the project in Visual Studio and then set their project output type to "copy always". And the main reference to System.Data.SqlServerCe that you have in your project references should have copy local set to true.
sqlceca35.dll
sqlcecompact35.dll
sqlceer35en.dll
sqlceoledb35.dll
sqlceqp35.dll
sqlcese35.dll
If you have these all set, then in your installer project all you have to include is the project output of this project and you're good. In my opinion this is the only way to go. It is a simple deployment, of a couple of files and you are in control of what DLL versions your application uses.
I hope that helps.
I had a similar problem, a Visual Studio 2008 Windows application targeting 32-bit Windows XP and Windows Vista that used SQL Server Compact 3.5 SP1 - that then got this error when installed on 64-bit Windows 7:
Unable to load DLL 'sqlceme35.dll'. The specified module could not be found
I was embedding an MSI for SQL Server Compact into the installer for the application.
Following this rather confused discussion on MSDN revealed that I needed to use the 64-bit MSI for SQL Server Compact on 64-bit machines. D'oh! That is, from page Microsoft SQL Server Compact 3.5 Service Pack 1 and Synchronization Services for ADO.NET version 1.0 Service Pack 1 for Windows Desktop I needed SSCERuntime-ENU-x64.msi rather than SSCERuntime-ENU-x86.msi for 64-bit machines.
How to: Deploy a SQL Server Compact Edition Database with an Application should help, at least with your first two questions.
In general, I think you should not install anything in the GAC for a single application.
The following provide a solution to the problem and an explanation also.
Troubleshooting: Can’t load SQL Server Compact DLL
SqlCeException on application's first use of SQL Server Compact
Laxmi Narsimha Rao Oruganti 's blog
I hope this helps.

Resources