Showing posts with label clickonce. Show all posts
Showing posts with label clickonce. Show all posts

Sunday, February 12, 2012

ClickOne Deployment and SQL Server Express

This is probably a dumb question. But if I embed a SQL Server Express database into my project and then attempt to deploy it via ClickOnce, will I be able to access that database using the SQL Server Management Studio Express CTP if it is installed on the same machine as the client that my app would be installed?

It depends...

ClickOnce deploys the database basically using XCopy and then VS employs a new feature of SQL Express called User Instances to allow the application to start up a special instance of SQL Server and attach the database to that instance at runtime. (Read more about User Instances)

You can use Management Studio to connect to this deployed database while the user instance is running and the database is attached, but not once it shuts down. User Instances eventually shut down when there are no connections open to them. You have to know the Pipe name to connect to a User Instance and you can learn more about how to get the Pipe name and use it to connect to the User Instance in this BOL topic.

Regards,

Mike Wachal
SQL Express team

-
Check out my tips for getting your answer faster and how to ask a good question: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=307712&SiteID=1

|||

Hi,

I encounter a problem when trying to deploy my project (VB2005 Express & SQL2005 Express) by using ClickOnce.

The connectionString is "

connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=;AttachDbFilename=|DataDirectory|\MyDB.mdf;Integrated Security=True;User Instance=True"

After the program is intalled on a client computer, when running, it throws an error: "Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance." I checked the SQL server is runnning on the computer. The user name used to log on has administrator privilege. The computer has multiple user accounts.

If I change User Instance=False in the ConnectionString, it throws an exception when debuging run the program: "An attempt to attach an auto-named database for file C:\.....\bin\Debug\MyDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."

I cann't figure out why. Any help would be appreciated.

Thanks.

ClickOnce private installation issue

I'm working on a VB.Net 2005 application that uses SQLCE as a backend database.

Following the instructions on how to do a private installation (http://msdn2.microsoft.com/en-us/library/bb219482.aspx) so that admin rights were not needed, I successfully got it working as a ClickOnce deployment. But today during a demo for a client, they ran into this error while installing the latest version from our publishing URL:

"Unable to install or run the application. Application requires that assembly System.Data.SQLServerCe version 9.0.42 .... must be installed in the Global Assembly Cache."

Basically it's saying the user isn't an admin so they can't install. This is the problem I went to great lengths to try to avoid, and is the reason we are using SQL CE in the first place: admin rights are not required to install our application's database. To our knowledge, SQL CE is the only Microsoft product that fits this scenario.

Now, I haven't changed anything in the publishing of the application to my knowledge, and when I check the project prerequisites, the SQLCE engine still isn't in there (as summarized at the above URL). Again following the instructions at the URL above for private installation, the required assemblies are still part of the project's files.

It must be something I did to cause this, but I have no memory of changing anything in regards to this part of the application. Our deadline is in 4 days and I cannot continue development until I get past this issue.

Where do I look to fix this problem? A little help would be greatly appreciated.

It is currently unknown as to what caused this problem and the fix may be a kludge. However, we have made some changes after much agonizing, and the application now installs with a newly-created standard user account on Windows XP. After seeing what we did to fix this issue below, any further comments are still appreciated, since we're working with a db system that's only a few months old, and which is not documented with the same rigor as most Microsoft products.

Upon checking the Prerequisites for our application (at Project Properties | Publish | Prerequisites), we saw that not only was SQL CE not selected as a prerequisite, it was not even listed as something we could deselect. Yet, it was still being configured to be installed into the GAC by the ClickOnce engine. Earlier in the development process, perhaps three weeks ago, it did appear in the prerequisites list, and was explicitly deselected. But now it had... disappeared.

However, upon checking what would be installed at Project Properties | Publish | Application Files, we saw that indeed, System.Data.SQLServerCE.dll was being included in the install, and its Publish Status was set as Prerequisite(Auto). Certainly we did not explicitly make this setting, and we are still unable to explain how it happened. Add to this that it could not be deselected on the Prerequisites tab, and you begin to understand the confusion surrounding this issue. (NOTE: we found this same problem with the Microsoft Visual Studio Report Viewer.)

Our first cut at a fix did not work: we changed the Publish status on each item listed as Prerequisite(Auto) to Exclude. The deployment completed without error, but after installation the application could not find required code to execute correctly, and threw unhandled errors at runtime.

Our second try at a fix is where we are now: we changed all items (except Framework 2.0) formerly listed as Prerequisite(Auto) to Include. Interestingly, those items that would not install as prerequisites without Administrator permissions, would now install without error. The last error to be cleared concerned the data file itself.

During our application deployment, we wanted to copy the .sdf database to the program folder. We reference it in code without a fully qualified path, due to the expectation that the database file will be in the same directory as the application executable. However, after clearing the errors described above, we had one last problem to fix: the database file was not found after installation. Checking, we saw that the ClickOnce engine automatically copies the database file to a different folder than the rest of the application files. So, we returned yet again to the Application Files list at Project Properties | Publish, and found that something Auto was happening with our database as well: its Publish Status was listed as Data File(Auto). Taking yet another wild guess, we changed it to Include. Lo, behold and voila, everything now works.

The very unfortunate issues here are 1) that we don't know why it didn't work in the first place, 2) we don't know what happened to change what we thought were correct settings for publication, and 3) we don't know whay what we did to fix the problems worked. To wit, nothing makes logical sense at this point.

