473,654 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Click-once app does not run

I built a small app with VS C# Express 2008, and published it as a
click-once app. I tried installing it on my local machine, and when I
click on its icon from the Start menu, nothing happens. Everything
works fine when I run the code from VisualStudio. I get this problem
if I use Debug or Release build config.
I'm sure it must be something rather simple, but I just can't seem to
find it.
Aug 28 '08 #1
6 5649


Lord Zoltar wrote:
I built a small app with VS C# Express 2008, and published it as a
click-once app. I tried installing it on my local machine, and when I
click on its icon from the Start menu, nothing happens. Everything
works fine when I run the code from VisualStudio. I get this problem
if I use Debug or Release build config.
I'm sure it must be something rather simple, but I just can't seem to
find it.
Ok I think I've isolated the problem: the SQLite database file is not
getting added to the deployment. I've tried marking the file as a
"resource" or "embedded resource" but I can't seem to get it to get
deployed with the app. It also never appears in Project Properties ->
Publish tab -Application Files.
Aug 28 '08 #2


Lord Zoltar wrote:
Lord Zoltar wrote:
I built a small app with VS C# Express 2008, and published it as a
click-once app. I tried installing it on my local machine, and when I
click on its icon from the Start menu, nothing happens. Everything
works fine when I run the code from VisualStudio. I get this problem
if I use Debug or Release build config.
I'm sure it must be something rather simple, but I just can't seem to
find it.

Ok I think I've isolated the problem: the SQLite database file is not
getting added to the deployment. I've tried marking the file as a
"resource" or "embedded resource" but I can't seem to get it to get
deployed with the app. It also never appears in Project Properties ->
Publish tab -Application Files.
Never mind... Had to set the file's Build Action to "Content", and in
Application files, set it to "Include" not "Data File".
Aug 28 '08 #3

"Lord Zoltar" <lo*********@gm ail.comwrote in message
news:41******** *************** ***********@k30 g2000hse.google groups.com...
>

Lord Zoltar wrote:
>Lord Zoltar wrote:
I built a small app with VS C# Express 2008, and published it as a
click-once app. I tried installing it on my local machine, and when I
click on its icon from the Start menu, nothing happens. Everything
works fine when I run the code from VisualStudio. I get this problem
if I use Debug or Release build config.
I'm sure it must be something rather simple, but I just can't seem to
find it.

Ok I think I've isolated the problem: the SQLite database file is not
getting added to the deployment. I've tried marking the file as a
"resource" or "embedded resource" but I can't seem to get it to get
deployed with the app. It also never appears in Project Properties ->
Publish tab -Application Files.

Never mind... Had to set the file's Build Action to "Content", and in
Application files, set it to "Include" not "Data File".
If you include it as an application file, it gets replaced when you issue
updates. Just be aware of that.

If you include it as a Data File, it gets put in a different location that
you can reach programmaticall y, and updates are handled differently.

If you need to retain the database between updates, post back and I will
give more info.

RobinS.
GoldMail.com

Aug 28 '08 #4
Response to "RobinS" <ro****@imnotte lling.com>:

<snip>
If you need to retain the database between updates, post
back and I will give more info.
I realize this thread is not my own, but I'd definitely
appreciate
you elaborating further.

I am currently researching the best methods for deployment
of one of
my applications. My thought was that adding them as
resources might
prove easier or more manageable at least.

One of the main problems I ran across was the file
disappearing or
my embedded projects* not building anew.

* Whatever the proper terminology is for a single solution
containing other solutions ("Add Project").

Thanks!

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail
me. I am
kidding. No I am not.
Aug 28 '08 #5


RobinS wrote:
"Lord Zoltar" <lo*********@gm ail.comwrote in message
news:41******** *************** ***********@k30 g2000hse.google groups.com...


Lord Zoltar wrote:
Lord Zoltar wrote:
I built a small app with VS C# Express 2008, and published it as a
click-once app. I tried installing it on my local machine, and when I
click on its icon from the Start menu, nothing happens. Everything
works fine when I run the code from VisualStudio. I get this problem
if I use Debug or Release build config.
I'm sure it must be something rather simple, but I just can't seem to
find it.

Ok I think I've isolated the problem: the SQLite database file is not
getting added to the deployment. I've tried marking the file as a
"resource" or "embedded resource" but I can't seem to get it to get
deployed with the app. It also never appears in Project Properties ->
Publish tab -Application Files.
Never mind... Had to set the file's Build Action to "Content", and in
Application files, set it to "Include" not "Data File".

If you include it as an application file, it gets replaced when you issue
updates. Just be aware of that.

If you include it as a Data File, it gets put in a different location that
you can reach programmaticall y, and updates are handled differently.

If you need to retain the database between updates, post back and I will
give more info.

RobinS.
GoldMail.com
Thanks for that bit of detail. I WOULD like this data file to be kept
when the app is updated. If there are ever schema changes, I'll have
my app handle those internally.
Aug 28 '08 #6

