|
Unexpectedly this procedure revealed positive for both laptops... 
|
|
|
|
|
Do you know what are the steps to implement ETW in C# application. Gone through various links but didn't get any start to end solution.
Below are few question 1. How to create data set controller?
2. How can I create trace as LogMan does?
3. How to create listener?
4. How to interact with listner?
Please suggest.
Thanks in Advance, Sapan
|
|
|
|
|
Why don't you just use a third party dll like log4net to do the tracing for you?
This would help you avoid implementing tracing from scratch.
|
|
|
|
|
hello friends,
I have an one console application w.r.t delegates but while executing am facing 2 errors, here is the code . .
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Delegates
{
delegate string StrMod(string str);
class DelegateTest
{
// replace spaces with hypens
static string ReplacesSpaces(string s)
{
Console.WriteLine("raplacing spaces with hypens.");
return s.Replace(' ','-');
}
//reomve spaces
static string RemoveSpaces(string s)
{
string temp="";
int i;
Console.WriteLine("Removing spaces.");
for(i=0;i<s.Length;i++)
{
if (s[i] != ' ')
{
temp = temp + s[i];
return temp;
}
}
}
//reverse a string
static string Reverse(string s)
{
string temp = "";
int i, j;
Console.WriteLine("Reversing string.");
for(j=0;i=s.Length-1;i--,j++)
{
if(i>=0)
{
temp=temp+s[i];
}
return temp;
}
}
static void Main(string[] args)
{
// construct a delegate
StrMod strOp = new StrMod(ReplacesSpaces);
string str;
//call method through delegate
str = strOp("This is a test.");
Console.WriteLine("Resulting string:" + str);
Console.WriteLine();
strOp = new StrMod(RemoveSpaces);
str = strOp("This is a test.");
Console.WriteLine("Resulting string:" + str);
Console.WriteLine();
strOp = new StrMod(Reverse);
str = strOp("This is a test.");
Console.WriteLine("Resulting string:" + str);
Console.WriteLine();
}
}
}
error:
Error 1 'Delegates.DelegateTest.RemoveSpaces(string)': not all code paths return a value C:\Users\Praveen\Documents\Visual Studio 2008\Projects\Delegates\Delegates\Program.cs 20 23 Delegates
Error 2 Cannot implicitly convert type 'int' to 'bool' C:\Users\Praveen\Documents\Visual Studio 2008\Projects\Delegates\Delegates\Program.cs 43 21 Delegates
As with concept wise delegates calling methods is right but am facing some problem in returning the value and in the for loop i.e, int to bool as both error shows
So plz concern this basic errors and give ur valuable feeds . .
Thanks,
praveen bellary
|
|
|
|
|
praveengb wrote: Error 1 'Delegates.DelegateTest.RemoveSpaces(string)': not all code paths return a value
static string RemoveSpaces(string s)
{
string temp="";
int i;
Console.WriteLine("Removing spaces.");
for(i=0;i<s.Length;i++)
{
if (s[i] != ' ')
{
temp = temp + s[i];
return temp;
}
}
}
This method does not return anything if the if-case is never true. This leads to 'not every possible scenario' is returning a string as expected. Add a return statement after 'for ' ends to correct it. If nothing else, return an empty string.
praveengb wrote: Error 2 Cannot implicitly convert type 'int' to 'bool'
Your checking condition in for loop here:
for (j = 0; i = s.Length - 1; i--, j++)
It should be a boolean true-false condition. Try:
i <= s.Length -1
|
|
|
|
|
Hi All,
is it possible to install an sql server 2008 with my c# windows application setup.
Please help me if it can.
thanks alot.
|
|
|
|
|
|
Hi,
Thanks you for your reply, but when i add the sql server as a prerequisites to my setup there is no way to set the instance name for the sql server that must installed.
do you know how to do that.
and do you know how to add custom dialog with different controls such as 2 radiobuttons and 2 textboxes.
Thanks alot for your help.
|
|
|
|
|
|
You should NOT be doing that.
SQL Server should be installed seperately by the user, if at all. Your application installer should ask the user for the SQL Server connection details, like servername, IP address, port, instance name, username and password to use to install/attach your database.
If the user already has SQL Server installed, they can use that, as well as putting the database on a seperate machine from the one your app is installed on.
By putting the SQL Server installation inside your own setup, you are limiting the choices the user has to install your app.
|
|
|
|
|
Not a good idea.
Run the SQL server installer using its own setup.
You can however, use custom actions to make your installer do certain tasks like register a dll etc.
|
|
|
|
|
I have a program for synchronizing my computers time from the time on the Internet, but since I updated my program to Windows7 it no longer works. If I run the program by right clicking on it and running it as an Administrator it will run and change the time on my computer. Otherwise, the program runs and it does not change the time.
How do I run this program in C# as an administrator, any help will be greatly appreciated.
Thanks in advance
Michael
|
|
|
|
|
This is by design to make it harder for program to make suspicious changes to the system. You can modify the manifest to indicate that the application should always be run as an admnistrator (or modify the link). That way, you will have one less step to do as a regular start will start the application with administrative right. You still have to confirm that you want your application to have that priviledge.
Depending on the application, it might make more sense to check the time and only if a change is required then prompt the user. This will typically be done by using 2 exécutable files. That approch would be the one an application with auto-update would typically use.
Philippe Mori
|
|
|
|
|
It would be my guess (and suggestion if it works) that you could and should create a Windows service that starts automatically, logged in as say System, and stays alive as long as Windows does. Then you would never interact with it nor been bothered by it or any UAC dialog.
|
|
|
|
|
You do not need a program of your own for setting your computer's time. There are time servers on the internet, and Windows can get the "correct" time from them.
|
|
|
|
|
You are correct that setting the time does require admin rights.
I suggested a couple of possible solutions here[^].
|
|
|
|
|
i want to know how can i make double right click for button C#
and in the same time i make another right click for this button event
|
|
|
|
|
Care to elaborate more on what are you trying to do here? It would help you in getting some direction.
|
|
|
|
|
how can i make double right click for button C#[^]
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
I really need to take a look at my code that does that (at least single-right-click). I don't claim it's the best way. But seeing as you cross posted, I won't hurry.
|
|
|
|
|
Hi,
i want to develop a program in C# which reads and analyzes values from Pulse LabShop (a Bruel & Kjaer tool to measure & analyze acoustics).
With a VB2010 example i found i was able to read out values via the COM&OLE interface:
-------------------------------------------
Public Class Form1
Dim myPulse As PulseLabShop.Application
Dim myDataSet As PulseLabShop.BKDataSet
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
myPulse = CreateObject("Pulse.LabShop.Application")
myPulse.Visible = True
Me.Text = "ControlPULSE " + myPulse.Name
Label1.Text = myPulse.Project.FunctionOrganiser.FunctionGroups(1).Name
End Sub
---------------------------------------
Now i wanted to code the same in C# 2010:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace C_PulseTest
{
public partial class Form1 : Form
{
PulseLabShop.Application myPulse;
PulseLabShop.BKDataSet myDataSet;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
myPulse = new PulseLabShop.Application("Pulse.LabShop.Application");
myPulse.Visible = true;
this.Text = "ControlPULSE " + myPulse.Name;
label1.Text = myPulse.Project.FunctionOrganiser.FunctionGroups(1).Name;
}
}
}
However the code is not working due to an error in the last line:
Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
I also tried [0] or [1] or ("string") as index - but all with the same error...
Is there something wrong in general with my C# code?
Any other idea why the index is not working?
Thanks a lot for all possible help!
BR
Tobias
|
|
|
|
|
Where are you getting the exception? I can see 2 places that could cause a problem.
|
|
|
|
|
I get the error in the last line with reference to (1):
label1.Text = myPulse.Project.FunctionOrganiser.FunctionGroups(1).Name;
|
|
|
|
|
What happens if you inspect myPulse.Project.FunctionOrganiser in the watch window? Is there a method for getting the count of FunctionGroups elements? My suspicion is that this is null - BTW, C# is zero based so you would need to use 0 and not 1 (even though when you tried it, it didn't work for you).
|
|
|
|
|
Interestingly the following line returns "7" (There are indeed 7 Function Groups available)
label1.Text = Convert.ToString(myPulse.Project.FunctionOrganiser.FunctionGroups.Count);
When i compare the Object myPulse in VB2010 and C#2010 i saw that in VB2010 i can unfold it to Project to FunctionOrganiser to Function Groups and also a few properties like "Name" are shown. In C#2010 i can't unfold it and there are also no properties shown.
So could it been that i have to initialize or define the object myPulse in a different way?
Thanks!
|
|
|
|