|
I have the follwing Problem. We have developed an application for a mobile device using windows mobile 5 as operating system. In the next step we want to install new versions of the software but we neet to uninstall the old version first. Since we don't have Active Sync all the time, and we don't want the user to uninstall the software over the systems>remove programs.
I'm just looking for the exe which is capable of removing applications from the mobile device, similar to msiexec.exe on other windows based systems. And then using c# code to remove/uninstall the application.
Any ideas?
|
|
|
|
|
Hi..
I need to get the List of all the user Name from Active Directory, i used the following code.
try{
ADEntry = new DirectoryEntry("LDAP://" + Session["DominName"].ToString() + ".net", txtUserName.Text.ToString(),
txtPassword.Text.ToString(), AuthenticationTypes.Secure);
nativeObject = ADEntry.NativeObject;
}
catch (Exception)
{
DirectorySearcher mySearcher = null;
mySearcher = new DirectorySearcher(ADEntry);
mySearcher.SearchRoot = ADEntry;
mySearcher.Filter = "(&(objectClass=USER))";
mySearcher.SearchScope = SearchScope.Subtree;
mySearcher.PropertiesToLoad.Add("SAMACCOUNTNAME");
mySearcher.PropertiesToLoad.Add("cn");
mySearcher.PropertiesToLoad.Add("mail");
SearchResult srh = null;
srh = mySearcher.FindOne();
int intSerialNo = 1;
foreach (SearchResult resEnt in mySearcher.FindAll())
{
resEnt.Properties["SAMACCOUNTNAME"][0].ToString();
resEnt.Properties["cn"][0].ToString();
resEnt.Properties["mail"][0].ToString();
}
But it is listing Max 1000 users details but there are 2000 entries in the ADS under "user" group..<br />
<br />
<br />
Please anyone Help me to get the list of all the 2000 user's list in ADS..<br />
<br />
if there is a limitation for LDAP protocol.. Can any one suggest other protocol, i tried with WINNT, NDS and IIS also..<br />
<br />
<br />
|
|
|
|
|
Yes, LDAP has a limit of 1000 result for a single search. To avoid that you must perform a paged search.
To do that, just set the PageSize property of the DirectorySearcher object to a value greater than 0 (e.g. 500 or 750) before calling the FindAll method.
The MSDN documentation for that is Here[^].
|
|
|
|
|
Thank you very much Mirko.
regards
skvs
|
|
|
|
|
Hi friends,
I have a RichTextBox control, and read a part of a file into a MemoryStream and then load that in my RichTextBox, here's my code:
void FillRTB(string filepath)
{
MemoryStream memStream = new MemoryStream();
FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.ReadWrite);
byte[] ByteRead = new byte[1];
for(int i = 0; i < 300; i++)
{
fs.Seek(i, SeekOrigin.Begin);
fs.Read(ByteRead, 0, 1);
memStream.WriteByte(ByteRead[0]);
}
rtbText.LoadFile(memStream, RichTextBoxStreamType.PlainText);
}
But rtbText shows nothing! I have no error too!
Any idea? Thank you.
While (true) { Human.isLearnable = true; }
|
|
|
|
|
How about this?
void FillRTB(string filepath){
byte[] ByteRead = new byte[300];
using (FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.ReadWrite))
{
fs.Read(ByteRead, 0, 300);
}
MemoryStream memStream = new MemoryStream(ByteRead);
richTextBox1.LoadFile(memStream, RichTextBoxStreamType.PlainText);
}
modified on Monday, October 20, 2008 4:37 AM
|
|
|
|
|
Well, I had error, "The name 'fs' does not exist in the current context"
I tried this:
void FillRTB(string filepath)
{
byte[] ByteRead = new byte[300];
FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.ReadWrite);
fs.Read(ByteRead, 0, 300);
MemoryStream memStream = new MemoryStream(ByteRead);
rtbPage.LoadFile(fs, RichTextBoxStreamType.PlainText);
}
and yes, it works, Thanks. But what if I have a dynamic length? Ex:
void FillRTB(string filepath, long Characters);
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Pedram Behroozi wrote: The name 'fs' does not exist in the current context
Sorry about that. It is fixed.
Pedram Behroozi wrote: But what if I have a dynamic length? Ex:
Unless you don't know how much to read, how can you do it? You have to pass length to FillRTB method.
|
|
|
|
|
Can I dynamically get the length?
void FillRTB(string filepath, long length);
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Pedram Behroozi wrote: Can I dynamically get the length?
I didn't get you. What do you mean by dynamically getting the length?
|
|
|
|
|
Sorry, My Bad English...
I mean how can I implement this:
void FillRTB(string filepath, long length);
I mean how can I have a variable with dynamic length?
Sorry again
While (true) { Human.isLearnable = true; }
|
|
|
|
|
void FillRTB(string filepath,long length)
{
byte[] ByteRead = new byte[length];
using (FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.ReadWrite)) {
fs.Read(ByteRead, 0, ByteRead.Length);
}
MemoryStream memStream = new MemoryStream(ByteRead);
richTextBox1.LoadFile(memStream, RichTextBoxStreamType.PlainText);
}
|
|
|
|
|
Thank you very much. That's work...
N a v a n e e t h wrote: byte[] ByteRead = new byte[length];
I thought we can't declare variables like this. And actually I didn't test that
Thank you again
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Hi all,
I am trying to export image to PDF file using iTextSharp dll.
I created a PDF file(test.pdf) and added image to that pdf file. But the problem is when the image is too large ,its not showing the complete image in pdf file.
when the image height is large, i am automatically getting the vertical scroll bar in pdf file. but for width i am not getting any horizontal scroll bar.
Please suggest me how to export large images to pdf file without resizing the image. I s there any way to get the horizontal and vertical scroll for PDF file.
Thanks in advance
|
|
|
|
|
Hi.
I Build Report In C# Windows Application , and this Report Is Build His Columns By Dynamic Criteria, May be the Number of Columns In it is 5 or 7 or 13 or 20 or other , and I won’t to put this columns in the report as a good way , the all columns is Clear of the User , i add the columns at every number of it , but if the number is more than 7 columns the columns is not show in the Report is Hidden , then I calculate the width of Report and The Width of the max text in every columns and Other Options may be Decrees the Size of Font if the Columns Number is or Increase the Font , these Operation Depend On Number OF Columns .....
The Problem Is in Type of Screen, the Report is good if the Screen 15 but if screen is 17 the Report is Show in Not Good Way.
Who I can solve this Problem, and what is the Unite Of width the text and width of report (Cm, Inch …., Unites).
Thanks for any body help me
Thaer
|
|
|
|
|
Hi
We use an external library with a class with a static event looking like this:
public static event EventHandler ThemeChanged .
I want to clear it's invocation list, is that possible?
Anything that would cause ThemeChanged to not hold references to anything will do
Thanks
modified on Monday, October 20, 2008 3:23 AM
|
|
|
|
|
Try setting that to NULL .
|
|
|
|
|
Unfortunately it's not that easy
error CS0079: The event 'ThemeChanged' can only appear on the left hand side of += or -=.
It would also be easy using reflection if it was non static.
|
|
|
|
|
Ok, how about writing a method which sets this to NULL?
class MyTheme
{
public static event EventHandler ThemeChanged;
public void ClearInvocationList()
{
ThemeChanged = null;
}
} You can implement this in destructor and use dispose pattern and set it to NULL.
|
|
|
|
|
I can't modify the source codes of that external library(I can but it causes other problems)
If I would have the possibility to modify it, I would do this:
public static event EventHandler ThemeChanged
{
add{}
remove{}
}
I don't need that event and it's causing memory leaks.
|
|
|
|
|
induur wrote: I can't modify the source codes of that external library
How about removing the handlers when application exits?
ExternalLibraryClass.ThemeChanged -= Yourhandler
edit
fixed typo
modified on Monday, October 20, 2008 6:48 AM
|
|
|
|
|
I need to do that during the life of my app.
Objects(controls) that subscribe to that event are also defined in the external libraries, I can't change their code.
During debuging VS allows me to look to the invocation list of that event, but from the code I can't get the references to subscribers. I was hoping there is a way to do that using reflection, but I have problems since the event is static. Is there a way to get the invocation list of a static event?
|
|
|
|
|
induur wrote: , but I have problems since the event is static
I think you will have problems even if it is not static. AFAIK, you won't get the invocation list from outside the class where event is declared. I will sit tonight and try to figure this. I will update you if I got something. Nice question though.
|
|
|
|
|
Thanks.
I'm looking forward to your response.
|
|
|
|
|
I think your best bet is to create a proxy class for your external library and route all calls through your proxy. Which means, you should not invoke your external library directly. It should be done via this proxy class.
Mimic the event in your proxy class. When items are added, keep the event handlers in a list. Create a method something like ClearInvocationList() in the proxy class, loop through all the event handlers in the list and unregister the event. Clear the list.
You can implement this cleanup in destructor also. But it is not recommended as finalization is performance costly. Look at implementing IDisposable instead.
Sample code follows, (uncompiled and exceptions not handled)
class ExternalLibraryProxy
{
List<EventHandler> subscriptions = new List<EventHandler>();
public event EventHandler ThemeChanged
{
add
{
ExternalLibrary.ThemeChanged += value;
subscriptions.Add(value);
}
remove
{
ExternalLibrary.ThemeChanged -= value;
subscriptions.Remove(value);
}
}
public void ClearInvocationList()
{
foreach(EventHandler handler in subscriptions)
ExternalLibrary.ThemeChanged -= handler;
subscriptions.Clear();
}
}
Hope this makes sense.
|
|
|
|