We don't know whether any of the things we went through should be classed as bugs in either ClickOnce, Visual Studio, or anything else. Admittedly we are rather over our heads using several technologies for the first time. However, it needs to be said: at best, the documentation for this deployment scenario is sadly lacking (or just plain wrong). At worst, this deployment scenario is not supported by default, and it takes several arcane spells and a lot of wing of bat and eye of newt due to bugs in the system.

At any rate, I hope this tale of woe may help others who may be doing this for the first time.

ClickOnce Please Help

When having someone run my click once app that is using SQL CE they are getting this message.

The application requires that assembly System.Data.SqlServerCE Version 9.0.242.0 be installed in the global assembly cache (GAC) first

Can someone please let me know what I need to add to prerequisites?

Update on my issue. I have downloaded the development toolkit for CE and have set CE as a prerequisit. I ran click once and then published the application and downloaded it on a machine that does not have click once. The application installed and started. I went to do something that I know uses CE and I get this message Unable to load DLL sqlceme30.DLL.

|||Maybe you should have a look at this: http://msdn2.microsoft.com/en-us/library/bb219481.aspx

ClickOnce path names are too long for SQL Server Express identifiers

I'm posting this in the ClickOnce forums as well...

My application doesn't include the .mdf and .ldf files, rather it creates the database the first time the application is run using a script that is included in the build. I want to create the database in the ClickOnce data directory. The problem I'm having is that SQL Server complains when I execute the CREATE DATABASE command as follows:

CREATE DATABASE [C:\Documents and Settings\xxxxx\Local Settings\Apps\2.0\Data\PQCK6EXN.5KG\AW630RPT.VGO\ifie..tion_014028c05b1d6ec6_0001.0002_0e86966f19503c89\DataiFieldMobile.mdf] ON PRIMARY
( NAME = N'myDatabase', FILENAME = N'C:\Documents and Settings\xxxxxx\Local Settings\Apps\2.0\Data\PQCK6EXN.5KG\AW630RPT.VGO\ifie..tion_014028c05b1d6ec6_0001.0002_0e86966f19503c89\Data\myDatabase.mdf' , SIZE = 3136KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'myDatabase_log', FILENAME = N'C:\Documents and Settings\xxxx\Local Settings\Apps\2.0\Data\PQCK6EXN.5KG\AW630RPT.VGO\ifie..tion_014028c05b1d6ec6_0001.0002_0e86966f19503c89\Data\myDatabase_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
END

Here's the error:

System.Data.SqlClient.SqlException "The identifier that starts with 'C:\Documents and Settings\xxxxxx\Local Settings\Apps\2.0\Data\PQCK6EXN.5KG\AW630RPT.VGO\ifie..tion_014028c05b1d6ec6_0001.00' is too long. Maximum length is 128."

The problem lies in the name of the database. This is restricted to 128 characters only since it is an identifier like table name or index name or column name. So you need to change the database name by not specifying the full path of the MDF file there.|||

Umachandar Jayachandran - MS wrote:

The problem lies in the name of the database. This is restricted to 128 characters only since it is an identifier like table name or index name or column name. So you need to change the database name by not specifying the full path of the MDF file there.

Thanks for the prompt reply... however, I am not a T-SQL expert... how exactly do I change my script? Do I create a variable for the database name and then use it in the CREATE DATABASE command?

|||

I'm using the script generated by SQL Server. The first thing I tried doing was replacing the pathnames with a token. The application replaces the tokens with the ClickOnce data path, etc. Here's the first part of the script... How exactly do I need to modify the script?

USE [master]

GO

IF NOT EXISTS (SELECT name FROM sys.databases WHERE name = N'D:\PROJECTS\DOTNET\TABLETPC\IFIELD\APP\DATA\IFIELDMOBILE.MDF')

BEGIN

CREATE DATABASE [D:\PROJECTS\DOTNET\TABLETPC\IFIELD\APP\DATA\IFIELDMOBILE.MDF] ON PRIMARY

( NAME = N'iFieldMobile', FILENAME = N'D:\Projects\DotNet\TabletPC\Release\iField 1.2.0.20\App\Data\iFieldMobile.mdf' , SIZE = 2112KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )

LOG ON

( NAME = N'iFieldMobile_log', FILENAME = N'D:\Projects\DotNet\TabletPC\Release\iField 1.2.0.20\App\Data\iFieldMobile_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)

END

GO

EXEC dbo.sp_dbcmptlevel @.dbname=N'D:\PROJECTS\DOTNET\TABLETPC\IFIELD\APP\DATA\IFIELDMOBILE.MDF', @.new_cmptlevel=90

GO

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))

