|
I'm having a little trouble. I'm playing with WCF and trying to install it via a service. I'm following these two articles that I found: http://msdn.microsoft.com/en-us/library/ms733069.aspx[^] and http://a1ashiish-csharp.blogspot.com/2012/02/cnet-how-to-host-wcf-web-service-in.html#.UJGjIMXA_08[^]
Now what is happening is I created my WCF DLL Library and I added the WindowsService file and the ProjectInstaller to it. I then created a Windows Setup and added the primary output to the setup project.
When it installs it creates the service and links it to my DLL file instead of the windows service created a EXE and linking it to that. So what I end up with is a service that is unable to start because it can't use the DLL file.
Here is my ProjectInstaller class:
[RunInstaller(true)]
public partial class ProjectInstaller : System.Configuration.Install.Installer
{
public ProjectInstaller()
{
this.AfterInstall += new System.Configuration.Install.InstallEventHandler(ProjectInstaller_AfterInstall);
InitializeComponent();
}
void ProjectInstaller_AfterInstall(object sender, System.Configuration.Install.InstallEventArgs e)
{
using (ServiceController sc = new ServiceController("HostingPanelDC"))
{
try
{
sc.Start();
}
catch (Exception ex)
{
EventLog.WriteEntry("HostingPanel", "Unable to start service. Error: " + ex.Message, EventLogEntryType.Error);
}
}
}
}
I set the service name and all the service info by clicking serviceInstaller1 and serviceProcessInstaller1 and editing the fields in the properties page.
Here is my windows service class:
partial class WindowsService : ServiceBase
{
public ServiceHost serviceHost = null;
public WindowsService()
{
InitializeComponent();
ServiceName = "HostingPanelDC";
}
public static void Main()
{
ServiceBase.Run(new WindowsService());
}
protected override void OnStart(string[] args)
{
if (serviceHost != null)
serviceHost.Close();
serviceHost = new ServiceHost(typeof(DC.DomainController));
serviceHost.Open();
}
protected override void OnStop()
{
if (serviceHost != null)
{
serviceHost.Close();
serviceHost = null;
}
}
}
What exactly am I missing that is causing this not to generate the exe file? Thank in advanced!
|
|
|
|
|
Duh. Forgot to change the output to windows application and set the startup object. Thanks!
|
|
|
|
|
Suggestion,I was only able to install my service using the command line once I ran my installer, if you google the command line function and use it for your service to show up in the actual list of services.
|
|
|
|
|
Thanks for the suggestion! Once I made the changes listed above I was able to install and start the service automatically with the windows installer once I changed my WCF DLL Library that had the windows service and installer to a Windows Application and set the startup object
|
|
|
|
|
Hi Guys,
I'm not English so I'll try to explain my problems as simple as possible
I've been trying to backup/restore SQLce database for one of my latest applications.
This is how my code looks like:
This button opens location in which user can save .sdf (backup):
private void button2_Click(object sender, EventArgs e)
{
DialogResult ofd = folderBrowserDialog1.ShowDialog();
if (ofd == DialogResult.OK)
{
string backupPath = folderBrowserDialog1.SelectedPath;
textBox4.Text = backupPath;
}
}
... then file is being saved in chosen location (backup):
private void button4_Click(object sender, EventArgs e)
{
string fileName = "Database.sdf";
string sourcePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string backupPath = textBox4.Text;
string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
string destFile = System.IO.Path.Combine(backupPath, fileName);
System.IO.File.Copy(sourceFile, destFile, true);
}
To restore database user opens location with .sdf file:
DialogResult ofd = folderBrowserDialog1.ShowDialog();
if (ofd == DialogResult.OK)
{
string backupPath = folderBrowserDialog1.SelectedPath;
textBox5.Text = backupPath;
}
}
...and restore file using this code:
try
{
string fileName = "Database.sdf";
string sourcePath = textBox5.Text;
string restorePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
string destFile = System.IO.Path.Combine(restorePath, fileName);
System.IO.File.Copy(sourceFile, destFile, true);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
I've checked all of this locally I mean after debugging and works perfectly.
When my application is published and than installed this code doesn't work. Throws an error 'Could not find file C:\Users\Lion\AppData\Local\Apps\2.0\J98YQDCL.P3L\3TX9ONZ9.XO3D\Database.sdf'
So its working before application is being published. Once is published and installed doesn't work.
Any ideas why? Could anyone please help me with this problem?
Thank you in advance for your help.
|
|
|
|
|
saturnuk wrote: 'Could not find file C:\Users\Lion\AppData\Local\Apps\2.0\J98YQDCL.P3L\3TX9ONZ9.XO3D\Database.sdf'
That message should give you a clue as to the problem.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Is the file in the actual location?
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
No this file doesn't exist in this location. And I know this. The question is how I can get this file? Where is the file?
System.IO.FileNotFoundException: Could not find file 'C:\Users\Lion\AppData\Local\Apps\2.0\J98YQDCL.P3L\3TX9ONZ9.XO3\cali..tion_b66fbc81589c75c7_0001.0000_012e4219e7fd7afb\Database.sdf'.
File name: 'C:\Users\Lion\AppData\Local\Apps\2.0\J98YQDCL.P3L\3TX9ONZ9.XO3\cali..tion_b66fbc81589c75c7_0001.0000_012e4219e7fd7afb\Database.sdf'
Thanks
|
|
|
|
|
saturnuk wrote: No this file doesn't exist in this location. And I know this. The question is how I can get this file? Where is the file?
Using ClickOnce[^]?
Every ClickOnce application installed on a local computer has a data directory, stored in the user's Documents and Settings folder. Any file included in a ClickOnce application and marked as a "data" file is copied to this directory when an application is installed. Data files can be of any file type, the most frequently used being text, XML, and database files such as Microsoft Access .mdb files.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Try this to find the file:
SqlCeConnection con = new SqlCeConnection(connectionString);
string databaseFilePath = con.Database;
con.Close();
0200 A9 23
0202 8D 01 80
0205 00
|
|
|
|
|
this[^] is what I'm after.
Infragistics so called help is horrible. Can't find anything that gets me what I want. There are scattered topics found in Google, but their not much help.
Anyone know how to do this? A code example would be nice.
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
You've only just posted the message on the Infragistics site. Give them a chance.
|
|
|
|
|
Actually, I posted here first. I find that asking a question either take way too long to get a response, or their responses are not very good.
If it's not broken, fix it until it is
|
|
|
|
|
One of the amazing things about Telerik support is that 90% of the time they supply a sample project. I generally have a 24 hour turn around b/c I'm on the other side of the planet. That and the depth of the Infragistics object model convinced us to change suites...
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: That and the depth of the Infragistics object model convinced us to change
suites...
LOL
I absolutly LOVE Telerik. I agree with your comments 100%
One of the guys here looked at the source code for the Infragistics UltraGrid COLUMN, just the column ...... 60+ lines of code!!!
If it's not broken, fix it until it is
|
|
|
|
|
C# is not allowing me to define a Serial Port speed.
He says the max is 115200
I have seen other apps run 921600 on this very machine right in front of my eyes.
What gives ?
|
|
|
|
|
C-P-User-3 wrote: He says the max is 115200
I don't believe that's right. It sounds like a limit of the hardware - if you take a look at this[^] article, you'll see a link to COMMPROP[^] which contains the BAUD rates.
|
|
|
|
|
Pete O'Hanlon wrote: , you'll see a link to COMMPROP[^] which contains the BAUD rates.
That page is for C++
Duh ? I [can | can't] use that in C#
|
|
|
|
|
More duh.
I see: dwSettableBaud in the list of COMMPROP structure
I can change that value ? In C# ?
The biggy: can I change it to 921600 ?
Super nice would be able to select it from a list
|
|
|
|
|
The reason I linked to the original article is because it's a C# version - so all the hard work has been taken care of for you.
|
|
|
|
|
I'm studying the example you suggested, "Basic serial port listening application". I'm trying to grasp the section titled, "...Updating baud rates supported by the selected device..."
I see that he opens the port, and then does some really really strange things to to something with the BaudRate (still trying to grasp the concepts) with something like eleven different levels of magic words, parentheses (2, 3, or 4 of them, not really sure at this moment) and some "or" lines, I think.
After all that, he closes the port.
Will the port remain at the speed he chose for the next open ?
|
|
|
|
|
The values there are instance values, so as long as the class is held by an instance, and as long as there is no other code changing these values, they will remain the same. Bear in mind that this is purely an example of the code in his library, it doesn't necessarily mean that he's closing the port immediately after he opens it - that's just the way he's presented the methods, with the close quite logically following the open.
|
|
|
|
|
Pete O'Hanlon wrote: as long as there is no other code changing these values, they will remain the same.
Okay, so, if I put that in an "init" sort of section, then I can open and close all day long and still keep the same speed ?
If so, that could help things a lot.
|
|
|
|
|
You should be able to - it really depends on whether you need to free that port up for anything else.
|
|
|
|
|
No, he is totally stuck with the external box the whole time. The customer wants it that way; in fact, it's a part of the entire system design; their people, processes, the whole works.
I'm still trying to figure out how to put different stuff in different files and let everybody see it.
|
|
|
|