"-Lost" <ma************ ****@techie.com wrote in message
news:Xn******** *************** *@216.196.97.13 6...
Response to "RobinS" <ro****@imnotte lling.com>:

<snip>
>If you need to retain the database between updates, post
back and I will give more info.

I realize this thread is not my own, but I'd definitely
appreciate
you elaborating further.

I am currently researching the best methods for deployment
of one of
my applications. My thought was that adding them as
resources might
prove easier or more manageable at least.

One of the main problems I ran across was the file
disappearing or
my embedded projects* not building anew.

* Whatever the proper terminology is for a single solution
containing other solutions ("Add Project").

Thanks!

--
-Lost
Here is my experience with deploying data files... A lot of this information
is from Brian Noyes's book on ClickOnce, which is excellent. I have an
alternative method at the end that we use for our homespun configuration
files as well, and will probably use for SQLCE when we get to that point.

This is Brian Noyes' book on ClickOnce Deployment:
http://www.amazon.com/Smart-Client-D...6469474&sr=8-1

Deploy the SQL database with the application as a data file. It goes into
the folder defined by ApplicationDepl oyment.DataDire ctory, or
Application.Use rAppDataPath. (Assuming you have it in the top level of your
project, otw it puts it in a relative folder under that base path).

The database is only placed there when actually deployed, so when you test
out of VS, you have to set the "copy to output directory" to "copy always"
or "copy if newer", so the files will be copied to the same (relative)
folder location under the build output folder for your project.

Then you have to add code that checks to see if you're running the deployed
version (ApplicationDep loyment.IsNetwo rkDeployed = true), and if not, adjust
the path programmaticall y for your debugging (it will be under the
Application.Exe cutablePath + relative-folder-if-you-have-one).

string dataPath;
if (ApplicationDep loyment.IsNetwo rkDeployed)
dataPath = ApplicationDepl oyment.CurrentD eployment.DataD irectory;
else
dataPath = System.Windows. Forms.Applicati on.StartupPath;
dataPath = System.IO.Path. Combine(dataPat h, "yourdatabasena me.sdf");

When you deploy your app, it deploys the database in the DataDirectory. When
you publish an update to the application, it copies the database forward to
the folder for the new version of the application, assuming nothing about
the server-side database has changed in any way.

But if you change the database, that's where it gets complicated. It will
copy the new database from the server to the new version's DataDirectory
folder.

It will copy the old database to a .\pre subfolder under the DataDirectory
folder for the new version.

Then you have to write code to migrate the old data to the new database. If
you do nothing, it will ignore the previous version's database and use the
new database.

The general process to migrate the data is to run a SQL script or a set of
SQL queries to retrieve the data from the old database and insert the data
into the appropriate tables in the new database. You might write this code
as part of a separate migration utility that is invoked when the new version
gets deployed.

If you look at the code from Brian Noyes' book (available at
http://www.softinsight.com/clickoncebook), there is a sample of this called
SQLCompactScrip tedMigration. It includes v1.0.0.0 and 2.0.0.0 of the same
application, but 2.0.0.0 contains the code in the main form's constructor to
migrate the data. The difference between 1.0 and 2.0 in his case is that a
new table was added to the database with a fk relation to the old table.

Here's the example from v2.0.

public Form1()
{
InitializeCompo nent();
if (ApplicationDep loyment.IsNetwo rkDeployed)
{
if (ApplicationDep loyment.Current Deployment.IsFi rstRun)
{
MigrateData();
}
}
}

// This method takes advantage of the fact that for this simple
example, the typed data set
// Customers table and table adapter is compatible with the new schema
private void MigrateData()
{
string preFile =
Path.Combine(Ap plicationDeploy ment.CurrentDep loyment.DataDir ectory,@".\.pre \Northwind.sdf" );
if (!File.Exists(p reFile)) // nothing to migrate
return;

// Get a connection to the old data in the \.pre folder
string oldDataConnecti onString = @"Data
Source=|DataDir ectory|\.pre\No rthwind.sdf";
SqlCeConnection oldConnection = new
SqlCeConnection (oldDataConnect ionString);
// Get a connection to the new data
string newDataConnecti onString = @"Data
Source=|DataDir ectory|\Northwi nd.sdf";
SqlCeConnection newConnection = new
SqlCeConnection (newDataConnect ionString);
// Fill a dataset with the migration data
NorthwindDataSe t oldData = new NorthwindDataSe t();
CustomersTableA dapter oldAdapter = new CustomersTableA dapter();
oldAdapter.Conn ection = oldConnection;
oldAdapter.Fill (oldData.Custom ers);
// Create a table adapter for the new database and a compatible
data set
CustomersTableA dapter newAdapter = new CustomersTableA dapter();
newAdapter.Conn ection = newConnection;
NorthwindDataSe t newData = new NorthwindDataSe t();
// Fill the new data set with default data
newAdapter.Fill (newData.Custom ers);
// Merge the old data into the new schema
// Assumes compatible schemas - this is the hard part for
// Real apps with significant schema changes
foreach (DataRow row in newData.Custome rs)
{
row.Delete();
}
newData.Merge(o ldData);
newAdapter.Upda te(newData);
}
About connection strings: If you include the |DataDirectory| placeholder in
your connection string, the path will be filled in automatically by the
runtime. For example, for Northwind, it would be