begin

EXEC [D:\PROJECTS\DOTNET\TABLETPC\IFIELD\APP\DATA\IFIELDMOBILE.MDF].[dbo].[sp_fulltext_database] @.action = 'enable'

end

GO

ALTER DATABASE [D:\PROJECTS\DOTNET\TABLETPC\IFIELD\APP\DATA\IFIELDMOBILE.MDF] SET ANSI_NULL_DEFAULT OFF

GO

ALTER DATABASE [D:\PROJECTS\DOTNET\TABLETPC\IFIELD\APP\DATA\IFIELDMOBILE.MDF] SET ANSI_NULLS OFF

GO

ALTER DATABASE [D:\PROJECTS\DOTNET\TABLETPC\IFIELD\APP\DATA\IFIELDMOBILE.MDF] SET ANSI_PADDING OFF

GO

ALTER DATABASE [D:\PROJECTS\DOTNET\TABLETPC\IFIELD\APP\DATA\IFIELDMOBILE.MDF] SET ANSI_WARNINGS OFF

GO

|||The issue is that the MDF file name cannot exceed 128 characters if you are using it as database name also. So you have to either specify a different name for the database or specify a shorter MDF file name. I am not sure what generates this script. Maybe you will have to post this question in the SQL Server Express forum here.

ClickOnce for SQL Express Database?

I'm working on an app in Visual Studio 2005 that needs to have installed locally SQL Express to handle its own data.

This app is in a strong upgrading process. I've been using clickonce to publish the app and let my users upgrade automatically (by the way this works amazing ...).

Yet many times changes to the DB are made. Is there a simple way to upgrade their local SQL Express DB like click once does with the app?

Thanks.

hi,

I'm not sure about click once capability to perform the requested task, but even if possible, are you sure you like to do it? that means you would upgrade users database loosing their data modifications... I do think you've better just "upgrade" the database schema and not replace their database...

if this is the case, you can perhaps have a look at syncornization tools like http://www.red-gate.com/products/SQL_Compare/index.htm..

regards

|||

Thanks, the products looks like a very good solution. I've already downloaded it and I'm testing.

Have you used it yourself? Do you know other products that do the same?

|||

hi,

yes, I do use it myself since versions 2...

I know other similar tools are available out there, like http://www.innovartis.co.uk/database_dbghost_home.aspx, but I've always been satisfied by red-gate tools.. they even provides http://www.red-gate.com/products/SQL_Packager/index.htm, base on SQL Compare tool, to just distribute an exe packaged file that, at run time, will perform the metadata updates for you..

but here we are in advertising mode

BTW, I'm not involved in any way with the reported products/company, I'm just a user as you could be..

for further info, a free comparison tool is available at http://www.absistemi.it/sqlCompare.aspx by another italian SQL Server MVP fellow, but I'm not sure it has been updated for SQL Server 2005...

regards

|||Grazie tante ...|||

prego...

(you're welcome)