|
|
I can't use SetValue in the normal way because I the name of the class is treated as a type, not an object to call a method on.
<br />
Type myType = typeof(MyStaticClass);<br />
myType.GetProperty(PropertyName).SetValue(MyStaticClass,newValue,null);<br />
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Pass in null . I wrote a quick example and it worked fine.
myType.GetProperty(PropertyName).SetValue(null, newValue, null);
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Looks nicer than the InvokeMember call I found too.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Answer found with additional googling.
myType.InvokeMember(PropertyName, BindingFlags.SetProperty | BindingFlags.Default,null,null,new object[] {newValue);
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Hi guys,
I am trying to design a form with a button to drop the database tables and finally uninstall the application, i got the drop tables working but I have no idea on how to uninstall the application programmatically. Please help!!
sasa
|
|
|
|
|
When you install your application, it's automatically added to the Add/Remove control panel applet. The applet is actually calling the uninstaller that is supplied by you. To call that installer yourself:
Process.Start("MsiExec.exe /I{AC7DF146-BA42-4EC4-A90C-BC9FF970E7DF}");
Where that GUID is the Product Code property of your setup project. Note that you must close the exe file once the uninstall has started or make a custom action to do that for you.
Regards
|
|
|
|
|
Pardon my ignorance in this matter.
Can I use your above suggestion as follows;
System.Diagnostics.Process Proc = new System.Diagnostics.Process();
Proc.StartInfo.FileName = "MsiExec.exe /I{11111111-1111-1111-1111-111111111111}";
Proc.Start();
Also, what does /I stand for?
Thank you in advance.
sasa
|
|
|
|
|
It's impossible that your Product Code is that?!! To get your product code:
1- Open the solution explorer
2- Right Click on the name of the setup project => Properties
3- In the Property Grid look for Product Code property. Copy it.
4- Paste it in the code I supplied instead of my GUID.
SASA_1 wrote: Also, what does /I stand for?
The "/I" is a command line argument that is passed to Windows installer. It tells the installer if you wish to modify/repair/remove you applicatino. In this case it will tell the installer that you want to remove, but don't worry; The uninstallation doesn't do it automatically. It opens up normally as you'd have clicked on the Add/Remove icon.
PS.
Did you decide how to handle closing your active application? Uninstallation won't work until you close it.
Regards
|
|
|
|
|
My product code is {C53335FB-9BAA-4F41-A47C-0474249B089B} and this is what I have now for my code which doesn't work;
System.Diagnostics.Process.Start("msiexec.exe /i{C53335FB-9BAA-4F41-A47C-0474249B089B}");
this.Close();
I get an unhandled exception saying the system can't find the file specified....
Please advice
sasa
|
|
|
|
|
|
Well, You can use this instead:
Process Proc = new Process();
Proc.StartInfo = new ProcessStartInfo("MsiExec.exe", "/I{23959E96-A80F-4172-A655-210E9BB7BFBE}");
Proc.Start();
PS.
Again replace that GUID with yours.
Regards
|
|
|
|
|
if u want silent uninstallation, use /q.
|
|
|
|
|
Thank you much man, I really really appreciate your help. I put the code in the main of the form and got it to work.
sasa
|
|
|
|
|
Hi Everybody
I was just wondering if there is anyone who has got any experience in streaming sound using C# as well as processing it using DSP algorithms e.g. FFT, filtering...( in the same manner as done in Matlab). I would really appreciate all inputs especially since I have never done anything similar before… Maybe you know of some good articles/links or code examples...I would also like to know (if possible) what to prefer when streaming sound: C# or java...
Thanks a lot
AL
-- modified at 16:16 Tuesday 12th December, 2006
|
|
|
|
|
Will this[^] open-source DSP library help?
/ravi
|
|
|
|
|
I will look into it seems very interesting,
Thanks alot
AL
|
|
|
|
|
I'm dynamically building my web.sitemap from the database table. It has all the first and second level menu items. On these pages, there are some hyperlinks to more child pages that aren't not in the sitemap. When I drilled down to these child pages, the SiteMapPath disappears. That makes sense since that page isn't in the sitemap BUT I would like to just freeze the breadcrump with the last valid option. Basically, how can I get the SiteMapPath only to refresh (change) when a menu item is changed? Not when a hyperlink is changed?
example:
menu item 1 (in web.sitemap and appears in the SiteMapPath)
menu item 2 (in web.sitemap and appears in the SiteMapPath)
hyperlink on menu item 2 page (not in web.sitemap and SiteMapPath is blank)
For the hyperlink, I would like the SiteMapPath to display the menu item 2. Any ideas??
Thanks, Jessica
|
|
|
|
|
Hi All,
the problem is that I want to change the border colour of the form. The strip on which the maximize, minimize and close button resides.
Plz Help Me
SAS
|
|
|
|
|
I'm currently working on a project which requires me to read Unicode File Names. Does the FileInfo class do this ? How can I create a unicode file in order to test this..
jon
|
|
|
|
|
Dato wrote: I'm currently working on a project which requires me to read Unicode File Names
I thought any program developed in C# can read unicode -unless you explicitly ask for ASCII-
Dato wrote: Does the FileInfo class do this
Yes.
Dato wrote: How can I create a unicode file in order to test this..
You have to use non-English caracters for that. For example; Add the eastren -e.g. chinese- languages support to your windows. Go to any chinese web site, and copy/paste some text from there -you don't have to understand it- into a file name and try to open it using your app.
Regards
|
|
|
|
|
I am developing a windows form app in C# -.net 1.1 framework.
The app creates 4 objects and executes a "Go" method in 4 threads - each thread goes off, grabs some data from a UDP socket, and processes it.
What I need is to get the processed data from each of the 4 threads (objects) and combine them into one string. I can not figure out how to get the individual threads to return anything. I tried to create a string and pass it to each object's constructor as a reference, but that went nowhere. Does anyone have any ideas on how I can accomplish this?
Dan
Senior Developer
Mitsubishi Power Systems
Now where did I put that Char....
|
|
|
|
|
As long as your threads are objects inside your class, they can manipulate any field -even private ones- including strings. My suggestion to your situation is to make a string obkect inside your class. then either you:
1- Make a single common method that takes parameters passed by the calling thread to add it to the single string object
2- Access that single string object in the different methods of threads -you don't need to return- the way that suits you -this is if you got different methods for different threads. If they all start with the same method, this won't apply-.
Very important thing to note is to apply a lock on the string object to prevent threads from modifying it simultaneously.
Regards
|
|
|
|
|
Let me give you some psudeo code - because I'm not understanding. Here is what I am doing:
public class MainClass
{
private void GetData()
{
MyObject mo = new MyObject();
Thread t = new Thread(new ThreadStart(mo.Connect));
t.Start();
MyObject mo2 = new MyObject();
Thread t2 = new Thread(new ThreadStart(mo2.Connect));
t2.Start();
MyObject mo2 = new MyObject();
Thread t3 = new Thread(new ThreadStart(mo3.Connect));
t3.Start();
MyObject mo3 = new MyObject();
Thread t4 = new Thread(new ThreadStart(mo4.Connect));
t4.Start();
//WHAT I WANT TO DO IS BE ABLE TO GRAB THE RESULTS FROM THE THREADS STARTED ABOVE
//AND PUSH THEM INTO A FILE. I NEED ALL OF THE DATA FROM ALL FOUR THREADS COMBINED INTO ONE FILE
}
}
Public class MyObject
{
public MyObject()
{
}
public void Connect()
{
//Starts all the socket stuff..
}
//...OTHER SOCKET RELATED FUNCTIONS GO HERE.
}
How do I get the data in the Connect function to the calling function in MainClass?
uh... yeah
|
|
|
|
|
NameYou wrote: How do I get the data in the Connect function to the calling function in MainClass?
You don't need to. If there is no good reason not to access the file from that method, you should.
To be specific, here is my suggestion of you MyObject.Connect() method:
Public class MyObject
{
public MyObject()
{
}
public void Connect()
{
object LockObject = new object()
lock(LockObject)
{
StreamWriter MyStream = File.AppendText("MyFile.txt");
MyStream.WriteLine(Input);
MyStream.Close();
}
}
}
Of course you got to do some modifications to the code to suite your needs, but I hope this was close enough.
Regards
|
|
|
|