Data Source = "|DataDirectory |\Northwind.sdf ".

Be sure your database is added to the project as a file with a Build Action
of "content", and marked as a Data File in the Application Files dialog.

Another problem to be aware of is that the migration of a data file is
triggered by *any* change to the data file in a newly published version of
your application. If you connect to your SQLServer Express or SQLCE database
in VS just to check the schema or contents of the default values, you will
have modified the date timestamp of the file, so the next time you publish
your application it will be treated as a new version of the database, and
you need to have your data migration code in place to handle that.

Basically, if you never change your database structure, ClickOnce will
handle the data migration for you by copying the database forward. OTW you
have to handle it yourself in code.

**AN ALTERNATIVE**

For databases that are just files, like Access databases or SQLCE, you can
do the following:

1) Include the database in the main project. In the ApplicationFile s dialog
in the Publish tab, set it to Include or Include(Require d) instead of
Include(Data).

2) In the application's startup, check to see if the folder you're going to
put the database in exists, and if there's already a database there. If
there's not, create the folder and copy the database over there.

In Vista, you can only write to MyDocuments and the user's profile. I
wouldn't put it in MyDocuments -- that's just asking for trouble. I put my
files in LocalApplicatio nData, as recommended for Windows Vista.

userFilePath =
Environment.Get FolderPath(Envi ronment.Special Folder.LocalApp licationData);
string userFilesGoHere = Path.Combine(us erFilePath, "ourCompanyName ");
string ourDatabase = Path.Combine(us erFilesGoHere, "myDB.mdb") ;
string whereTheDBStart s =
Path.Combine(Sy stem.Windows.Fo rms.Application .StartupPath, "myDB.mdb") ;

So in your startup, you can check for it, and copy it over if it's not
there:

if (!Directory.Exi sts(userFilesGo Here))
{
Directory.Creat eDirectory(user FilesGoHere);
File.Copy(where TheDBStarts, ourDatabase);
}
else if (!File.Exists(o urDatabase))
File.Copy(where TheDBStarts, ourDatabase);

And then just set the connection string to point at the location defined by
ourDatabase.

So the first time the user runs the application, it will set up the
directory and copy the database over there. On subsequent updates or
installations, it will just use the database that is already there.

The advantage of this is you don't have to deal with migration if you just
open the database and close it. You just have to handle it when you know
something has changed.

Also, if the user deinstalls your application and reinstalls it, the data is
left behind. This is bad (the data is left behind and not cleaned up) and
good (the user reinstalls the application and doesn't lose his data).

And one last extra helpful comment about SQLCE: If you're deploying this,
you can include the dll's as local references instead of pushing SLQCE as a
prerequisite. This is way cool, because it removes one step from the
installation process.

To do this, you add the dll's to your project and set "copy local" to true
and include them in the deployment. Then you can remove the prerequisite.
Here are the dll's you need to add (version may change):

sqlceca30.dll
sqlcecompact30. dll
sqlceer30en.dll
sqlceme30.dll
sqlceoledb30.dl l
sqlceqp30.dll
sqlcese30.dll
I hope this helps someone. This is a frequently asked question in the
ClickOnce forum, so hopefully it will also help someone here.

RobinS.
GoldMail.com

Sep 4 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
535
by: Thom Little | last post by:
I would like three states on an icon ... Left Click Right Click Double Click Left Click is fired at least once on a Double Click Is there a good example that shows how to determine if the user entered a Left Click or a Double Click?
11
414
by: Thom Little | last post by:
I would like three states on an icon ... Left Click Right Click Double Click Left Click is fired at least once on a Double Click Is there a good example that shows how to determine if the user entered a Left Click or a Double Click?
14
3545
by: Thom Little | last post by:
I would like three states on an icon ... Left Click Right Click Double Click Left Click is fired at least once on a Double Click Is there a good example that shows how to determine if the user entered a Left Click or a Double Click?
5
6166
by: J McD | last post by:
Hi I have a DataGrid with an ImageButton column. When I click on an imagebutton I get a postback but it doesn't run the OnImgBtnClick method. I can actually comment out the line where I add this Click event to the ImageButton Column and it makes no difference, I still get a postback. This is driving me crazy...something seems to be causing an OnClick postback and it isn't my Click event I've included the code below....any help will be...
41
4288
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based on some initialization information obtained elsewhere. Basically, I'm going to create my own dynamic toolbar where the toolbarbuttons can change. I'm not using the VB toolbar because of limitations in changing things like backcolor (I can't get...
0
8379
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8294
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8596
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2719
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1924
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.