|
Sorry for not getting back sooner. In the OnStart method I'll be creating a couple of threads, a dozen or sockets and creating some objects but they won't depend on base.OnStart().
Let's say that something in my OnStart fails (file not found for example), how would I report that startup has failed and stop the startup of the service? Do I simply not call base.OnStart()?
modified on Sunday, December 6, 2009 9:15 PM
|
|
|
|
|
That depends on what else you do in your OnStart; I call base.OnStart in the middle:
protected override void
OnStart
(
string[] args
)
{
# if DEBUG
System.Threading.Thread.Sleep ( 60000 ) ;
# endif
this.oktoproceed = true ;
base.OnStart ( args ) ;
if ( this.when != null )
{
this.when.Start() ;
}
LogMessage ( this.ServiceName + " started" ) ;
return ;
}
(The Sleep gives me time to attach the debugger. when is a System.Timers.Timer .)
|
|
|
|
|
hey guys,
i wanted to program a windows CE device by c# and my purpose is to print a simple page. but in 'device application' windows form, there is no 'PrintDialog' nor 'PrintDocument' (and other necessary) classes for me to manage a print .
how can i print through a windows CE device?
much appreciated.
modified on Saturday, November 28, 2009 1:32 PM
|
|
|
|
|
How do you attach a printer to a windows CE device ? Do they have USB ports and printer drivers ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
yes exactly. i have a usb printer connected to my device and my windows recognizes it and the driver.
i can print with other applications in windows CE (like microsoft word) but i want my own application to print a page. how is it?
thanks.
|
|
|
|
|
I have several columns I want to print the column headers vertically and not horizontal.
I have found a method that works but does not meet the expectations speficied.
Option 1) (This way does not meet specifications but does work)
- I could loop thru the string placing a carrage return after each letter.
Option 2) (This way meets specifications and I can get it to print on the screen. However I can not get it to print onto the printer)
private void dgvReport_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)<br />
{<br />
<br />
if (e.RowIndex == -1 && e.ColumnIndex >= 4)<br />
{<br />
e.PaintBackground(e.ClipBounds, true);<br />
Rectangle rect = <br />
this.dgvReport.GetColumnDisplayRectangle(e.ColumnIndex, true);<br />
Size titleSize =<br />
TextRenderer.MeasureText(e.Value.ToString(), e.CellStyle.Font);<br />
if (this.dgvReport.ColumnHeadersHeight < titleSize.Width)<br />
this.dgvReport.ColumnHeadersHeight = titleSize.Width;<br />
<br />
e.Graphics.TranslateTransform(0, titleSize.Width);<br />
e.Graphics.RotateTransform(-90.0F);<br />
<br />
e.Graphics.DrawString(e.Value.ToString(), e.CellStyle.Font,
Brushes.Black, new PointF(rect.Y, rect.X));<br />
<br />
e.Graphics.RotateTransform(90.0F);<br />
e.Graphics.TranslateTransform(0, -titleSize.Width);<br />
e.Handled = true;<br />
} <br />
<br />
}
This way actually rotates the column headers to ensure their vertical the same as their horizontal.
How can I print this way (Option 2)
|
|
|
|
|
What additional information is needed to aid in resolving this issue?
I need to be able to print my column names horizontal.
I can not seem to figure this out when going to the printer. Please help.
|
|
|
|
|
Hi every one.
I wana make a report from dataBase,Instead of using and showing it in crystalReport i want it in Word.
Can u help me please.Thank you .
CanI
|
|
|
|
|
You can get the data from the database using ADO.Net and then format it as per your need. To write the same to a word file, you can use interop.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Have a look at an open source project called Migradoc, this makes RTF files from data,
without word installed, you can export to word from the crystal viewer or use interop
but the MS Word product must be installed.
All the word versions will open RTF and this should be sufficient for a report
|
|
|
|
|
I am trying to connect a client to server using WCF.
The following code works when the server code is loaded (named pipe, same machine).
m_app is initialized as follows:
const string address = @"net.pipe://localhost/Pipe";
EndpointAddress ep = new EndpointAddress(address);
m_app = ChannelFactory<iservicecontract>.CreateChannel(new NetNamedPipeBinding(), ep);
I am trying to catch the exception EndPointNotFoundException. The catch block below initially used EndPointNotFoundException but didn't work so I tried CommunicationException.
I want to catch the situation where the server is not present.
What am I missing?
try
{
LoginResult result = m_app.DoLogin(username, password);
return result;
}
catch (CommunicationException e)
{
}
|
|
|
|
|
Perhaps you could just catch Exception , inspect the derived type, then recode to catch that exception? (I'm surprised CommunicationException didn't work).
/ravi
|
|
|
|
|
We use reflection to get properties of a type. Here is a class :
namespace Test
{
internal class MyClass
{
public MyClass(){}
}
class MyTest
{
public static int Main(string[] args)
{
Assembly asm = Assembly.GetExecutingAssembly();
Type[] types = asm.GetTypes();
foreach(Type type in types)
Console.WriteLine(String.Concat(type.Name,":\t",type.IsPublic);
}
}
}
"MyClass" is a "intenal" class. However, there seems no property for decide this in Type Class.
Type.IsPublic, Type.IsNestedAssembly ... all these properties seems not work.
Is there any method to take care of this ?
Thanks.
|
|
|
|
|
Please do not cross post.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Anyone has any idea ?
There is no reason we couldn't judge an "internal" class since we have obtained all types in an assembly by reflection.
|
|
|
|
|
Hiii all.............
I think u don't mined to help me at project of ...
How i can represent an image, voice & vedio trafic after we capture it
(using SharpPcap)from the application layer at TCP ???
|
|
|
|
|
I don't understand this at all. What are you asking ? How to render it, or how to send it across the network, or something else ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hello everyone
I want a fully editable, DB interacted data grid view.
By some mystake, the system has multiple DB's and I cannot use the interface. I have to enter the code to call a table from a specific database, I don't ask how can I fix this, we got along together well until now
I made this data grid view editable, that user can add rows and edit info on the table.
My questions are
-How can I call a table from database to view in this grid view
-How can I save the table's final state? (this is a single usered non-online system so performance is not issue, I can appreciate a solution that drops the previous table and creates a new one with the edited data grid view)
Thank you
|
|
|
|
|
-How can I call a table from database to view in this grid view
SqlDataAdapter SQL_Adapter;
DataTable dtReport1 = new DataTable();
string SQL_Command = "SQL STATEMENT GOES HERE"
SQL_Command += "'" + strExecutive + "', '" + strToolClass + "'";
try
{
using (SQL_Conn = new SqlConnection(WhatIsTheSQLConnectionString))
{
if (SQL_Conn.State != ConnectionState.Open)
{
SQL_Conn.Open();
}
else
{
SQL_Conn.Close();
SQL_Conn.Open();
}
using (SQL_Adapter = new SqlDataAdapter(SQL_Command, SQL_Conn))
{
SQL_Adapter.Fill(dtReport1);
dgvReport.DataSource = dtReport1;
dgvReport.Refresh();
gbToolStatusBoard.Refresh();
}
SQL_Adapter.Dispose();
}
SQL_Conn.Close();
}
catch
{ return; }
-How can I save the table's final state? (this is a single usered non-online system so performance is not issue, I can appreciate a solution that drops the previous table and creates a new one with the edited data grid view)
For this method you would simply export the datatable directly back to the main table after flushing out the data in the origional table.
|
|
|
|
|
oh thank you, I'll give it a try
|
|
|
|
|
Hello,
how can i run or create an instance of a class, which runs in a sandbox (so have no access to the filesystem and so on) and is only able to communicate over for example my host application over an api?
The api and so on is no problem, that is already implemented, but the problem is to restrict all those access...
Has somebody any idea for doing this?
Thanks
|
|
|
|
|
I don't know if you'll be able to do everything you've described, but you could probably try loading the assembly with various permissions. I'm not certain how you would go about this though.
|
|
|
|
|
If the classes in the Assembly wants to access the system I don't think you can stop it.
|
|
|
|
|
{"Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))"}
im passing int value in CR.
mine string value is working but not INTEGER.
HELP!!!!!
|
|
|
|
|
This code converts from string to index
String strIndex = "12";
Int32 nIndex = Convert.ToInt32(strIndex);
|
|
|
|